# -*- coding: utf-8 -*- import paramiko script = """import sys, json, sqlite3 sys.path.insert(0, '/opt/douyinWEB/backend') from app import yt_long_db as yldb yl = yldb.get_yt_long_channel('9f51bb18-65dc-4f77-8d88-9c47fe191ad7') print('refresh_token len', len(str(yl.get('refresh_token') or ''))) print('oauth_profile_id', yl.get('oauth_profile_id')) print('oauth_ok', yl.get('oauth_ok')) print('oauth_error', yl.get('oauth_error')) print('has_refresh_token', yl.get('has_refresh_token')) 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,finished_at FROM yt_long_jobs WHERE channel_pk=? ORDER BY finished_at DESC LIMIT 10', ('9f51bb18-65dc-4f77-8d88-9c47fe191ad7',)).fetchall() print('jobs', len(jobs)) for j in jobs: print(dict(j)) 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_hub3.py", "w") as f: f.write(script) sftp.close() _, o, e = c.exec_command("cd /opt/douyinWEB/backend && .venv/bin/python /tmp/diag_hub3.py", timeout=120) print(o.read().decode("utf-8", "replace")) err = e.read().decode("utf-8", "replace") if err.strip(): print('ERR', err) c.close()