Skip to content

Commit

Permalink
indicate future refactoring of errors
Browse files Browse the repository at this point in the history
switch from bash to python errors
  • Loading branch information
jlchang committed Oct 6, 2020
1 parent 03633e1 commit 59b1b69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions scripts/manage_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
python manage_study.py --no-user-agent --token=$ACCESS_TOKEN list-studies --summary
EXIT CODES
# TODO: replace with python error handling and logging (SCP-2790)
79 incompatible scp-ingest-pipeline package version detected
80 exit-file-already-exists-in-study-bucket
81 exit-file-not-found-in-study-bucket
Expand Down
7 changes: 7 additions & 0 deletions scripts/scp_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ def check_api_return(self, ret):
print("")
# custom exit code to indicate
# incompatible scp-ingest-pipeline package version detected
# TODO: replace with python error handling and logging (SCP-2790)
exit(79)
api_return[c_CODE_RET_KEY] = ret.status_code
api_return[c_RESPONSE] = ret
Expand Down Expand Up @@ -847,11 +848,13 @@ def upload_via_gsutil(bucket_id, file_path):
f"ERROR: {filename} already exists in study bucket, please delete existing file, then retry."
)
# custom exit code to indicate exit-file-already-exists-in-study-bucket
# TODO: replace with python error handling and logging (SCP-2790)
exit(80)
else:
if source_bucket == bucket_id:
print(f"\nERROR: {filename} not found in study bucket.")
# custom exit code to indicate exit-file-not-found-in-study-bucket
# TODO: replace with python error handling and logging (SCP-2790)
exit(81)
else:
file_from_study_bucket = False
Expand All @@ -865,6 +868,7 @@ def upload_via_gsutil(bucket_id, file_path):
else:
print(f"\nERROR: failed to find upload file {file_path}.")
# custom exit code to indicate exit-file-not-found-in-remote-bucket
# TODO: replace with python error handling and logging (SCP-2790)
exit(85)

# Get GCS details for the file to be used
Expand Down Expand Up @@ -893,6 +897,7 @@ def delete_via_gsutil(bucket_id, file_path):
if not cmdline.func_CMD(command=command, stdout=False):
print(f"ERROR: failed to delete {filename}.")
# custom exit code to indicate exit-failed-to-gsutil-delete-file
# TODO: replace with python error handling and logging (SCP-2790)
exit(82)

def upload_study_file(
Expand Down Expand Up @@ -962,10 +967,12 @@ def upload_study_file(
print("\nCleaning up after failed request:")
self.delete_via_gsutil(bucket_id, file)
# custom exit code to indicate exit-uploaded-file-deleted
# TODO: replace with python error handling and logging (SCP-2790)
exit(83)
else:
print("\nExisting file will persist in study bucket.")
# custom exit code to indicate exit-no-file-cleanup-needed
# TODO: replace with python error handling and logging (SCP-2790)
exit(84)

if parse:
Expand Down

0 comments on commit 59b1b69

Please sign in to comment.