diff options
author | Michael Scherer <mscherer@users.noreply.github.com> | 2016-10-15 17:21:01 +0200 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2016-10-15 08:21:01 -0700 |
commit | fb228d682d862ad1572295f74acbf0e10d290106 (patch) | |
tree | 7ec7c54c8a93694216ab88498d38acf4adb888c2 /monitoring | |
parent | baed114a92763661ac023d0c087ebde1a7fa15ce (diff) | |
download | ansible-modules-extras-fb228d682d862ad1572295f74acbf0e10d290106.tar.gz |
Make sensu_check compile on python 3 (#3177)
Diffstat (limited to 'monitoring')
-rw-r--r-- | monitoring/sensu_check.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/monitoring/sensu_check.py b/monitoring/sensu_check.py index 7cf38509..dff8d196 100644 --- a/monitoring/sensu_check.py +++ b/monitoring/sensu_check.py @@ -206,7 +206,8 @@ def sensu_check(module, path, name, state='present', backup=False): try: stream = open(path, 'r') config = json.load(stream) - except IOError, e: + except IOError: + e = get_exception() if e.errno is 2: # File not found, non-fatal if state == 'absent': reasons.append('file did not exist and state is `absent\'') @@ -327,7 +328,8 @@ def sensu_check(module, path, name, state='present', backup=False): try: stream = open(path, 'w') stream.write(json.dumps(config, indent=2) + '\n') - except IOError, e: + except IOError: + e = get_exception() module.fail_json(msg=str(e)) finally: if stream: @@ -381,4 +383,5 @@ def main(): module.exit_json(path=path, changed=changed, msg='OK', name=name, reasons=reasons) from ansible.module_utils.basic import * +from ansible.module_utils.pycompat24 import get_exception main() |