MCPcopy Create free account
hub / github.com/1jehuang/jcode / DebugSocketClient

Class DebugSocketClient

scripts/test_memory.py:43–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41def log_section(msg): log(f"\n{'='*60}\n{msg}\n{'='*60}", YELLOW)
42
43class DebugSocketClient:
44 def __init__(self, socket_path):
45 self.socket_path = socket_path
46 self.sock = None
47
48 def connect(self):
49 self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
50 self.sock.connect(self.socket_path)
51 self.sock.settimeout(120)
52
53 def close(self):
54 if self.sock:
55 self.sock.close()
56
57 def send(self, cmd, session_id=None):
58 req = {"type": "debug_command", "id": 1, "command": cmd}
59 if session_id:
60 req["session_id"] = session_id
61 self.sock.send((json.dumps(req) + '\n').encode())
62 data = self.sock.recv(65536).decode()
63 resp = json.loads(data)
64 return resp.get('ok'), resp.get('output', '')
65
66def run_tests(client, providers):
67 results = {"passed": 0, "failed": 0}

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by 1

mainFunction · 0.68