# -*- coding: utf-8 -*- """Deploy: OAuth always writes to the clicked channel card.""" from __future__ import annotations import sys from pathlib import Path import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") ROOT = Path(__file__).resolve().parents[1] HOST = "108.174.50.68" PASS = "Xiao4669805" REPO = "/opt/douyinWEB" FILES = [ "backend/app/shorts_oauth.py", "backend/app/main.py", "frontend/src/app/shorts/page.tsx", "frontend/src/app/shorts/reauth-batch/page.tsx", ] def main() -> int: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(HOST, 22, "root", PASS, timeout=60, allow_agent=False, look_for_keys=False) sftp = c.open_sftp() for rel in FILES: sftp.put(str(ROOT / rel), f"{REPO}/{rel}") print("uploaded", rel) sftp.close() cmd = r""" set -e systemctl restart douyinweb-api cd /opt/douyinWEB/frontend && npm run build systemctl restart douyinweb-web sleep 2 systemctl is-active douyinweb-api douyinweb-web cd /opt/douyinWEB/backend PYTHONPATH=. .venv/bin/python - <<'PY' import inspect from app import shorts_oauth src = inspect.getsource(shorts_oauth.exchange_code) assert '点错品牌账号' not in src assert '_find_channel_for_youtube_id' not in src assert 'Always bind OAuth result to the card' in src or 'Clicked card wins' in src src2 = inspect.getsource(shorts_oauth.prepare_reauthorize) assert 'revoke_refresh_token' not in src2 print('ok_clicked_card') PY """ _i, o, e = c.exec_command(cmd, timeout=360) out = o.read().decode("utf-8", "replace") err = e.read().decode("utf-8", "replace") code = o.channel.recv_exit_status() print(out[-2500:] if len(out) > 2500 else out) if err.strip(): print("STDERR", err[-1500:]) print("exit", code) c.close() return code if __name__ == "__main__": raise SystemExit(main())