nomadro/apps/admin/deploy/_push_weapp_switches_svc.py
Eric 4389ebe6cb Ship WeChat audit release 2026-11-02: realtime config, audit vip-ebook shell, admin ops.
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>
2026-11-02 16:12:57 +08:00

47 lines
1.6 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"
SRC = REPO / "apps/api/services/ebook_svc/services/weapp_switches.py"
def main() -> int:
data = SRC.read_text(encoding="utf-8").replace("ebook_svc.", "app.").encode("utf-8")
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()
with sftp.file("/tmp/weapp_switches.py", "wb") as rf:
rf.write(data)
sftp.close()
cmd = r"""
set -e
sudo cp /tmp/weapp_switches.py /opt/nomadmini/backend/app/services/weapp_switches.py
cd /opt/nomadmini/backend
.venv/bin/python -c 'from app.services.weapp_switches import read_weapp_switches; print("ok", read_weapp_switches()["bookAudit"])'
sudo systemctl restart nomadmini-api
sleep 2
systemctl is-active nomadmini-api
rm -f /tmp/weapp_switches.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())