mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-13 03:44:02 -07:00
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:
parent
0a48d54c1c
commit
67f769d9a6
21 changed files with 121 additions and 74 deletions
|
@ -107,20 +107,19 @@ EXAMPLES = '''
|
|||
- s3: bucket=mybucket mode=delete
|
||||
'''
|
||||
|
||||
import sys
|
||||
import os
|
||||
import urlparse
|
||||
import hashlib
|
||||
|
||||
from boto.s3.connection import OrdinaryCallingFormat
|
||||
|
||||
try:
|
||||
import boto
|
||||
from boto.s3.connection import Location
|
||||
from boto.s3.connection import OrdinaryCallingFormat
|
||||
from boto.s3.connection import S3Connection
|
||||
HAS_BOTO = True
|
||||
except ImportError:
|
||||
print "failed=True msg='boto required for this module'"
|
||||
sys.exit(1)
|
||||
HAS_BOTO = False
|
||||
|
||||
|
||||
def key_check(module, s3, bucket, obj):
|
||||
try:
|
||||
|
@ -278,6 +277,9 @@ def main():
|
|||
)
|
||||
module = AnsibleModule(argument_spec=argument_spec)
|
||||
|
||||
if not HAS_BOTO:
|
||||
module.fail_json(msg='boto required for this module')
|
||||
|
||||
bucket = module.params.get('bucket')
|
||||
obj = module.params.get('object')
|
||||
src = module.params.get('src')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue