From 74da19ed55fde1dda118075279a06b3df2acfb41 Mon Sep 17 00:00:00 2001 From: Bill Finger Date: Thu, 22 May 2025 14:44:04 +0300 Subject: [PATCH] colorized debug --- utils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/utils.py b/utils.py index 04f96ff..c74f0d6 100644 --- a/utils.py +++ b/utils.py @@ -4,6 +4,9 @@ import socket import json DEBUG: bool = True +RESET = "\033[0m" +CYAN = "\033[36m" +YELLOW = "\033[33m" class RobotClient: @@ -14,13 +17,13 @@ class RobotClient: self.sock.connect((self.host, self.port)) def _send(self, cmd) -> dict: - if (DEBUG): - print(f"DEBUG: sended: {cmd}") + if DEBUG: + print(f"{CYAN}DEBUG: sended:{RESET} {cmd}") self.sock.sendall(json.dumps(cmd).encode("utf-8")) data = self.sock.recv(1024).decode("utf-8") ret = json.loads(data) - if (DEBUG): - print(f"DEBUG: received: {ret}") + if DEBUG: + print(f"{YELLOW}DEBUG: received:{RESET} {ret}") return ret def rpy_to_quat(self, arr):