增加启动校验
This commit is contained in:
@@ -2,9 +2,6 @@ import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import wda
|
||||
|
||||
import tidevice
|
||||
from Module.DeviceInfo import DeviceInfo
|
||||
from Module.FlaskSubprocessManager import FlaskSubprocessManager
|
||||
from Utils.DevDiskImageDeployer import DevDiskImageDeployer
|
||||
@@ -27,32 +24,19 @@ if "--role=flask" in sys.argv:
|
||||
_run_flask_role()
|
||||
sys.exit(0)
|
||||
|
||||
def main(arg):
|
||||
print(arg)
|
||||
if len(arg) != 2:
|
||||
sys.exit(0)
|
||||
else:
|
||||
if arg[1] != "iosai":
|
||||
sys.exit(0)
|
||||
|
||||
# 项目入口
|
||||
if __name__ == "__main__":
|
||||
|
||||
wda.debug = True
|
||||
|
||||
# 1. 打包环境
|
||||
if hasattr(sys, '_MEIPASS'):
|
||||
base_dir = sys._MEIPASS
|
||||
# 2. 源码调试环境
|
||||
else:
|
||||
base_dir = os.path.dirname(
|
||||
os.path.dirname(os.path.abspath(__file__)) # 向上跳一级
|
||||
)
|
||||
|
||||
# 3. 拼 iproxy 目录
|
||||
iproxy_dir = os.path.join(base_dir, 'resources', 'iproxy')
|
||||
|
||||
# 4. 剩余逻辑不变
|
||||
if os.path.isdir(iproxy_dir):
|
||||
sep = os.pathsep
|
||||
old_path = os.environ.get('PATH', '')
|
||||
if iproxy_dir not in old_path:
|
||||
os.environ['PATH'] = old_path + sep + iproxy_dir
|
||||
else:
|
||||
print(f'warning: {iproxy_dir} not found', file=sys.stderr)
|
||||
# 获取启动时候传递的参数
|
||||
main(sys.argv)
|
||||
|
||||
# 添加iOS开发包到电脑上
|
||||
deployer = DevDiskImageDeployer(verbose=True)
|
||||
@@ -69,15 +53,13 @@ if __name__ == "__main__":
|
||||
except Exception as e:
|
||||
print("[WARN] Device listener not running:", e)
|
||||
|
||||
|
||||
# === 保活:阻塞主线程,直到收到 Ctrl+C/关闭 ===
|
||||
import threading, time, signal
|
||||
|
||||
stop = threading.Event()
|
||||
|
||||
def _handle(_sig, _frm):
|
||||
stop.set()
|
||||
|
||||
|
||||
# Windows 上 SIGINT/SIGTERM 都可以拦到
|
||||
try:
|
||||
signal.signal(signal.SIGINT, _handle)
|
||||
|
||||
Reference in New Issue
Block a user