logging: exceptions can log more info
This commit is contained in:
parent
7c8d4ea4d7
commit
562e49b8d2
@ -34,7 +34,8 @@ class KlippyRest:
|
|||||||
headers = {} if self.api_key is False else {"x-api-key": self.api_key}
|
headers = {} if self.api_key is False else {"x-api-key": self.api_key}
|
||||||
try:
|
try:
|
||||||
r = requests.get(url, headers=headers)
|
r = requests.get(url, headers=headers)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
|
logging.critical(e, exc_info=True)
|
||||||
return False
|
return False
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
return False
|
return False
|
||||||
@ -42,7 +43,8 @@ class KlippyRest:
|
|||||||
# TODO: Try/except
|
# TODO: Try/except
|
||||||
try:
|
try:
|
||||||
data = json.loads(r.content)
|
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)
|
logging.exception("Unable to parse response from moonraker:\n %s" % r.content)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -74,7 +74,8 @@ class KlippyWebsocket(threading.Thread):
|
|||||||
_("Retry #%s") % self.reconnect_count)
|
_("Retry #%s") % self.reconnect_count)
|
||||||
return False
|
return False
|
||||||
token = self._screen.apiclient.get_oneshot_token()
|
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")
|
logging.debug("Unable to get oneshot token")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -86,7 +87,8 @@ class KlippyWebsocket(threading.Thread):
|
|||||||
try:
|
try:
|
||||||
logging.debug("Starting websocket thread")
|
logging.debug("Starting websocket thread")
|
||||||
self._wst.start()
|
self._wst.start()
|
||||||
except Exception:
|
except Exception as e:
|
||||||
|
logging.critical(e, exc_info=True)
|
||||||
logging.debug("Error starting web socket")
|
logging.debug("Error starting web socket")
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
|
@ -64,7 +64,8 @@ def get_wireless_interfaces():
|
|||||||
try:
|
try:
|
||||||
p = subprocess.Popen(["iwconfig"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen(["iwconfig"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
result = p.stdout.read().decode('ascii').split('\n')
|
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")
|
logging.info("Error with running iwconfig command")
|
||||||
return None
|
return None
|
||||||
interfaces = []
|
interfaces = []
|
||||||
|
@ -50,8 +50,9 @@ class WifiManager():
|
|||||||
self.soc = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
|
self.soc = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
|
||||||
self.soc.bind(KS_SOCKET_FILE)
|
self.soc.bind(KS_SOCKET_FILE)
|
||||||
self.soc.connect("/var/run/wpa_supplicant/%s" % interface)
|
self.soc.connect("/var/run/wpa_supplicant/%s" % interface)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
logging.info("Error connecting to wifi socket: %s" % interface)
|
logging.critical(e, exc_info=True)
|
||||||
|
logging.error("Error connecting to wifi socket: %s" % interface)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.wpa_thread = WpaSocket(self, self.queue, self.callback)
|
self.wpa_thread = WpaSocket(self, self.queue, self.callback)
|
||||||
@ -324,7 +325,8 @@ class WpaSocket(Thread):
|
|||||||
while self._stop_loop is False:
|
while self._stop_loop is False:
|
||||||
try:
|
try:
|
||||||
msg = self.soc.recv(4096).decode().strip()
|
msg = self.soc.recv(4096).decode().strip()
|
||||||
except Exception:
|
except Exception as e:
|
||||||
|
logging.critical(e, exc_info=True)
|
||||||
# TODO: Socket error
|
# TODO: Socket error
|
||||||
continue
|
continue
|
||||||
if msg.startswith("<"):
|
if msg.startswith("<"):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user