1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Allow AWSRetry class to be created without boto3/botocore installed

This commit is contained in:
Ryan S. Brown 2016-09-14 11:33:29 -04:00
parent 4656b6a846
commit 0bda419f66

View file

@ -58,8 +58,18 @@ class AnsibleAWSError(Exception):
pass pass
def _botocore_exception_maybe():
"""
Allow for boto3 not being installed when using these utils by wrapping
botocore.exceptions instead of assigning from it directly.
"""
if HAS_BOTO3:
return botocore.exceptions.ClientError
return type(None)
class AWSRetry(CloudRetry): class AWSRetry(CloudRetry):
base_class = botocore.exceptions.ClientError base_class = _botocore_exception_maybe()
@staticmethod @staticmethod
def status_code_from_exception(error): def status_code_from_exception(error):