Skip to content

Commit

Permalink
Handle 202 responses from Sondehub better.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Jessop authored and Mark Jessop committed Feb 3, 2024
1 parent 8012154 commit 5f63666
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion horusdemodlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.12"
__version__ = "0.3.13"
24 changes: 24 additions & 0 deletions horusdemodlib/sondehubamateur.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,30 @@ def upload_telemetry(self, telem_list):
_upload_success = True
break

elif _req.status_code == 202:
# A 202 return code means there was some kind of data issue.
# We expect a response of the form {"message": "error message", "errors":[], "warnings":[]}
try:
_resp_json = _req.json()

for _error in _resp_json['errors']:
self.log_error("Payload data error: " + _error["error_message"])
if 'payload' in _error:
self.log_debug("Payload data associated with error: " + str(_error['payload']))

for _warning in _resp_json['warnings']:
self.log_warning("Payload data warning: " + _warning["warning_message"])
if 'payload' in _warning:
self.log_debug("Payload data associated with warning: " + str(_warning['payload']))

except Exception as e:
self.log_error("Error when parsing 202 response: %s" % str(e))
self.log_debug("Content of 202 response: %s" % _req.text)

_upload_success = True
break


elif _req.status_code in [500,501,502,503,504]:
# Server Error, Retry.
_retries += 1
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "horusdemodlib"
version = "0.3.12"
version = "0.3.13"
description = "Project Horus HAB Telemetry Demodulators"
authors = ["Mark Jessop"]
license = "LGPL-2.1-or-later"
Expand Down

0 comments on commit 5f63666

Please sign in to comment.