boto3-assist 0.9.3__py3-none-any.whl → 0.9.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,3 +32,15 @@ class InvalidRoutePath(Exception):
32
32
  "message": message,
33
33
  }
34
34
  super().__init__(self.message)
35
+
36
+
37
+ class FileNotFound(Exception):
38
+ """File Not Found Error"""
39
+
40
+ def __init__(self, message="File Not Found"):
41
+ """Invalid Route"""
42
+ self.message = {
43
+ "status_code": 404,
44
+ "message": message,
45
+ }
46
+ super().__init__(self.message)
@@ -18,7 +18,7 @@ from boto3_assist.s3.s3_connection import S3Connection
18
18
  from boto3_assist.utilities.datetime_utility import DatetimeUtility
19
19
  from boto3_assist.utilities.file_operations import FileOperations
20
20
  from boto3_assist.utilities.http_utility import HttpUtility
21
-
21
+ from boto3_assist.errors.custom_exceptions import FileNotFound
22
22
 
23
23
  logger = Logger(child=True)
24
24
 
@@ -462,15 +462,28 @@ class S3Object:
462
462
 
463
463
  except Exception as e: # pylint: disable=W0718
464
464
  error = str(e)
465
- logger.error({"metric_filter": "s3_download_error", "error": str(e)})
466
- raise RuntimeError(
467
- {
468
- "metric_filter": "s3_download_error",
469
- "error": str(e),
470
- "bucket": bucket_name,
471
- "key": key,
472
- }
473
- ) from e
465
+ error_info = {
466
+ "metric_filter": "s3_download_error",
467
+ "error": str(e),
468
+ "bucket": bucket_name,
469
+ "key": key,
470
+ }
471
+
472
+ logger.error(error_info)
473
+ # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3/client/get_object.html
474
+ error = str(e)
475
+ if "An error occurred (AccessDenied)" in error:
476
+ if (
477
+ "is not authorized to perform: s3:ListBucket on resource" in error
478
+ and "because no identity-based policy allows the s3:ListBucket action"
479
+ in error
480
+ ):
481
+ # the file is not found but you're getting a access error since you don't
482
+ # have s3:ListBucket. To make life easier, we're just going to return a 404 error
483
+ raise FileNotFound("File Not Found") from e
484
+
485
+ # last ditch
486
+ raise RuntimeError(error_info) from e
474
487
 
475
488
  finally:
