2025-10-23 13:59:30 +00:00
|
|
|
import sys
|
|
|
|
|
import platform
|
2025-10-18 21:11:16 +00:00
|
|
|
from serial.tools import list_ports
|
2025-10-23 13:59:30 +00:00
|
|
|
import serial
|
2025-10-18 21:11:16 +00:00
|
|
|
|
|
|
|
|
def cmd_doctor(_args):
|
|
|
|
|
try:
|
|
|
|
|
ports = list(list_ports.comports())
|
2025-10-23 13:59:30 +00:00
|
|
|
print(f"[bao] Python {platform.python_version()} OK; pyserial {serial.__version__} OK; ports found: {len(ports)}")
|
2025-10-18 21:11:16 +00:00
|
|
|
for p in ports:
|
|
|
|
|
print(f" - {p.device} {p.description}")
|
2025-10-23 13:59:30 +00:00
|
|
|
if not ports and sys.platform != "win32":
|
|
|
|
|
print(" Hint: On Linux/macOS you may need to add your user to the dialout/uucp group or adjust permissions.")
|
2025-10-18 21:11:16 +00:00
|
|
|
except Exception as e:
|
|
|
|
|
print(f"[bao] Doctor failed: {e}")
|
2025-11-03 14:39:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def register(subparsers) -> None:
|
|
|
|
|
d = subparsers.add_parser("doctor", help="Check Python environment and ports")
|
|
|
|
|
d.set_defaults(func=cmd_doctor)
|