nomadro/apps/admin/deploy/_probe_douyin_live.py
eric 0e85d71386 Add Douyin BMI audit homepage with remote A/B switch.
Ship a health-management BMI home for review, keep the nomad hub as hub, and let admin switch platforms.tt.homeVariant live with track/ntfy; fix tt config fetch to api.nomadro.cn/api/config.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-03 02:32:26 -05:00

51 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""Probe live douyin admin / API layout on production."""
from __future__ import annotations
import paramiko
HOST, USER, PASS = "82.157.112.245", "ubuntu", "Xiao4669805"
CMD = r"""
set -e
echo "=== systemd ==="
systemctl show nomadmini-api -p WorkingDirectory -p FragmentPath --no-pager 2>/dev/null || true
echo "=== files ==="
ls -la /opt/nomadmini/backend/app/routers/douyin_admin.py /opt/nomadmini/backend/app/services/tt_platform_config.py 2>&1 || true
ls -la /opt/nomadmini/backend/app/main.py 2>&1 || true
echo "=== imports ==="
head -20 /opt/nomadmini/backend/app/routers/douyin_admin.py 2>/dev/null || true
echo "=== homeVariant in py ==="
grep -n homeVariant /opt/nomadmini/backend/app/services/tt_platform_config.py 2>/dev/null || echo no_homeVariant
echo "=== remote-config tt ==="
python3 - <<'PY'
import json
from pathlib import Path
p = Path("/var/www/nomadro.cn/data/remote-config.json")
d = json.loads(p.read_text(encoding="utf-8"))
tt = (d.get("platforms") or {}).get("tt") or {}
print("homeVariant", tt.get("homeVariant"))
mods = tt.get("modules") or {}
print("mods", {k: (v or {}).get("enabled") for k, v in mods.items()})
print("chapters", len(((tt.get("bookContent") or {}).get("chapters") or [])))
PY
"""
def main() -> int:
import sys
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(HOST, username=USER, password=PASS, timeout=40, allow_agent=False, look_for_keys=False)
_, stdout, _ = c.exec_command(CMD, timeout=60, get_pty=True)
print(stdout.read().decode("utf-8", "replace"))
code = stdout.channel.recv_exit_status()
c.close()
return code
if __name__ == "__main__":
raise SystemExit(main())