MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / _LiveCapture

Class _LiveCapture

core/peer_shell.py:57–75  ·  view source on GitHub ↗

Writes to stdout in real-time AND accumulates to a buffer. Handles both str and bytes from pexpect safely.

Source from the content-addressed store, hash-verified

55
56
57class _LiveCapture:
58 """Writes to stdout in real-time AND accumulates to a buffer.
59 Handles both str and bytes from pexpect safely."""
60
61 def __init__(self):
62 self._buf = io.StringIO()
63
64 def write(self, data):
65 if isinstance(data, bytes):
66 data = data.decode("utf-8", errors="replace")
67 sys.stdout.write(data)
68 sys.stdout.flush()
69 self._buf.write(data)
70
71 def flush(self):
72 sys.stdout.flush()
73
74 def getvalue(self) -> str:
75 return self._buf.getvalue()
76
77
78def _check_pexpect() -> bool:

Callers 1

run_peerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected