- support offline mode

This commit is contained in:
2023-08-22 08:50:48 +03:00
parent 9d2ba8c998
commit 937bafb493
4 changed files with 19 additions and 11 deletions

View File

@@ -66,12 +66,12 @@ class QualtestBackend:
self.__phone = self.load_phone(cache)
def upload_report(self, report, cache: InfoCache) -> (str, bool):
def upload_report(self, report: dict, cache: InfoCache) -> (str, bool):
# UUID string as result
result = (None, False)
# Log about upload attempt
utils.log_verbose(f"Uploading to {self.address} report: {json.dumps(report, indent=4)}")
utils.log_verbose(f'Uploading to {self.address} report with audio duration: {report["duration"]}s, AQuA MOS: {round(report["mos_aqua"], 3)}')
url = utils.join_host_and_path(self.address, "/probes/")
try:
@@ -82,7 +82,7 @@ class QualtestBackend:
result = (r.content.decode().strip(), True)
except Exception as e:
utils.log_error(f"Upload report to {self.address} finished with error.", err=e)
utils.log_error(f'Upload report to {self.address} finished with error: {str(e)}')
# Backup probe result
if cache is not None:
probe_id = cache.add_report(report)