#!/usr/bin/env python3 from __future__ import annotations import sys import paramiko HOST, USER, PASS = "10.88.0.3", "eric", "Xiao4669805" BASE = "/opt/live/d2ypp" def run(cmd: str, timeout: int = 120) -> str: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(HOST, username=USER, password=PASS, timeout=20) _, o, e = c.exec_command("export LC_ALL=C.UTF-8 LANG=C.UTF-8; " + cmd, timeout=timeout) out = (o.read() + e.read()).decode("utf-8", "replace") c.close() return out def safe_print(text: str) -> None: try: print(text) except UnicodeEncodeError: sys.stdout.buffer.write(text.encode("utf-8", errors="replace") + b"\n") cmds = [ f"journalctl -u live-console.service -n 60 --no-pager 2>&1 | tail -40", f"cd {BASE} && .venv/bin/python -c \"import web; print('web_import_ok')\" 2>&1", f"cd {BASE} && .venv/bin/python -c \"from src.youtube_relay_log import list_relay_sessions; print(list_relay_sessions(limit=1))\" 2>&1", ] for cmd in cmds: safe_print(f"\n=== {cmd[:80]} ===\n{run(cmd)[:4000]}")