Skip to content

Commit

Permalink
Better capture failure cases of aws calls
Browse files Browse the repository at this point in the history
  • Loading branch information
vanreece committed Jun 18, 2021
1 parent fa94989 commit cb88e1c
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions scripts/aws_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import shutil
import subprocess
import sys

"""Script to upload RapiD to S3 bucket
Usage: python3 aws_deploy.py
Expand Down Expand Up @@ -64,30 +65,39 @@ def deploy():
.replace("'iD.legacy.js'", f"'/rapid/{distdir}/iD.legacy.js'")
)
output.write(s)
print("\nCopying new " + distdir + "folder and index file to s3.")
subprocess.run(
print("\nCopying new index file to s3.")
results = subprocess.run(
[
"aws",
"s3",
"cp",
distdir,
f"s3://{os.environ['RAPID_S3_BUCKET_NAME']}/rapid/{distdir}",
"--recursive",
newindex,
f"s3://{os.environ['RAPID_S3_BUCKET_NAME']}/rapid/{identifier}-rapid.html",
],
check=True,
# capture_output=True,
capture_output=True,
)
if results.returncode != 0:
print("Got an error:")
print(f"STDOUT:\n{results.stdout.decode('utf-8')}")
print(f"STDERR:\n{results.stderr.decode('utf-8')}")
sys.exit(-1)
print("\nCopying new " + distdir + "folder and index file to s3.")
subprocess.run(
[
"aws",
"s3",
"cp",
newindex,
f"s3://{os.environ['RAPID_S3_BUCKET_NAME']}/rapid/{identifier}-rapid.html",
distdir,
f"s3://{os.environ['RAPID_S3_BUCKET_NAME']}/rapid/{distdir}",
"--recursive",
],
check=True,
# capture_output=True,
capture_output=True,
)
if results.returncode != 0:
print("Got an error:")
print(f"STDOUT:\n{results.stdout.decode('utf-8')}")
print(f"STDERR:\n{results.stderr.decode('utf-8')}")
sys.exit(-1)

if __name__ == "__main__":
deploy()

0 comments on commit cb88e1c

Please sign in to comment.