# -*- coding: utf-8 -*- import paramiko script = """import sys, json sys.path.insert(0, '/opt/douyinWEB/backend') from app import db from app import yt_long_db as yldb # find Nomadro Hub rows = db.list_shorts_channels(enabled=None) hub = None for ch in rows: n = str(ch.get('name') or '').lower() if 'nomadro hub' in n or 'nomadrohub' in n: hub = ch break if not hub: print('channel not found') sys.exit(0) print('=== shorts channel ===') print('id', hub.get('id')) print('name', hub.get('name')) print('yt_id', hub.get('youtube_channel_id')) print('oauth_ok', hub.get('oauth_ok')) print('oauth_error', hub.get('oauth_error')) print('oauth_profile_id', hub.get('oauth_profile_id')) print('note', (hub.get('note') or '')[:120]) yl = yldb.get_yt_long_by_shorts_pk(str(hub.get('id') or '')) print('=== yt_long channel ===') print(json.dumps({k: yl.get(k) for k in ('id','name','youtube_channel_id','ypp_ok','monetize_default','shorts_channel_pk') if yl}, ensure_ascii=False, indent=2) if yl else 'none') # recent uploaded jobs for this channel if yl: import sqlite3 conn = sqlite3.connect('/opt/douyinWEB/backend/data/monitor.db') conn.row_factory = sqlite3.Row jobs = conn.execute(''' SELECT id, status, youtube_video_id, youtube_url, error, meta_json, finished_at FROM yt_long_jobs WHERE channel_pk=? ORDER BY finished_at DESC LIMIT 8 ''', (yl['id'],)).fetchall() for j in jobs: meta = {} try: meta = json.loads(j['meta_json'] or '{}') except Exception: pass print('--- job', j['id'][:8], j['status'], j['youtube_video_id']) print(' error', (j['error'] or '')[:120]) print(' monetize', meta.get('monetize') or meta.get('monetize_result') or meta.get('ypp_monetize')) 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_hub.py", "w") as f: f.write(script) sftp.close() _, o, e = c.exec_command("cd /opt/douyinWEB/backend && .venv/bin/python /tmp/diag_hub.py", timeout=120) print(o.read().decode("utf-8", "replace")) if e.read().decode().strip(): print("ERR", e.read()[:300]) c.close()