From 065b2fe3095fa3f9e897f2c0ef7510bce8d37096 Mon Sep 17 00:00:00 2001 From: Matthew Makai Date: Mon, 13 Apr 2015 12:06:27 -0400 Subject: [PATCH] updating main for loop based on @abadger code review --- .../modules/extras/notification/twilio.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/ansible/modules/extras/notification/twilio.py b/lib/ansible/modules/extras/notification/twilio.py index a45dc02298..faae7b6f58 100644 --- a/lib/ansible/modules/extras/notification/twilio.py +++ b/lib/ansible/modules/extras/notification/twilio.py @@ -157,17 +157,15 @@ def main(): to_number = module.params['to_number'] media_url = module.params['media_url'] - try: - if isinstance(to_number, list): - for number in to_number: - post_twilio_api(module, account_sid, auth_token, msg, - from_number, number, media_url) - else: + if not isinstance(to_number, list): + to_number = [to_number] + + for number in to_number: + try: post_twilio_api(module, account_sid, auth_token, msg, - from_number, to_number, media_url) - pass - except Exception: - module.fail_json(msg="unable to send text message to %s" % to_number) + from_number, number, media_url) + except Exception: + module.fail_json(msg="unable to send message to %s" % number) module.exit_json(msg=msg, changed=False)