"""看设备上 show_ui.py 的实际大小 / 指纹,以及播种日志。""" import json import sys import urllib.request try: sys.stdout.reconfigure(encoding="utf-8", errors="replace") except Exception: pass URL = "http://127.0.0.1:15199" TOOLS = "/storage/emulated/0/Android/data/com.doubao.lynxclone/files/tools" def call(path, payload=None, method="POST", timeout=90): data = json.dumps(payload, ensure_ascii=False).encode("utf-8") if payload is not None else None req = urllib.request.Request( URL + path, data=data, method=method, headers={"Content-Type": "application/json; charset=utf-8"}, ) with urllib.request.urlopen(req, timeout=timeout) as r: return json.loads(r.read().decode("utf-8")) probe = r''' import os, sys, json, hashlib D = %r out = {"dir": D, "exists": os.path.isdir(D)} if os.path.isdir(D): files = [] for name in sorted(os.listdir(D)): p = os.path.join(D, name) if os.path.isfile(p): st = os.stat(p) item = {"name": name, "size": st.st_size, "mtime": st.st_mtime} if name.endswith(".py"): txt = open(p, encoding="utf-8", errors="replace").read() item["has_wait"] = "wait" in txt item["sha16"] = hashlib.sha256(txt.encode()).hexdigest()[:16] files.append(item) out["files"] = files sp = os.path.join(D, ".doubao-seed.json") if os.path.isfile(sp): out["stamp_exists"] = True out["stamp_show_ui"] = json.load(open(sp, encoding="utf-8")).get("show_ui.py") else: out["stamp_exists"] = False # 内嵌源码里的那份 try: import hashlib as _h import bundled_tool_sources src = bundled_tool_sources.sources().get("show_ui.py", "") out["bundled_len"] = len(src) out["bundled_sha16"] = _h.sha256(src.encode()).hexdigest()[:16] out["bundled_has_wait"] = "wait" in src except Exception as e: out["bundled_error"] = f"{type(e).__name__}: {e}" print(json.dumps(out, ensure_ascii=False, indent=1)) ''' % TOOLS res = call("/api/tools/run", {"name": "python_run", "args": {"code": probe, "timeout": 30}}, timeout=120) out = (res or {}).get("result") or {} print(out.get("stdout") or json.dumps(out, ensure_ascii=False)[:1500])