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>
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
import paramiko
|
|
|
|
HOST = "107.173.30.245"
|
|
USER = "root"
|
|
PASSWORD = "Xiao4669805"
|
|
|
|
|
|
def main() -> None:
|
|
client = paramiko.SSHClient()
|
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
client.connect(HOST, 22, USER, PASSWORD, timeout=30, allow_agent=False, look_for_keys=False)
|
|
|
|
# last commits that touched monitor.db
|
|
cmd = "cd /opt/douyinWEB && git log -n 8 --oneline -- backend/data/monitor.db"
|
|
_stdin, stdout, stderr = client.exec_command(cmd, timeout=60)
|
|
log = stdout.read().decode("utf-8", "replace")
|
|
_ = stderr.read().decode("utf-8", "replace")
|
|
print(log)
|
|
|
|
hashes: list[str] = []
|
|
for line in log.splitlines():
|
|
line = line.strip()
|
|
if not line:
|
|
continue
|
|
hashes.append(line.split()[0])
|
|
|
|
for h in hashes:
|
|
tmp = f"/tmp/monitor_{h}.db"
|
|
cmd1 = f"cd /opt/douyinWEB && git show {h}:backend/data/monitor.db > {tmp}"
|
|
_stdin, stdout, stderr = client.exec_command(cmd1, timeout=120)
|
|
err1 = stderr.read().decode("utf-8", "replace").strip()
|
|
if err1:
|
|
print("hash", h, "git show err:", err1[:200])
|
|
continue
|
|
|
|
cmd2 = (
|
|
"python3 -c \"import sqlite3; "
|
|
f"conn=sqlite3.connect('{tmp}'); "
|
|
"print(conn.execute('select count(*) from shorts_channels').fetchone()[0])\""
|
|
)
|
|
_stdin, stdout, stderr = client.exec_command(cmd2, timeout=60)
|
|
out = stdout.read().decode("utf-8", "replace").strip()
|
|
err2 = stderr.read().decode("utf-8", "replace").strip()
|
|
print("hash", h, "shorts_channels", out, "err", err2[:120])
|
|
|
|
client.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|