Document test9 tag 2026-11-02 for upload; POST config pull + WS, fixed dark home, no debug bar. Co-authored-by: Cursor <cursoragent@cursor.com>
57 lines
2.0 KiB
Python
57 lines
2.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
REPO = Path(__file__).resolve().parents[3]
|
|
HOST, USER, PASS = "82.157.112.245", "ubuntu", "Xiao4669805"
|
|
FILES = [
|
|
(REPO / "apps/api/services/ebook_svc/core/deps.py", "/opt/nomadmini/backend/app/core/deps.py"),
|
|
(REPO / "apps/api/services/ebook_svc/routers/books.py", "/opt/nomadmini/backend/app/routers/books.py"),
|
|
]
|
|
|
|
|
|
def main() -> int:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, username=USER, password=PASS, timeout=60, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
for src, dest in FILES:
|
|
data = src.read_text(encoding="utf-8").replace("ebook_svc.", "app.").encode("utf-8")
|
|
with sftp.file(f"/tmp/{Path(dest).name}", "wb") as rf:
|
|
rf.write(data)
|
|
sftp.close()
|
|
cmd = r"""
|
|
set -e
|
|
sudo cp /tmp/deps.py /opt/nomadmini/backend/app/core/deps.py
|
|
sudo cp /tmp/books.py /opt/nomadmini/backend/app/routers/books.py
|
|
sudo systemctl restart nomadmini-api
|
|
sleep 2
|
|
curl -sk -o /tmp/r.json -w "read %{http_code}\n" https://api.nomadro.cn/api/ebook/books/audit/read
|
|
python3 - <<'PY'
|
|
import json
|
|
d=json.load(open('/tmp/r.json',encoding='utf-8'))
|
|
print('title', (d.get('book') or {}).get('title'))
|
|
print('chapters', len(d.get('chapters') or []))
|
|
body=((d.get('chapters') or [{}])[0].get('content') or '')[:100]
|
|
print('body', body.replace('\n',' '))
|
|
PY
|
|
"""
|
|
_, stdout, _ = c.exec_command(cmd, timeout=90, get_pty=True)
|
|
while not stdout.channel.exit_status_ready():
|
|
if stdout.channel.recv_ready():
|
|
print(stdout.channel.recv(65536).decode("utf-8", "replace"), end="", flush=True)
|
|
time.sleep(0.05)
|
|
while stdout.channel.recv_ready():
|
|
print(stdout.channel.recv(65536).decode("utf-8", "replace"), end="", flush=True)
|
|
code = stdout.channel.recv_exit_status()
|
|
c.close()
|
|
return code
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|