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>
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
# -*- coding: utf-8
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
REMOTE_PY = r"""import json, time, urllib.request
|
|
|
|
time.sleep(8)
|
|
with urllib.request.urlopen("http://127.0.0.1:9222/json/list", timeout=8) as resp:
|
|
tabs = json.loads(resp.read().decode())
|
|
print("tabs", len(tabs))
|
|
for t in tabs:
|
|
u = t.get("url") or ""
|
|
if "youtube" in u or "google" in u or "studio" in u:
|
|
mark = "ACTIVE" if t.get("type") == "page" else ""
|
|
print(mark, u[:130])
|
|
"""
|
|
|
|
|
|
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)
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/check_tabs.py", "w") as f:
|
|
f.write(REMOTE_PY)
|
|
sftp.close()
|
|
_i, o, e = c.exec_command(
|
|
"docker cp /tmp/check_tabs.py douyinweb-neko-3:/tmp/check_tabs.py && docker exec douyinweb-neko-3 python3 /tmp/check_tabs.py",
|
|
timeout=90,
|
|
)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|