69cf94d1df
Co-authored-by: Cursor <cursoragent@cursor.com>
55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
"""Deploy symbol.js syntax fix."""
|
|
import paramiko
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
root = Path(__file__).resolve().parents[1]
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("192.168.8.21", username="root", password="woaini88", timeout=15)
|
|
sftp = c.open_sftp()
|
|
sftp.put(str(root / "static/js/symbol.js"), "/opt/qihuo/static/js/symbol.js")
|
|
print("uploaded symbol.js")
|
|
sftp.close()
|
|
|
|
VERIFY = r"""
|
|
import sys, urllib.request, urllib.parse, http.cookiejar, json
|
|
sys.path.insert(0, "/opt/qihuo")
|
|
|
|
jar = http.cookiejar.CookieJar()
|
|
op = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(jar))
|
|
user = pwd = ""
|
|
for line in open("/opt/qihuo/.env"):
|
|
line = line.strip()
|
|
if line.startswith("ADMIN_USERNAME="):
|
|
user = line.split("=", 1)[1].strip().strip('"').strip("'")
|
|
if line.startswith("ADMIN_PASSWORD="):
|
|
pwd = line.split("=", 1)[1].strip().strip('"').strip("'")
|
|
op.open(urllib.request.Request(
|
|
"http://127.0.0.1:6600/login",
|
|
urllib.parse.urlencode({"username": user, "password": pwd}).encode(),
|
|
))
|
|
raw = op.open("http://127.0.0.1:6600/api/symbols/recommended").read().decode()
|
|
groups = json.loads(raw)
|
|
items = sum(len(g.get("items") or []) for g in groups)
|
|
print("recommended groups", len(groups), "items", items)
|
|
js = open("/opt/qihuo/static/js/symbol.js", encoding="utf-8").read()
|
|
if "if item.near_expiry)" in js:
|
|
print("FAIL syntax still broken")
|
|
elif items <= 0:
|
|
print("WARN no recommended items")
|
|
else:
|
|
print("VERIFY PASS")
|
|
"""
|
|
|
|
sftp = c.open_sftp()
|
|
with sftp.open("/tmp/verify_symbol_js.py", "w") as f:
|
|
f.write(VERIFY)
|
|
sftp.close()
|
|
_, o, e = c.exec_command("cd /opt/qihuo && /opt/qihuo/venv/bin/python /tmp/verify_symbol_js.py")
|
|
print(o.read().decode("utf-8", errors="replace"))
|
|
print(e.read().decode("utf-8", errors="replace"))
|
|
c.close()
|