fix a couple of errors that may happen if klipper fails to start or takes too long

This commit is contained in:
alfrix 2022-12-11 19:22:45 -03:00
parent 502d9699bd
commit e4d5cd65ce
2 changed files with 4 additions and 2 deletions

View File

@ -101,6 +101,8 @@ class Printer:
logging.info(f"# Output pins: {self.output_pin_count}") logging.info(f"# Output pins: {self.output_pin_count}")
def process_update(self, data): def process_update(self, data):
if self.data is None:
return
for x in (self.get_tools() + self.get_heaters() + self.get_filament_sensors()): for x in (self.get_tools() + self.get_heaters() + self.get_filament_sensors()):
if x in data: if x in data:
for i in data[x]: for i in data[x]:
@ -316,7 +318,7 @@ class Printer:
return True return True
def init_temp_store(self, tempstore): 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']): if self.tempstore and list(self.tempstore) != list(tempstore['result']):
logging.debug("Tempstore has changed") logging.debug("Tempstore has changed")
self.tempstore = tempstore['result'] self.tempstore = tempstore['result']

View File

@ -242,7 +242,7 @@ class BasePanel(ScreenPanel):
name = f"{name[:1].upper()}: " name = f"{name[:1].upper()}: "
self.labels[device].set_label(f"{name}{int(temp)}°") self.labels[device].set_label(f"{name}{int(temp)}°")
with contextlib.suppress(KeyError): with contextlib.suppress(Exception):
if data["toolhead"]["extruder"] != self.current_extruder: if data["toolhead"]["extruder"] != self.current_extruder:
self.control['temp_box'].remove(self.labels[f"{self.current_extruder}_box"]) self.control['temp_box'].remove(self.labels[f"{self.current_extruder}_box"])
self.current_extruder = data["toolhead"]["extruder"] self.current_extruder = data["toolhead"]["extruder"]