#!/usr/bin/env python3 """Redeploy YtAssignPanel FE after type fix; verify timeslot-test API.""" from __future__ import annotations import sys import time from pathlib import Path import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") ROOT = Path(__file__).resolve().parents[1] def ssh(): c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect( "107.173.30.245", 22, "root", "Xiao4669805", timeout=45, allow_agent=False, look_for_keys=False, banner_timeout=120, ) return c def run(c, cmd, t=900): print(f"\n$ {cmd[:240]}", flush=True) _i, o, e = c.exec_command(cmd, timeout=t) code = o.channel.recv_exit_status() out = (o.read() + e.read()).decode("utf-8", "replace") print(out[-22000:] if len(out) > 22000 else out, flush=True) return code, out c = ssh() sftp = c.open_sftp() sftp.put( str(ROOT / "frontend/src/components/YtAssignPanel.tsx"), "/tmp/YtAssignPanel.tsx", ) sftp.close() code, _ = run( c, r""" set -euo pipefail install -m 0644 /tmp/YtAssignPanel.tsx /opt/douyinWEB/frontend/src/components/YtAssignPanel.tsx cd /opt/douyinWEB/frontend npm run build systemctl restart douyinweb-web sleep 2 systemctl is-active douyinweb-web douyinweb-api CS=$(mktemp) curl -sS -m 20 -c "$CS" -b "$CS" -X POST http://127.0.0.1:8014/api/auth/login \ -H 'Content-Type: application/json' \ -d '{"username":"hackrobot","password":"Xiao4669805@"}' >/dev/null curl -sS -m 15 -b "$CS" -o /dev/null -w 'timeslot-test:%{http_code}\n' -X POST \ http://127.0.0.1:8014/api/youtube/relay/timeslot-test \ -H 'Content-Type: application/json' -d '{"enabled":false}' curl -sS -m 15 -b "$CS" -o /dev/null -w 'timeslot-next:%{http_code}\n' -X POST \ http://127.0.0.1:8014/api/youtube/relay/timeslot-test/next echo DONE """, ) c.close() raise SystemExit(code)