43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Read-only: how live session covers are stored on physical API."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace", line_buffering=True)
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("107.173.30.245", 4014, "eric", "4669805", timeout=25, banner_timeout=40, allow_agent=False, look_for_keys=False)
|
|
print("connected", flush=True)
|
|
cmd = r'''
|
|
echo 4669805 | sudo -S -p '' bash -lc '
|
|
cd /opt/douyinWEB/backend
|
|
.venv/bin/python - <<PY
|
|
from app import db
|
|
rows = db.list_active_sessions()
|
|
print("active", len(rows))
|
|
for s in rows[:8]:
|
|
print({
|
|
"id": s.get("id"),
|
|
"anchor": s.get("anchor_name") or s.get("room_id"),
|
|
"cover_path": (s.get("cover_path") or "")[:120],
|
|
"cover_url_field": (s.get("cover_url") or "")[:80],
|
|
})
|
|
PY
|
|
'
|
|
'''
|
|
_i, o, e = c.exec_command(cmd, timeout=40)
|
|
while not o.channel.exit_status_ready():
|
|
if o.channel.recv_ready():
|
|
sys.stdout.write(o.channel.recv(4096).decode("utf-8", "replace"))
|
|
sys.stdout.flush()
|
|
time.sleep(0.1)
|
|
sys.stdout.write((o.read() + e.read()).decode("utf-8", "replace"))
|
|
sys.stdout.flush()
|
|
c.close()
|
|
print("DONE", flush=True)
|