From e4d5cd65cef0ab31625d6874c0441b792d6731f2 Mon Sep 17 00:00:00 2001 From: alfrix Date: Sun, 11 Dec 2022 19:22:45 -0300 Subject: [PATCH] fix a couple of errors that may happen if klipper fails to start or takes too long --- ks_includes/printer.py | 4 +++- panels/base_panel.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ks_includes/printer.py b/ks_includes/printer.py index be7b6bbe..f8981ed4 100644 --- a/ks_includes/printer.py +++ b/ks_includes/printer.py @@ -101,6 +101,8 @@ class Printer: logging.info(f"# Output pins: {self.output_pin_count}") def process_update(self, data): + if self.data is None: + return for x in (self.get_tools() + self.get_heaters() + self.get_filament_sensors()): if x in data: for i in data[x]: @@ -316,7 +318,7 @@ class Printer: return True def init_temp_store(self, tempstore): - if 'result' in tempstore: + if tempstore and 'result' in tempstore: if self.tempstore and list(self.tempstore) != list(tempstore['result']): logging.debug("Tempstore has changed") self.tempstore = tempstore['result'] diff --git a/panels/base_panel.py b/panels/base_panel.py index 1bae646d..01564aaf 100644 --- a/panels/base_panel.py +++ b/panels/base_panel.py @@ -242,7 +242,7 @@ class BasePanel(ScreenPanel): name = f"{name[:1].upper()}: " self.labels[device].set_label(f"{name}{int(temp)}°") - with contextlib.suppress(KeyError): + with contextlib.suppress(Exception): if data["toolhead"]["extruder"] != self.current_extruder: self.control['temp_box'].remove(self.labels[f"{self.current_extruder}_box"]) self.current_extruder = data["toolhead"]["extruder"]