From 60886ef3cb0e1caef3404910cada56f46e7d97c7 Mon Sep 17 00:00:00 2001 From: Simon Briere Date: Wed, 24 Apr 2024 14:32:54 -0400 Subject: [PATCH] Fixed some data decoding issues and OpenTera transfers. --- Globals.py | 2 +- libs/servers/WatchServerOpenTera.py | 6 +++++- libs/servers/handlers/BaseAppleWatchRequestHandler.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Globals.py b/Globals.py index 9c0cf65..f110579 100644 --- a/Globals.py +++ b/Globals.py @@ -2,4 +2,4 @@ config_man = ConfigManager() -version_string = '1.2.0' +version_string = '1.2.1' diff --git a/libs/servers/WatchServerOpenTera.py b/libs/servers/WatchServerOpenTera.py index 3f00b1b..88473ce 100644 --- a/libs/servers/WatchServerOpenTera.py +++ b/libs/servers/WatchServerOpenTera.py @@ -237,7 +237,11 @@ def initiate_opentera_transfer(self, device_name: str): # Create session events session_events = self.watch_logs_to_events(logs_data) - for event in session_events: + for index, event in enumerate(session_events): + if index >= 100: + logging.warning('OpenTera: More than 100 session events for session ' + session_name + + ' - ignoring the rest...') + break event['id_session'] = id_session event['id_session_event'] = 0 response = device_com.do_post(DeviceAPI.ENDPOINT_DEVICE_SESSION_EVENTS, {'session_event': event}) diff --git a/libs/servers/handlers/BaseAppleWatchRequestHandler.py b/libs/servers/handlers/BaseAppleWatchRequestHandler.py index d123558..05e8846 100644 --- a/libs/servers/handlers/BaseAppleWatchRequestHandler.py +++ b/libs/servers/handlers/BaseAppleWatchRequestHandler.py @@ -111,7 +111,7 @@ def do_POST(self): return if text_format: - fh.write(data.decode()) + fh.write(data.decode(errors="ignore")) # Ignore unknown characters and errors else: fh.write(data) content_size_remaining -= buffer_size