Skip to content

Commit

Permalink
initial commit improving logging
Browse files Browse the repository at this point in the history
  • Loading branch information
JackLewis-digirati committed Jan 8, 2024
1 parent 7f8f8f4 commit 1005f98
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions appetiser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import subprocess

from app.json_utils import (
extract_process_kwargs,
extract_response_items,
Expand Down Expand Up @@ -50,14 +52,34 @@ def ping():
def convert():
json_data = flask.request.get_json()
appetiser.logger.info('Processing request data: %s', json_data)
result = process(**extract_process_kwargs(json_data))
proto_reponse = {
**result,
**extract_response_items(json_data)
}
response = add_iiif_info_json(proto_reponse)
appetiser.logger.info('Response: %s', json_data)
return flask.jsonify(response)
try:
result = process(**extract_process_kwargs(json_data))
proto_reponse = {
**result,
**extract_response_items(json_data)
}
response = add_iiif_info_json(proto_reponse)
appetiser.logger.info('Response: %s', json_data)
return flask.jsonify(response)
except FileNotFoundError as fileError:
appetiser.logger.exception('Error: %s', fileError)
return flask.jsonify(
status='file not found',
message=str(fileError)
), 400
except subprocess.CalledProcessError as subprocess_error:
appetiser.logger.exception('Error: %s', subprocess_error.stderr)
return flask.jsonify(
status='kakadu error',
message=str(subprocess_error.stderr)
), 500
except Exception as general_error:
appetiser.logger.exception('Error: %s', general_error)

return flask.jsonify(
status='server error',
message=str(general_error)
), 500


if __name__ == '__main__':
Expand Down

0 comments on commit 1005f98

Please sign in to comment.