Created
April 12, 2025 19:18
-
-
Save vvuk/423d985a737e28e2e661b51671b22dbf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git klippy/webhooks.py klippy/webhooks.py | |
index 458a77b1..b6708232 100644 | |
--- klippy/webhooks.py | |
+++ klippy/webhooks.py | |
@@ -311,15 +311,23 @@ class ClientConnection: | |
return | |
self.send(result) | |
- def send(self, data): | |
+ def _safe_dumps(self, data): | |
try: | |
- jmsg = json.dumps(data, separators=(",", ":")) | |
- self.send_buffer += jmsg.encode() + b"\x03" | |
+ return json.dumps(data, separators=(",", ":")) | |
except (TypeError, ValueError) as e: | |
- msg = "json encoding error: %s" % (str(e),) | |
+ msg = "json encoding error: %s, data: %s" % (str(e),str(data)) | |
logging.exception(msg) | |
+ logging.info("DATA DUMP:") | |
+ for k,v in data.items(): | |
+ logging.info(f" {k} -> {v} ({type(v)})") | |
self.printer.invoke_shutdown(msg) | |
+ return None | |
+ | |
+ def send(self, data): | |
+ jmsg = self._safe_dumps(data) | |
+ if jmsg is None: | |
return | |
+ self.send_buffer += jmsg.encode() + b"\x03" | |
if not self.is_blocking: | |
self._do_send() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment