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:
parent
2f7be4ceef
commit
aa45bd8a94
1 changed files with 5 additions and 5 deletions
|
@ -117,14 +117,14 @@ def main():
|
||||||
# Send some audible notification if requested
|
# Send some audible notification if requested
|
||||||
if notify:
|
if notify:
|
||||||
response, info = fetch_url(module, target_url, data=NSTR % cgi.escape(notify), headers=headers)
|
response, info = fetch_url(module, target_url, data=NSTR % cgi.escape(notify), headers=headers)
|
||||||
if info['status'] != 200:
|
if info['status'] not in [200, 201]:
|
||||||
module.fail_json(msg="unable to send msg: '%s', campfire api"
|
module.fail_json(msg="unable to send msg: '%s', campfire api"
|
||||||
" returned error code: '%s'" %
|
" returned error code: '%s'" %
|
||||||
(notify, info['status']))
|
(notify, info['status']))
|
||||||
|
|
||||||
# Send the message
|
# Send the message
|
||||||
response, info = fetch_url(module, target_url, data=MSTR %cgi.escape(msg), headers=headers)
|
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"
|
module.fail_json(msg="unable to send msg: '%s', campfire api"
|
||||||
" returned error code: '%s'" %
|
" returned error code: '%s'" %
|
||||||
(msg, info['status']))
|
(msg, info['status']))
|
||||||
|
|
Loading…
Reference in a new issue