douyinWEB/scripts/_open_tm_dashboard.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-04 22:42:40 -05:00

57 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
from __future__ import annotations
import sys
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
CMD = r"""
docker exec douyinweb-neko-3 python3 - <<'PY'
import json, urllib.request, time
def list_tabs():
with urllib.request.urlopen("http://127.0.0.1:9222/json/list", timeout=8) as resp:
return json.loads(resp.read().decode())
def new_tab(url):
req = urllib.request.Request(
"http://127.0.0.1:9222/json/new",
data=json.dumps({"url": url}).encode(),
headers={"Content-Type": "application/json"},
)
with urllib.request.urlopen(req, timeout=8) as resp:
return json.loads(resp.read().decode())
for url in (
"chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/dashboard.html",
"chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/options.html",
):
try:
tab = new_tab(url)
print("opened", url.split("/")[-1], "->", (tab.get("url") or "")[:120])
except Exception as exc:
print("fail", url.split("/")[-1], exc)
time.sleep(2)
for tab in list_tabs():
u = tab.get("url") or ""
if "dhdgffkkebhmkfjojejmpbldmpobfkfo" in u or "tampermonkey" in u:
print("tab", u[:140])
PY
"""
def main() -> None:
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("108.174.50.68", 22, "root", "Xiao4669805", timeout=60, allow_agent=False, look_for_keys=False)
_i, o, e = c.exec_command(CMD, timeout=60)
print(o.read().decode("utf-8", "replace"))
c.close()
if __name__ == "__main__":
main()