printer_initializing: refactor message generation and remove markup

markup caused issues with status messages
This commit is contained in:
alfrix 2022-11-21 09:18:36 -03:00
parent 818f1ab465
commit 7b7c3838fc
2 changed files with 10 additions and 17 deletions

View File

@ -62,8 +62,7 @@ class KlippyWebsocket(threading.Thread):
if state is False:
if self.reconnect_count > 2:
self._screen.printer_initializing(
_("Cannot connect to Moonraker")
+ f'\n\n{self._url}\n\n'
_("Cannot connect to Moonraker") + '\n\n'
+ _("Retrying") + f' #{self.reconnect_count}'
)
return False
@ -159,7 +158,7 @@ class KlippyWebsocket(threading.Thread):
self.connecting = False
self._screen.printer_initializing(
_("Cannot connect to Moonraker")
+ f'\n\n{self._url}\n\n{self._screen.apiclient.status}')
+ f'\n\n{self._screen.apiclient.status}')
return False
logging.debug("Attempting to reconnect")
self.connect()

View File

@ -659,18 +659,13 @@ class KlipperScreen(Gtk.Window):
def state_error(self):
self.close_screensaver()
msg = self.printer.get_stat("webhooks", "state_message")
if "FIRMWARE_RESTART" in msg:
self.printer_initializing("<b>" + _("Klipper has encountered an error.") + "\n" +
_("A FIRMWARE_RESTART may fix the issue.") +
"</b>" + "\n\n" + msg)
elif "micro-controller" in msg:
self.printer_initializing("<b>" + _("Klipper has encountered an error.") +
_("Please recompile and flash the micro-controller.") +
"</b>" + "\n\n" + msg)
else:
self.printer_initializing("<b>" + _("Klipper has encountered an error.") +
"</b>" + "\n\n" + msg)
msg = _("Klipper has encountered an error.") + "\n"
state = self.printer.get_stat("webhooks", "state_message")
if "FIRMWARE_RESTART" in state:
msg += _("A FIRMWARE_RESTART may fix the issue.") + "\n"
elif "micro-controller" in state:
msg += _("Please recompile and flash the micro-controller.") + "\n"
self.printer_initializing(msg + "\n" + state)
def state_paused(self):
if "job_status" not in self._cur_panels:
@ -695,8 +690,7 @@ class KlipperScreen(Gtk.Window):
self.close_screensaver()
msg = self.printer.get_stat("webhooks", "state_message")
msg = msg if "ready" not in msg else ""
self.printer_initializing("<b>" + _("Klipper has shutdown") +
"</b>" + "\n\n" + msg)
self.printer_initializing(_("Klipper has shutdown") + "\n\n" + msg)
def toggle_macro_shortcut(self, value):
self.base_panel.show_macro_shortcut(value)