From f5329eb3370da969de6bbf6f6b33a3c8b43e7538 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 1 Mar 2016 14:22:28 -0600 Subject: [PATCH] Don't call sys.exit in sns_topic, use HAS_BOTO to fail --- .travis.yml | 2 +- cloud/amazon/sns_topic.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 86ce1a3a7c0..5e09a9a447f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,5 +16,5 @@ script: - python2.4 -m compileall -fq -x 'cloud/|monitoring/zabbix.*\.py|/dnf\.py|/layman\.py|/maven_artifact\.py|clustering/(consul.*|znode)\.py|notification/pushbullet\.py' . - python2.6 -m compileall -fq . - python2.7 -m compileall -fq . - - ansible-validate-modules --exclude 'cloud/amazon/sns_topic\.py|cloud/centurylink/clc_aa_policy\.py|cloud/centurylink/clc_alert_policy\.py|cloud/centurylink/clc_blueprint_package\.py|cloud/centurylink/clc_firewall_policy\.py|cloud/centurylink/clc_group\.py|cloud/centurylink/clc_loadbalancer\.py|cloud/centurylink/clc_modify_server\.py|cloud/centurylink/clc_publicip\.py|cloud/centurylink/clc_server\.py|cloud/centurylink/clc_server_snapshot\.py|cloud/docker/docker_login\.py|messaging/rabbitmq_binding\.py|messaging/rabbitmq_exchange\.py|messaging/rabbitmq_queue\.py|monitoring/circonus_annotation\.py|network/snmp_facts\.py|notification/sns\.py' . + - ansible-validate-modules --exclude 'cloud/centurylink/clc_aa_policy\.py|cloud/centurylink/clc_alert_policy\.py|cloud/centurylink/clc_blueprint_package\.py|cloud/centurylink/clc_firewall_policy\.py|cloud/centurylink/clc_group\.py|cloud/centurylink/clc_loadbalancer\.py|cloud/centurylink/clc_modify_server\.py|cloud/centurylink/clc_publicip\.py|cloud/centurylink/clc_server\.py|cloud/centurylink/clc_server_snapshot\.py|cloud/docker/docker_login\.py|messaging/rabbitmq_binding\.py|messaging/rabbitmq_exchange\.py|messaging/rabbitmq_queue\.py|monitoring/circonus_annotation\.py|network/snmp_facts\.py|notification/sns\.py' . #- ./test-docs.sh extras diff --git a/cloud/amazon/sns_topic.py b/cloud/amazon/sns_topic.py index 9b4ae3f0516..71a66318290 100755 --- a/cloud/amazon/sns_topic.py +++ b/cloud/amazon/sns_topic.py @@ -134,9 +134,9 @@ import re try: import boto import boto.sns + HAS_BOTO = True except ImportError: - print "failed=True msg='boto required for this module'" - sys.exit(1) + HAS_BOTO = False def canonicalize_endpoint(protocol, endpoint): @@ -186,6 +186,9 @@ def main(): module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + if not HAS_BOTO: + module.fail_json(msg='boto required for this module') + name = module.params.get('name') state = module.params.get('state') display_name = module.params.get('display_name')