Skip to content

Commit f69bc7b

Browse files
Add basic exception handling around the S3 request
1 parent 39b1fe1 commit f69bc7b

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

circuitpython_build_tools/build.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,17 @@ def mpy_cross(mpy_cross_filename, circuitpython_tag, quiet=False):
8383

8484
if s3_url is not None:
8585
print(f"Checking S3 for {s3_url}")
86-
r = requests.get(s3_url)
87-
if r.status_code == 200:
88-
with open(mpy_cross_filename, "wb") as f:
89-
f.write(r.content)
90-
# Set the User Execute bit
91-
os.chmod(mpy_cross_filename, os.stat(mpy_cross_filename)[0] | stat.S_IXUSR)
92-
print(" FOUND")
93-
return
86+
try:
87+
r = requests.get(s3_url)
88+
if r.status_code == 200:
89+
with open(mpy_cross_filename, "wb") as f:
90+
f.write(r.content)
91+
# Set the User Execute bit
92+
os.chmod(mpy_cross_filename, os.stat(mpy_cross_filename)[0] | stat.S_IXUSR)
93+
print(" FOUND")
94+
return
95+
except Exception as e:
96+
print(f" exception fetching from S3: {e}")
9497
print(" NOT FOUND")
9598

9699
if not quiet:

0 commit comments

Comments
 (0)