also fixed exceptions

pull/18777/head
Brian Coca 9 years ago committed by Matt Clay
parent 027aaed757
commit bfa63e01e5

@ -185,7 +185,7 @@ def sensu_check(module, path, name, state='present', backup=False):
try: try:
stream = open(path, 'r') stream = open(path, 'r')
config = json.load(stream.read()) config = json.load(stream.read())
except IOError as e: except IOError, e:
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\'')
@ -279,7 +279,7 @@ 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 as e: except IOError, e:
module.fail_json(msg=str(e)) module.fail_json(msg=str(e))
finally: finally:
if stream: if stream:

Loading…
Cancel
Save