Improve error messages (#549)

Shows if the issue is with moonraker or klipper
if the issue is with klipper and there is info about it then show it
Reconnect now has a counter and it's visible to the user
This commit is contained in:
Alfredo Monclus
2022-03-18 20:18:53 -03:00
committed by GitHub
parent 7dc74f74f4
commit 046e03b883
4 changed files with 49 additions and 24 deletions

View File

@@ -132,7 +132,6 @@ class KlipperScreen(Gtk.Window):
self.add(self.base_panel.get())
self.show_all()
self.base_panel.activate()
self.touch_ready = True
self.printer_initializing(_("Initializing"))
@@ -141,7 +140,9 @@ class KlipperScreen(Gtk.Window):
# Move mouse to 0,0
os.system("/usr/bin/xdotool mousemove 0 0")
self.change_cursor()
self.initial_connection()
def initial_connection(self):
printers = self._config.get_printers()
default_printer = self._config.get_main_config().get('default_printer')
logging.debug("Default printer: %s" % default_printer)
@@ -159,6 +160,7 @@ class KlipperScreen(Gtk.Window):
def connect_printer(self, name):
_ = self.lang.gettext
self.connecting_to_printer = name
if self.connected_printer == name:
if self.printer_select_prepanel is not None:
self.show_panel(self.printer_select_prepanel, "", "", 2)
@@ -208,11 +210,10 @@ class KlipperScreen(Gtk.Window):
}, self.state_execute)
self._remove_all_panels()
panels = list(self.panels)
if len(self.subscriptions) > 0:
self.subscriptions = []
for panel in panels:
del self.panels[panel]
self.subscriptions = []
for panel in list(self.panels):
if panel not in ["printer_select", "splash_screen"]:
del self.panels[panel]
self.base_panel.show_printer_select(True)
self.printer_initializing(_("Connecting to %s") % name)
@@ -698,10 +699,14 @@ class KlipperScreen(Gtk.Window):
_ = self.lang.gettext
logging.debug("### Going to disconnected")
self.base_panel.show_macro_shortcut(False)
self.wake_screen()
self.printer_initializing(_("Klipper has disconnected"))
for panel in list(self.panels):
if panel not in ["printer_select", "splash_screen"]:
del self.panels[panel]
if self.connected_printer is not None:
self.connected_printer = None
# Try to reconnect
self.connect_printer(self.connecting_to_printer)
else:
self.initial_connection()
def state_error(self, prev_state):
if "printer_select" in self._cur_panels:
@@ -710,21 +715,19 @@ class KlipperScreen(Gtk.Window):
_ = self.lang.gettext
self.base_panel.show_macro_shortcut(False)
self.wake_screen()
msg = self.printer.get_stat("webhooks", "state_message")
if "FIRMWARE_RESTART" in msg:
self.printer_initializing(
_("Klipper has encountered an error.\nIssue a FIRMWARE_RESTART to attempt fixing the issue.")
+ "\n\n" + 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(
_("Klipper has encountered an error with the micro-controller.\nPlease recompile and flash.")
+ "\n\n" + 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(
_("Klipper has encountered an error.") + "\n\n" + msg
)
self.printer_initializing("<b>" + _("Klipper has encountered an error.") +
"</b>" + "\n\n" + msg)
for panel in list(self.panels):
if panel not in ["printer_select", "splash_screen"]:
@@ -776,7 +779,10 @@ class KlipperScreen(Gtk.Window):
_ = self.lang.gettext
self.base_panel.show_macro_shortcut(False)
self.printer_initializing(_("Klipper has shutdown"))
self.wake_screen()
msg = self.printer.get_stat("webhooks", "state_message")
self.printer_initializing("<b>" + _("Klipper has shutdown") +
"</b>" + "\n\n" + msg)
def toggle_macro_shortcut(self, value):
if value is True: