Skip to content

Commit

Permalink
feat(api): respond w/ task.status
Browse files Browse the repository at this point in the history
instead of custom
  • Loading branch information
matthiasschaub committed Oct 12, 2023
1 parent 4295a21 commit 5796c06
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions sketch_map_tool/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,32 +164,27 @@ def status(uuid: str, type_: REQUEST_TYPES) -> Response:
if task.ready():
if task.successful(): # SUCCESS
http_status = 200
status = "SUCCESSFUL"
href = "/api/download/" + uuid + "/" + type_
elif task.failed(): # REJECTED, REVOKED, FAILURE
try:
task.get(propagate=True)
except MapGenerationError as err:
http_status = 408 # Request Timeout
status = "FAILED"
error = str(err)
except (QRCodeError, OQTReportError) as err:
# The request was well-formed but was unable to be followed due
# to semantic errors.
http_status = 422 # Unprocessable Entity
status = "FAILED"
error = str(err)
except (Exception) as err:
http_status = 500 # Internal Server Error
status = "FAILED"
error = str(err)
else: # PENDING, RETRY, RECEIVED, STARTED
else: # PENDING, RETRY, STARTED
# Accepted for processing, but has not been completed
http_status = 202 # Accepted
status = "PROCESSING"
body_raw = {
"id": uuid,
"status": status,
"status": task.status,
"type": type_,
"href": href,
"error": error,
Expand Down

0 comments on commit 5796c06

Please sign in to comment.