From b93fd08b6fa0701971e6eb9e96e74e34154c5701 Mon Sep 17 00:00:00 2001 From: alfrix Date: Thu, 28 Mar 2024 12:48:05 -0300 Subject: [PATCH] base_panel: resource warning changes make the notification contain the name of the printer use avg cpu instead of individual core to be less intrusive, also because moonraker seems to report higher core usage than htop, which is strange --- panels/base_panel.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/panels/base_panel.py b/panels/base_panel.py index 84d06742..0830adb3 100644 --- a/panels/base_panel.py +++ b/panels/base_panel.py @@ -209,7 +209,7 @@ class BasePanel(ScreenPanel): def process_update(self, action, data): if action == "notify_proc_stat_update": - cpu = (max(data["system_cpu_usage"][core] for core in data["system_cpu_usage"] if core.startswith("cpu"))) + cpu = data["system_cpu_usage"]["cpu"] memory = (data["system_memory"]["used"] / data["system_memory"]["total"]) * 100 error = "message_popup_error" ctx = self.titlebar.get_style_context() @@ -221,11 +221,11 @@ class BasePanel(ScreenPanel): self.last_usage_report = datetime.now() if not ctx.has_class(error): ctx.add_class(error) - self._screen.log_notification(msg, 3) + self._screen.log_notification(f"{self._screen.connecting_to_printer}: {msg}", 2) self.titlelbl.set_label(msg) elif ctx.has_class(error): - self.titlelbl.set_label(msg) if (datetime.now() - self.last_usage_report).seconds < 5: + self.titlelbl.set_label(msg) return self.usage_report = 0 ctx.remove_class(error)