Skip to content

Commit

Permalink
[IIIF-1069] Handle nginx error pages (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark A. Matney, Jr authored Jan 14, 2021
1 parent 457effc commit e96122b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions festerize.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,16 @@ def cli(
out_file = click.open_file(os.path.join(out, csv_filename), "wb")
out_file.write(r.content)
else:
error_cause = (
BeautifulSoup(r.text, features="html.parser")
.find(id="error-message")
.string
)
error_page_soup = BeautifulSoup(r.text, features="html.parser")
try:
# Fester error page via Vert.x
error_cause = error_page_soup.find(id="error-message").string
except AttributeError:
# nginx error page with response status code and message in title
error_cause = "{} - {}".format(
error_page_soup.title.string, "nginx"
)

error_msg = "Failed to upload {}: {} (HTTP {})".format(
csv_filename, error_cause, r.status_code
)
Expand Down

0 comments on commit e96122b

Please sign in to comment.