issue #994: use HAS_BOTO to determine if import was successful: - removed import of sys module. - HAS_BOTO constant to check if import was successful. - trigger a failure when import fails. - removed unnecessary imports.

This commit is contained in:
steenzout 2015-04-01 17:16:54 -06:00 committed by Matt Clay
commit 67f769d9a6
21 changed files with 121 additions and 74 deletions

View file

@ -131,16 +131,15 @@ EXAMPLES = """
"""
import sys
import os
import time
try:
import boto
from boto.elasticache.layer1 import ElastiCacheConnection
from boto.regioninfo import RegionInfo
HAS_BOTO = True
except ImportError:
print "failed=True msg='boto required for this module'"
sys.exit(1)
HAS_BOTO = False
class ElastiCacheManager(object):
@ -497,6 +496,9 @@ def main():
argument_spec=argument_spec,
)
if not HAS_BOTO:
module.fail_json(msg='boto required for this module')
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module)
name = module.params['name']