Merge remote-tracking branch 'origin/main'

# Conflicts:
#	.idea/workspace.xml
This commit is contained in:
2025-09-03 19:03:57 +08:00
10 changed files with 135 additions and 179 deletions

38
script/mac_wda_agent.py Normal file
View File

@@ -0,0 +1,38 @@
# windows_run.py替换你起 iproxy 的那几行)
import os, subprocess, time, requests, wda
from pathlib import Path
UDID = "00008110-00067D0014D3B01E"
MAC = "http://192.168.1.219:8765"
# 让 Mac 起 WDA不转发
requests.post(f"{MAC}/startWDA", json={"udid": UDID}, timeout=600).raise_for_status()
# 计算 iproxy 绝对路径(项目根/resources/iproxy/iproxy.exe
BASE = Path(__file__).resolve().parents[1] # iOSAI/
IPROXY = BASE / "resources" / "iproxy" / "iproxy.exe"
if not IPROXY.exists():
raise FileNotFoundError(f"iproxy 不在这里: {IPROXY}")
# 可选:把 iproxy 目录加入 PATH避免 DLL 依赖找不到
env = os.environ.copy()
env["PATH"] = str(IPROXY.parent) + os.pathsep + env.get("PATH", "")
try:
os.add_dll_directory(str(IPROXY.parent)) # 仅 Windows 有效
except Exception:
pass
# 起 iproxy本地 9111 -> 设备 8100
p = subprocess.Popen([str(IPROXY), "-u", UDID, "9111", "8100"],
cwd=str(IPROXY.parent),
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
text=True, creationflags=0x08000000)
# 探活 WDA
c = wda.Client("http://127.0.0.1:9111")
for _ in range(120):
try:
print(c.status()); break
except:
time.sleep(1)

35
script/windows_run.py Normal file
View File

@@ -0,0 +1,35 @@
from pathlib import Path
import os, subprocess, time, requests, wda
UDID = "00008110-00067D0014D3B01E"
MAC = "http://192.168.1.90:8765"
# 让 Mac 起 WDA
requests.post(f"{MAC}/startWDA", json={"udid": UDID}, timeout=600).raise_for_status()
# 计算 iproxy 绝对路径:项目根/resources/iproxy/iproxy.exe
BASE = Path(__file__).resolve().parents[1] # iOSAI/
IPROXY = BASE / "resources" / "iproxy" / "iproxy.exe"
if not IPROXY.exists():
raise FileNotFoundError(f"iproxy 不在这里:{IPROXY}")
# 避免 DLL 找不到:把目录加入 PATH以及 Windows 的 DLL 搜索路径)
env = os.environ.copy()
env["PATH"] = str(IPROXY.parent) + os.pathsep + env.get("PATH", "")
try:
os.add_dll_directory(str(IPROXY.parent))
except Exception:
pass
# 起 iproxy本地 9111 -> 设备 8100
p = subprocess.Popen([str(IPROXY), "-u", UDID, "9111", "8100"],
cwd=str(IPROXY.parent),
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
# 探活 WDA
c = wda.Client("http://127.0.0.1:9111")
for _ in range(120):
try:
print(c.status()); break
except Exception:
time.sleep(1)