diff --git a/ks_includes/KlippyWebsocket.py b/ks_includes/KlippyWebsocket.py index 0b0f6080..654d7d29 100644 --- a/ks_includes/KlippyWebsocket.py +++ b/ks_includes/KlippyWebsocket.py @@ -64,6 +64,12 @@ class KlippyWebsocket(threading.Thread): self.on_open(ws) try: + state = self._screen.apiclient.get_server_info() + if state is False or state['result']['klippy_connected'] is False: + return False + printer_info = self._screen.apiclient.get_printer_info() + if printer_info is False: + return False token = self._screen.apiclient.get_oneshot_token() except Exception: logging.debug("Unable to get oneshot token") @@ -160,7 +166,8 @@ class KlippyWebsocket(threading.Thread): Gdk.threads_add_idle( GLib.PRIORITY_HIGH_IDLE, self._callback['on_close'], - "Lost Connection to Moonraker" + "Lost Connection to Moonraker", + True ) def reconnect(self): diff --git a/screen.py b/screen.py index e83b983f..8209562f 100644 --- a/screen.py +++ b/screen.py @@ -774,10 +774,12 @@ class KlipperScreen(Gtk.Window): def _send_action(self, widget, method, params): self._ws.send_method(method, params) - def printer_initializing(self, text=None): + def printer_initializing(self, text=None, disconnect=False): self.shutdown = True self.close_popup_message() self.show_panel('splash_screen', "splash_screen", "Splash Screen", 2) + if disconnect is True and self.printer is not None: + self.printer.state = "disconnected" if text is not None: self.panels['splash_screen'].update_text(text) self.panels['splash_screen'].show_restart_buttons()