From 5619a77d6e847fff428d06ba0ff05c84f926199f Mon Sep 17 00:00:00 2001 From: Alfredo Monclus Date: Wed, 29 May 2024 22:26:38 -0300 Subject: [PATCH] changes to make ks start and give the no support error in python 3.7 --- ks_includes/config.py | 3 ++- ks_includes/functions.py | 6 ++++-- screen.py | 9 ++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ks_includes/config.py b/ks_includes/config.py index 2b3596e3..d509bb69 100644 --- a/ks_includes/config.py +++ b/ks_includes/config.py @@ -456,7 +456,8 @@ class KlipperScreenConfig: directories = [printer_data_config, xdg_config, klipperscreendir] for directory in directories: - if path := self.check_path_exists(directory, self.configfile_name): + path = self.check_path_exists(directory, self.configfile_name) + if path: return path # fallback diff --git a/ks_includes/functions.py b/ks_includes/functions.py index b0075c22..e3a8dba8 100644 --- a/ks_includes/functions.py +++ b/ks_includes/functions.py @@ -40,7 +40,8 @@ try: onoff_p = ctypes.create_string_buffer(1) state_p = ctypes.create_string_buffer(2) if libXext.DPMSInfo(display, state_p, onoff_p): - if onoff := struct.unpack('B', onoff_p.raw)[0]: + onoff = struct.unpack('B', onoff_p.raw)[0] + if onoff: state = struct.unpack('H', state_p.raw)[0] libXext.XCloseDisplay(display) return state @@ -72,7 +73,8 @@ def get_wireless_interfaces(): return None interfaces = [] for line in result: - if match := re.search('^(\\S+)\\s+.*$', line): + match = re.search('^(\\S+)\\s+.*$', line) + if match: interfaces.append(match[1]) return interfaces diff --git a/screen.py b/screen.py index 60aa0ea4..4dc7253a 100755 --- a/screen.py +++ b/screen.py @@ -885,7 +885,8 @@ class KlipperScreen(Gtk.Window): if self.connected_printer is None or not devices: return found_devices devices = [str(i.strip()) for i in devices.split(',')] - if power_devices := self.printer.get_power_devices(): + power_devices = self.printer.get_power_devices() + if power_devices: found_devices = [dev for dev in devices if dev in power_devices] logging.info(f"Found {found_devices}", ) return found_devices @@ -1040,7 +1041,8 @@ class KlipperScreen(Gtk.Window): def init_tempstore(self): if len(self.printer.get_temp_devices()) == 0: return - if tempstore := self.apiclient.send_request("server/temperature_store"): + tempstore = self.apiclient.send_request("server/temperature_store") + if tempstore: self.printer.init_temp_store(tempstore) if hasattr(self.panels[self._cur_panels[-1]], "update_graph_visibility"): self.panels[self._cur_panels[-1]].update_graph_visibility() @@ -1051,7 +1053,8 @@ class KlipperScreen(Gtk.Window): if set(self.printer.tempstore) != set(self.printer.get_temp_devices()): GLib.timeout_add_seconds(5, self.init_tempstore) return - if server_config := self.apiclient.send_request("server/config"): + server_config = self.apiclient.send_request("server/config") + if server_config: try: self.printer.tempstore_size = server_config["config"]["data_store"]["temperature_store_size"] logging.info(f"Temperature store size: {self.printer.tempstore_size}")