douyinWEB/scripts/_diag_nomadro_hub2.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

48 lines
1.9 KiB
Python

# -*- coding: utf-8 -*-
import paramiko
script = """import sys, json, sqlite3
sys.path.insert(0, '/opt/douyinWEB/backend')
from app import db
conn = sqlite3.connect('/opt/douyinWEB/backend/data/monitor.db')
conn.row_factory = sqlite3.Row
# yt_long channel for Nomadro Hub
yl = conn.execute("SELECT * FROM yt_long_channels WHERE name LIKE '%Nomadro Hub%'").fetchone()
print('yt_long row keys:', list(yl.keys()) if yl else None)
if yl:
d = dict(yl)
for k in ('id','name','youtube_channel_id','ypp_ok','source_shorts_channel_pk','oauth_refresh_token','oauth_client_id'):
v = d.get(k)
if k == 'oauth_refresh_token' and v:
v = v[:20] + '...'
print(k, v)
jobs = conn.execute('SELECT id,status,youtube_video_id,error,meta_json,finished_at FROM yt_long_jobs WHERE channel_pk=? ORDER BY finished_at DESC LIMIT 10', (yl['id'],)).fetchall()
print('jobs count', len(jobs))
for j in jobs:
meta = {}
try: meta = json.loads(j['meta_json'] or '{}')
except: pass
print('job', j['id'][:8], j['status'], j['youtube_video_id'], (j['error'] or '')[:100])
# check if source_shorts_channel_pk links
if yl and not yl['source_shorts_channel_pk']:
sc = conn.execute("SELECT id,name,oauth_ok,youtube_channel_id FROM shorts_channels WHERE youtube_channel_id=?", (yl['youtube_channel_id'],)).fetchone()
print('matching shorts by yt_id:', dict(sc) if sc else None)
conn.close()
"""
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False)
sftp = c.open_sftp()
with sftp.file("/tmp/diag_hub2.py", "w") as f:
f.write(script)
sftp.close()
_, o, e = c.exec_command("cd /opt/douyinWEB/backend && .venv/bin/python /tmp/diag_hub2.py", timeout=120)
print(o.read().decode("utf-8", "replace"))
c.close()