Handle 202 responses from Sondehub better.

pull/217/head v0.3.13
Mark Jessop 2024-02-03 15:56:02 +10:30
rodzic 80121545f3
commit 5f63666f5f
3 zmienionych plików z 26 dodań i 2 usunięć

Wyświetl plik

@ -1 +1 @@
__version__ = "0.3.12" __version__ = "0.3.13"

Wyświetl plik

@ -344,6 +344,30 @@ class SondehubAmateurUploader(object):
_upload_success = True _upload_success = True
break 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]: elif _req.status_code in [500,501,502,503,504]:
# Server Error, Retry. # Server Error, Retry.
_retries += 1 _retries += 1

Wyświetl plik

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "horusdemodlib" name = "horusdemodlib"
version = "0.3.12" version = "0.3.13"
description = "Project Horus HAB Telemetry Demodulators" description = "Project Horus HAB Telemetry Demodulators"
authors = ["Mark Jessop"] authors = ["Mark Jessop"]
license = "LGPL-2.1-or-later" license = "LGPL-2.1-or-later"