mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-03 04:34:24 -07:00
Make sensu_check compile on python 3 (#3177)
This commit is contained in:
parent
151c6d2f88
commit
415c2d4591
2 changed files with 5 additions and 3 deletions
|
@ -206,7 +206,8 @@ def sensu_check(module, path, name, state='present', backup=False):
|
||||||
try:
|
try:
|
||||||
stream = open(path, 'r')
|
stream = open(path, 'r')
|
||||||
config = json.load(stream)
|
config = json.load(stream)
|
||||||
except IOError, e:
|
except IOError:
|
||||||
|
e = get_exception()
|
||||||
if e.errno is 2: # File not found, non-fatal
|
if e.errno is 2: # File not found, non-fatal
|
||||||
if state == 'absent':
|
if state == 'absent':
|
||||||
reasons.append('file did not exist and state is `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:
|
try:
|
||||||
stream = open(path, 'w')
|
stream = open(path, 'w')
|
||||||
stream.write(json.dumps(config, indent=2) + '\n')
|
stream.write(json.dumps(config, indent=2) + '\n')
|
||||||
except IOError, e:
|
except IOError:
|
||||||
|
e = get_exception()
|
||||||
module.fail_json(msg=str(e))
|
module.fail_json(msg=str(e))
|
||||||
finally:
|
finally:
|
||||||
if stream:
|
if stream:
|
||||||
|
@ -381,4 +383,5 @@ def main():
|
||||||
module.exit_json(path=path, changed=changed, msg='OK', name=name, reasons=reasons)
|
module.exit_json(path=path, changed=changed, msg='OK', name=name, reasons=reasons)
|
||||||
|
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
|
from ansible.module_utils.pycompat24 import get_exception
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -63,7 +63,6 @@
|
||||||
/monitoring/circonus_annotation.py
|
/monitoring/circonus_annotation.py
|
||||||
/monitoring/datadog_monitor.py
|
/monitoring/datadog_monitor.py
|
||||||
/monitoring/rollbar_deployment.py
|
/monitoring/rollbar_deployment.py
|
||||||
/monitoring/sensu_check.py
|
|
||||||
/monitoring/stackdriver.py
|
/monitoring/stackdriver.py
|
||||||
/monitoring/zabbix_group.py
|
/monitoring/zabbix_group.py
|
||||||
/monitoring/zabbix_host.py
|
/monitoring/zabbix_host.py
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue