Skip to content

Commit

Permalink
add exception handling to ckan upload script (#3227)
Browse files Browse the repository at this point in the history
* add exception handling to ckan upload script

* substitute continue for pass in loop

* push changes resulting from Soren's review
  • Loading branch information
charlie-costanzo authored Jan 11, 2024
1 parent c4f572f commit fde6d52
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions warehouse/scripts/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,14 +477,21 @@ def _publish_exposure(

if publish:
typer.secho(publish_msg, fg=typer.colors.GREEN)
with open(fpath, "rb") as fp:
upload_to_ckan(
url=destination.url,
fname=fname,
fsize=fsize,
file=fp,
resource_id=resource.id,
try:
with open(fpath, "rb") as fp:
upload_to_ckan(
url=destination.url,
fname=fname,
fsize=fsize,
file=fp,
resource_id=resource.id,
)
except requests.exceptions.HTTPError as e:
typer.secho(
f"Failed to upload to {fpath} due to error: {e}",
fg=typer.colors.RED,
)

else:
typer.secho(
f"would be {publish_msg} if --publish",
Expand Down

0 comments on commit fde6d52

Please sign in to comment.