1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix undefined info error and accept HTTP 201 response code (#2643)

Prevent referenced before assignment error when `notify` argument is not specified and accept HTTP 201 (created) code.
This commit is contained in:
Marcin Kawa 2016-09-15 16:35:47 +01:00 committed by Matt Clay
parent d9b5d9e551
commit dde76066d3

View file

@ -117,14 +117,14 @@ def main():
# Send some audible notification if requested
if notify:
response, info = fetch_url(module, target_url, data=NSTR % cgi.escape(notify), headers=headers)
if info['status'] != 200:
module.fail_json(msg="unable to send msg: '%s', campfire api"
" returned error code: '%s'" %
(notify, info['status']))
if info['status'] not in [200, 201]:
module.fail_json(msg="unable to send msg: '%s', campfire api"
" returned error code: '%s'" %
(notify, info['status']))
# Send the message
response, info = fetch_url(module, target_url, data=MSTR %cgi.escape(msg), headers=headers)
if info['status'] != 200:
if info['status'] not in [200, 201]:
module.fail_json(msg="unable to send msg: '%s', campfire api"
" returned error code: '%s'" %
(msg, info['status']))