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:
parent
7dc74f74f4
commit
046e03b883
@ -31,6 +31,7 @@ class KlippyWebsocket(threading.Thread):
|
||||
connected = False
|
||||
callback_table = {}
|
||||
reconnect_timeout = None
|
||||
reconnect_count = 0
|
||||
|
||||
def __init__(self, screen, callback, host, port):
|
||||
threading.Thread.__init__(self)
|
||||
@ -49,6 +50,8 @@ class KlippyWebsocket(threading.Thread):
|
||||
self.connect()
|
||||
|
||||
def connect(self):
|
||||
_ = self._screen.lang.gettext
|
||||
|
||||
def ws_on_close(ws, a=None, b=None):
|
||||
self.on_close(ws)
|
||||
|
||||
@ -63,7 +66,18 @@ class KlippyWebsocket(threading.Thread):
|
||||
|
||||
try:
|
||||
state = self._screen.apiclient.get_server_info()
|
||||
if state is False or state['result']['klippy_connected'] is False:
|
||||
if state is False:
|
||||
if self.reconnect_count > 3:
|
||||
self._screen.printer_initializing(_("Cannot connect to Moonraker") +
|
||||
("\n\n%s\n\n") % self._url +
|
||||
_("Retry #%s") % self.reconnect_count)
|
||||
|
||||
return False
|
||||
if state['result']['klippy_connected'] is False:
|
||||
if self.reconnect_count > 3:
|
||||
self._screen.printer_initializing(_("Moonraker: connected") +
|
||||
("\n\nKlipper: %s\n\n") % state['result']['klippy_state'] +
|
||||
_("Retry #%s") % self.reconnect_count)
|
||||
return False
|
||||
printer_info = self._screen.apiclient.get_printer_info()
|
||||
if printer_info is False:
|
||||
@ -137,6 +151,7 @@ class KlippyWebsocket(threading.Thread):
|
||||
logging.info("Moonraker Websocket Open")
|
||||
logging.info("Self.connected = %s" % self.is_connected())
|
||||
self.connected = True
|
||||
self.reconnect_count = 0
|
||||
if self.reconnect_timeout is not None:
|
||||
GLib.source_remove(self.reconnect_timeout)
|
||||
self.reconnect_timeout = None
|
||||
@ -180,6 +195,7 @@ class KlippyWebsocket(threading.Thread):
|
||||
return False
|
||||
|
||||
logging.debug("Attempting to reconnect")
|
||||
self.reconnect_count += 1
|
||||
self.connect()
|
||||
return True
|
||||
|
||||
|
@ -377,5 +377,8 @@ class Printer:
|
||||
for x in self.tempstore[device]:
|
||||
if len(self.tempstore[device][x]) >= 1200:
|
||||
self.tempstore[device][x].pop(0)
|
||||
self.tempstore[device][x].append(round(self.get_dev_stat(device, x[:-1]), 2))
|
||||
temp = self.get_dev_stat(device, x[:-1])
|
||||
if temp is None:
|
||||
temp = 0
|
||||
self.tempstore[device][x].append(round(temp))
|
||||
return True
|
||||
|
@ -56,7 +56,7 @@ class SplashScreenPanel(ScreenPanel):
|
||||
self.content.add(main)
|
||||
|
||||
def update_text(self, text):
|
||||
self.labels['text'].set_text(text)
|
||||
self.labels['text'].set_markup("%s" % text)
|
||||
self.clear_action_bar()
|
||||
|
||||
def clear_action_bar(self):
|
||||
|
48
screen.py
48
screen.py
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user