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
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):
base_class = botocore.exceptions.ClientError
base_class = _botocore_exception_maybe()
@staticmethod
def status_code_from_exception(error):