Allow AWSRetry class to be created without boto3/botocore installed
This commit is contained in:
parent
4656b6a846
commit
0bda419f66
1 changed files with 11 additions and 1 deletions
|
@ -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):
|
||||||
|
|
Loading…
Reference in a new issue