MCPcopy Create free account
hub / github.com/cocoindex-io/cocoindex-code / doctor

Function doctor

src/cocoindex_code/client.py:362–394  ·  view source on GitHub ↗

Run doctor checks via daemon, streaming results to on_result callback.

(
    project_root: str | None = None,
    on_result: Callable[[DoctorCheckResult], None] | None = None,
)

Source from the content-addressed store, hash-verified

360
361
362def doctor(
363 project_root: str | None = None,
364 on_result: Callable[[DoctorCheckResult], None] | None = None,
365) -> list[DoctorCheckResult]:
366 """Run doctor checks via daemon, streaming results to on_result callback."""
367 if project_root is not None:
368 project_root = normalize_input_path(project_root)
369 conn = _connect_and_handshake()
370 try:
371 conn.send_bytes(encode_request(DoctorRequest(project_root=project_root)))
372 results: list[DoctorCheckResult] = []
373 while True:
374 try:
375 data = conn.recv_bytes()
376 except EOFError:
377 raise RuntimeError("Connection to daemon lost during doctor checks")
378 resp = decode_response(data)
379 if isinstance(resp, ErrorResponse):
380 detail = f"Daemon error: {resp.message}"
381 if resp.traceback:
382 detail += f"\n{resp.traceback}"
383 raise RuntimeError(detail)
384 if isinstance(resp, DoctorResponse):
385 results.append(resp.result)
386 if on_result is not None:
387 on_result(resp.result)
388 if resp.final:
389 break
390 else:
391 raise RuntimeError(f"Unexpected response: {type(resp).__name__}")
392 return results
393 finally:
394 conn.close()
395
396
397# ---------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 6

normalize_input_pathFunction · 0.85
encode_requestFunction · 0.85
DoctorRequestClass · 0.85
decode_responseFunction · 0.85
closeMethod · 0.80
_connect_and_handshakeFunction · 0.70

Tested by

no test coverage detected