476
489
  logger.debug(
boto3_assist/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = '0.9.3'
1
+ __version__ = '0.9.4'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: boto3_assist
3
- Version: 0.9.3
3
+ Version: 0.9.4
4
4
  Summary: Additional boto3 wrappers to make your life a little easier
5
5
  Author-email: Eric Wilson <boto3-assist@geekcafe.com>
6
6
  License-File: LICENSE-EXPLAINED.txt
@@ -3,7 +3,7 @@ boto3_assist/boto3session.py,sha256=Q9sByNC0r_aMQfHnIEnxtTaiCMUqikm8UeSTxV7-Np0,
3
3
  boto3_assist/connection.py,sha256=-z_OZtZmSVjSSECpoqx1FnqW7B9A_LovfN_cJ_nhHgg,4361
4
4
  boto3_assist/connection_tracker.py,sha256=UgfR9RlvXf3A4ssMr3gDMpw89ka8mSRvJn4M34SzhbU,4378
5
5
  boto3_assist/http_status_codes.py,sha256=G0zRSWenwavYKETvDF9tNVUXQz3Ae2gXdBETYbjvJe8,3284
6
- boto3_assist/version.py,sha256=83oJ8nCWXwQbno1uqIRolJfmli7BtUNqtuSvnzeSyxg,22
6
+ boto3_assist/version.py,sha256=PrvpsFpxFfV-9CkerqH8w9aj7jp44ZzlQ22FXf5IOIk,22
7
7
  boto3_assist/aws_lambda/event_info.py,sha256=OkZ4WzuGaHEu_T8sB188KBgShAJhZpWASALKRGBOhMg,14648
8
8
  boto3_assist/aws_lambda/mock_context.py,sha256=kLLwt46a2ZrGF8jEmBWDFrH9sFavZSrB4k7EZZK2hs8,105
9
9
  boto3_assist/cloudwatch/cloudwatch_connection.py,sha256=mnGWaLSQpHh5EeY7Ek_2o9JKHJxOELIYtQVMX1IaHn4,2480
@@ -34,13 +34,13 @@ boto3_assist/ec2/ec2_connection.py,sha256=IrtaidH6_SF5l3OeNehRsTlC-sX7EURVqcO-U6
34
34
  boto3_assist/environment_services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
35
  boto3_assist/environment_services/environment_loader.py,sha256=1uVLqSPQriUWazGXpxPJBLveGL8rLZaT5ZsciqqjVek,3979
36
36
  boto3_assist/environment_services/environment_variables.py,sha256=4ccBKdPt6O7hcRT3zBHd8vqu8yQU8udmoD5RLAT3iMs,6801
37
- boto3_assist/errors/custom_exceptions.py,sha256=zC2V2Y4PUtKj3uLPn8mB-JessksKWJWvKM9kp1dmvt8,760
37
+ boto3_assist/errors/custom_exceptions.py,sha256=QAMW49NbClELVnRd00u4NHfzVtRS3Tc1TrsIMUP9wLw,1041
38
38
  boto3_assist/models/serializable_model.py,sha256=ZMrRJRvJWLY8PBSKK_nPCgYKv1qUxDPEVdcADKbIHsI,266
39
39
  boto3_assist/s3/s3.py,sha256=ESTPXtyDi8mrwHaYNWjQLNGTuTUV4CxKDqw-O_KGzKs,2052
40
40
  boto3_assist/s3/s3_bucket.py,sha256=GfyBbuI5BWz_ybwU_nDqUZiC0wt24PNt49GKZmb05OY,2018
41
41
  boto3_assist/s3/s3_connection.py,sha256=0JgEDNoDFPQTo5hQe-lS8mWnFBJ2S8MDSl0LPG__lZo,2008
42
42
  boto3_assist/s3/s3_event_data.py,sha256=vwty34zDgTeSLNCLAWVxvhSQKT7hIpM7fZrWm5w6znM,4063
43
- boto3_assist/s3/s3_object.py,sha256=iPcdTByhVJJCadfoS2S6o-aTexULIWvaD7hYo5aHjNs,21976
43
+ boto3_assist/s3/s3_object.py,sha256=2O9AYLQ6sfkkTE4_LzHBTyfz2CSKg6a9umBc71pj6vQ,22716
44
44
  boto3_assist/securityhub/securityhub.py,sha256=nGmHd_R3awDeB_QRzPfNAtQauLdVA1hlRlkaZA4oZjg,5409
45
45
  boto3_assist/securityhub/securityhub_connection.py,sha256=hWfcj9gjS2lNXUObyw4cShtveoqJPIp8kKFuz-fz1J4,1449
46
46
  boto3_assist/utilities/datetime_utility.py,sha256=dgAMB9VqakrYIPXlSoVQiLSsc_yhrJK4gMfJO9mX90w,11112
@@ -51,8 +51,8 @@ boto3_assist/utilities/logging_utility.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
51
51
  boto3_assist/utilities/numbers_utility.py,sha256=EjCnQhSbD5TRnuReKBD_GQyynp7Wit5M2bSfOfQGJBU,10051
52
52
  boto3_assist/utilities/serialization_utility.py,sha256=oS-tVGfP0fPq6FD5RE09DuNUB6tqR76QmthJTDERJRE,17203
53
53
  boto3_assist/utilities/string_utility.py,sha256=5BpDaqGZI8cSM-3YFQLU1fKcWcqG9r1_GPgDstCWFIs,10318
54
- boto3_assist-0.9.3.dist-info/METADATA,sha256=i9GglORO_pF5m48S9MznyLtqyk6w9WFPT65FlPYDUN8,1728
55
- boto3_assist-0.9.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
56
- boto3_assist-0.9.3.dist-info/licenses/LICENSE-EXPLAINED.txt,sha256=WFREvTpfTjPjDHpOLADxJpCKpIla3Ht87RUUGii4ODU,606
57
- boto3_assist-0.9.3.dist-info/licenses/LICENSE.txt,sha256=PXDhFWS5L5aOTkVhNvoitHKbAkgxqMI2uUPQyrnXGiI,1105
58
- boto3_assist-0.9.3.dist-info/RECORD,,
54
+ boto3_assist-0.9.4.dist-info/METADATA,sha256=30NkYeb-PZlihZ_LxQ1Ho3cZDoC2jbllHjho4Cud-gA,1728
55
+ boto3_assist-0.9.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
56
+ boto3_assist-0.9.4.dist-info/licenses/LICENSE-EXPLAINED.txt,sha256=WFREvTpfTjPjDHpOLADxJpCKpIla3Ht87RUUGii4ODU,606
57
+ boto3_assist-0.9.4.dist-info/licenses/LICENSE.txt,sha256=PXDhFWS5L5aOTkVhNvoitHKbAkgxqMI2uUPQyrnXGiI,1105
58
+ boto3_assist-0.9.4.dist-info/RECORD,,