# -*- coding: utf-8 -*- from __future__ import annotations import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") REMOTE = r""" from app import yt_assign_db r = yt_assign_db.ensure_default_assign_data() print("ensure", r) for g in yt_assign_db.list_groups(include_urls=True): print(g.get("name"), "pool", len(g.get("pool") or []), "slots", len(g.get("slots") or [])) """ c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False) _, o, e = c.exec_command( f"cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'\n{REMOTE}\nPY", timeout=60, ) print(o.read().decode("utf-8", "replace")) if e.read().decode().strip(): print("ERR", e.read().decode()[:500]) c.close()