From 4611aab2f2f2299481ea4e3b1610f114ff48e4a0 Mon Sep 17 00:00:00 2001 From: Quentin WEPHRE Date: Thu, 9 Oct 2025 17:59:54 +0200 Subject: [PATCH] Fix bug reading IoT Edge module properties --- .../azure_iot_hub_manage_iot_edge_devices.py | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Python/azure_iot_hub_manage_iot_edge_devices.py b/Python/azure_iot_hub_manage_iot_edge_devices.py index 797d5f2..0e414ce 100644 --- a/Python/azure_iot_hub_manage_iot_edge_devices.py +++ b/Python/azure_iot_hub_manage_iot_edge_devices.py @@ -49,9 +49,23 @@ class ModuleScreen(Screen): table = self.query_one(DataTable) table.add_columns("Module", "Status", "Since", "Last activity") for module in self.device_modules: - local_connection_time = datetime.fromisoformat(str(module.connection_state_updated_time)).astimezone().replace(microsecond=0).isoformat() - local_activity_time = datetime.fromisoformat(str(module.last_activity_time)).astimezone().replace(microsecond=0).isoformat() - table.add_row(f"{module.module_id}", f"{module.connection_state}", f"{local_connection_time}", f"{local_activity_time}") + try: + local_connection_time = datetime.fromisoformat(str(module.connection_state_updated_time)).astimezone().replace(microsecond=0).isoformat() + except: + local_connection_time = datetime.min.isoformat() + try: + local_activity_time = datetime.fromisoformat(str(module.last_activity_time)).astimezone().replace(microsecond=0).isoformat() + except: + local_activity_time = datetime.min.isoformat() + try: + module_id = module.module_id + except: + module_id = "NA" + try: + connection_state = module.connection_state + except: + connection_state = "NA" + table.add_row(f"{module_id}", f"{connection_state}", f"{local_connection_time}", f"{local_activity_time}") ## NEW: The Screen for showing device details and actions