sh2/d2ypp2/tools/verify_deploy_unlock.py
eric 2a0b37a4cb Allow independent lane control in YouTube Multi Pro without auto-locking to the pushing stream.
Remove the primary-pushing follow effect so operators can switch lanes while another line is live, keep logs and events tied to the selected lane, and ship the rebuilt console plus a deploy verification helper.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-10 23:01:29 -05:00

89 lines
3.2 KiB
Python

#!/usr/bin/env python3
"""Post-deploy verification for YouTube Pro lane unlock."""
from __future__ import annotations
import json
import os
import sys
import paramiko
HOST = os.environ.get("LIVE_DEPLOY_HOST", "192.168.31.56")
USER = os.environ.get("LIVE_DEPLOY_USER", "eric")
PASSWORD = os.environ.get("LIVE_DEPLOY_PASS", "")
def run(client: paramiko.SSHClient, cmd: str) -> tuple[int, str, str]:
_, stdout, stderr = client.exec_command(f"bash -lc {json.dumps(cmd)}", timeout=45)
return (
stdout.channel.recv_exit_status(),
stdout.read().decode("utf-8", errors="replace"),
stderr.read().decode("utf-8", errors="replace"),
)
def main() -> int:
if not PASSWORD:
print("Set LIVE_DEPLOY_PASS", file=sys.stderr)
return 1
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(HOST, username=USER, password=PASSWORD, timeout=20)
checks: list[tuple[str, bool, str]] = []
code, out, err = run(client, "curl -sf http://127.0.0.1:8001/health")
checks.append(("health", code == 0 and "ok" in out.lower(), out.strip() or err.strip()))
code, out, _ = run(
client,
'grep -r "自动跟随" /opt/live/d2ypp/web-console/out/_next/static/chunks/ 2>/dev/null | head -1 || true',
)
checks.append(("no_auto_follow_in_bundle", not out.strip(), out.strip() or "not found (good)"))
code, out, _ = run(
client,
'grep -r "primaryPushingPm2" /opt/live/d2ypp/web-console/components/LiveYoutubeUnmannedView.tsx /opt/live/d2ypp/web-console/components/live-product/LiveYoutubeUnmannedView.tsx 2>/dev/null | head -1 || true',
)
checks.append(("no_primary_pushing_in_tsx", not out.strip(), out.strip() or "not found (good)"))
code, out, err = run(client, "curl -sf http://127.0.0.1:8001/hub/processes")
youtube_rows: list[dict] = []
if code == 0 and out.strip():
data = json.loads(out)
rows = data if isinstance(data, list) else data.get("processes", data.get("rows", []))
youtube_rows = [
r
for r in rows
if "youtube" in str(r.get("pm2", "")).lower()
or "youtube" in str(r.get("script", "")).lower()
]
proc_lines = [
f"{r.get('pm2')}: pushing={r.get('is_pushing')} biz={r.get('business_status')}"
for r in youtube_rows
]
checks.append(("hub_processes", code == 0, "\n".join(proc_lines) or err.strip()))
code, out, err = run(client, "curl -sf http://127.0.0.1:8001/hub/youtube/pro/channels")
channel_names: list[str] = []
if code == 0 and out.strip():
data = json.loads(out)
channels = data.get("channels", data if isinstance(data, list) else [])
channel_names = [str(c.get("name", c.get("id", "?"))) for c in channels]
checks.append(("pro_channels", code == 0 and len(channel_names) > 0, ", ".join(channel_names) or err.strip()))
client.close()
failed = 0
for name, ok, detail in checks:
status = "PASS" if ok else "FAIL"
print(f"[{status}] {name}: {detail}")
if not ok:
failed += 1
return 1 if failed else 0
if __name__ == "__main__":
raise SystemExit(main())