diff --git a/ks_includes/KlippyRest.py b/ks_includes/KlippyRest.py index 542dec09..6a01cc9c 100644 --- a/ks_includes/KlippyRest.py +++ b/ks_includes/KlippyRest.py @@ -34,7 +34,8 @@ class KlippyRest: headers = {} if self.api_key is False else {"x-api-key": self.api_key} try: r = requests.get(url, headers=headers) - except Exception: + except Exception as e: + logging.critical(e, exc_info=True) return False if r.status_code != 200: return False @@ -42,7 +43,8 @@ class KlippyRest: # TODO: Try/except try: data = json.loads(r.content) - except Exception: + except Exception as e: + logging.critical(e, exc_info=True) logging.exception("Unable to parse response from moonraker:\n %s" % r.content) return False diff --git a/ks_includes/KlippyWebsocket.py b/ks_includes/KlippyWebsocket.py index bc096263..29804ab3 100644 --- a/ks_includes/KlippyWebsocket.py +++ b/ks_includes/KlippyWebsocket.py @@ -74,7 +74,8 @@ class KlippyWebsocket(threading.Thread): _("Retry #%s") % self.reconnect_count) return False token = self._screen.apiclient.get_oneshot_token() - except Exception: + except Exception as e: + logging.critical(e, exc_info=True) logging.debug("Unable to get oneshot token") return False @@ -86,7 +87,8 @@ class KlippyWebsocket(threading.Thread): try: logging.debug("Starting websocket thread") self._wst.start() - except Exception: + except Exception as e: + logging.critical(e, exc_info=True) logging.debug("Error starting web socket") def close(self): diff --git a/ks_includes/functions.py b/ks_includes/functions.py index 46f71a81..3a19ecaa 100644 --- a/ks_includes/functions.py +++ b/ks_includes/functions.py @@ -64,7 +64,8 @@ def get_wireless_interfaces(): try: p = subprocess.Popen(["iwconfig"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) result = p.stdout.read().decode('ascii').split('\n') - except Exception: + except Exception as e: + logging.critical(e, exc_info=True) logging.info("Error with running iwconfig command") return None interfaces = [] diff --git a/ks_includes/wifi.py b/ks_includes/wifi.py index 406ad7c3..21b8c4f0 100644 --- a/ks_includes/wifi.py +++ b/ks_includes/wifi.py @@ -50,8 +50,9 @@ class WifiManager(): self.soc = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) self.soc.bind(KS_SOCKET_FILE) self.soc.connect("/var/run/wpa_supplicant/%s" % interface) - except Exception: - logging.info("Error connecting to wifi socket: %s" % interface) + except Exception as e: + logging.critical(e, exc_info=True) + logging.error("Error connecting to wifi socket: %s" % interface) return self.wpa_thread = WpaSocket(self, self.queue, self.callback) @@ -324,7 +325,8 @@ class WpaSocket(Thread): while self._stop_loop is False: try: msg = self.soc.recv(4096).decode().strip() - except Exception: + except Exception as e: + logging.critical(e, exc_info=True) # TODO: Socket error continue if msg.startswith("<"):