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>
59 lines
2.1 KiB
Python
59 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
import sys
|
|
import paramiko
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
CMD = r"""
|
|
cd /opt/douyinWEB/backend
|
|
.venv/bin/python <<'PY'
|
|
from app import db, yt_assign_db
|
|
db.init_db()
|
|
rooms = db.list_rooms()
|
|
print('rooms_type', type(rooms).__name__)
|
|
if isinstance(rooms, dict):
|
|
print('rooms_keys', list(rooms.keys())[:20])
|
|
items = rooms.get('rooms') or rooms.get('items') or list(rooms.values())
|
|
else:
|
|
items = rooms
|
|
print('monitor_rooms', len(items) if hasattr(items,'__len__') else items)
|
|
for r in list(items)[:20]:
|
|
if not isinstance(r, dict):
|
|
print('ROW', r)
|
|
continue
|
|
print('ROOM', r.get('room_id') or r.get('id'), (r.get('anchor_name') or r.get('last_anchor') or r.get('name') or '')[:40], (r.get('url') or '')[:70], 'en', r.get('enabled'))
|
|
|
|
print('---groups---')
|
|
for g in yt_assign_db.list_groups(include_urls=True, include_secret=False):
|
|
feat = g.get('featured') or []
|
|
pool = g.get('pool') or []
|
|
slots = g.get('slots') or []
|
|
print('G', g.get('name'), 'feat', len(feat), 'pool', len(pool), 'slots', len(slots))
|
|
for x in feat[:3]:
|
|
print(' F', (x.get('url') or '')[:70], x.get('room_id'), x.get('blacklisted'))
|
|
for x in pool[:2]:
|
|
print(' P', (x.get('url') or '')[:70], x.get('room_id'))
|
|
# sqlite counts
|
|
import sqlite3
|
|
from app.config import settings
|
|
conn=sqlite3.connect(str(settings.sqlite_path))
|
|
for t in ('rooms','yt_assign_groups','yt_assign_pool_urls','yt_assign_featured_urls','yt_assign_slot_urls'):
|
|
try:
|
|
n=conn.execute(f'select count(*) from {t}').fetchone()[0]
|
|
print('CNT', t, n)
|
|
except Exception as e:
|
|
print('CNT', t, e)
|
|
conn.close()
|
|
PY
|
|
"""
|
|
|
|
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)
|
|
_, o, e = c.exec_command(CMD, timeout=60)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
err = e.read().decode("utf-8", "replace")
|
|
if err.strip():
|
|
print("STDERR", err[-2000:])
|
|
c.close()
|