调整逻辑。临时提交
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -19,6 +19,7 @@ var/
|
|||||||
*.egg-info/
|
*.egg-info/
|
||||||
.installed.cfg
|
.installed.cfg
|
||||||
*.egg
|
*.egg
|
||||||
|
out/
|
||||||
|
|
||||||
# PyInstaller
|
# PyInstaller
|
||||||
# Usually these files are written by a python script from a template
|
# Usually these files are written by a python script from a template
|
||||||
|
|||||||
67
.idea/workspace.xml
generated
67
.idea/workspace.xml
generated
@@ -5,68 +5,13 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="eceeff5e-51c1-459c-a911-d21ec090a423" name="Changes" comment="">
|
<list default="true" id="eceeff5e-51c1-459c-a911-d21ec090a423" name="Changes" comment="">
|
||||||
|
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Entity/Variables.py" beforeDir="false" afterPath="$PROJECT_DIR$/Entity/Variables.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Module/DeviceInfo.py" beforeDir="false" afterPath="$PROJECT_DIR$/Module/DeviceInfo.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Module/DeviceInfo.py" beforeDir="false" afterPath="$PROJECT_DIR$/Module/DeviceInfo.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Module/FlaskService.py" beforeDir="false" afterPath="$PROJECT_DIR$/Module/FlaskService.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Module/FlaskService.py" beforeDir="false" afterPath="$PROJECT_DIR$/Module/FlaskService.py" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Utils/LogManager.py" beforeDir="false" afterPath="$PROJECT_DIR$/Utils/LogManager.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Utils/Requester.py" beforeDir="false" afterPath="$PROJECT_DIR$/Utils/Requester.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Utils/Requester.py" beforeDir="false" afterPath="$PROJECT_DIR$/Utils/Requester.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/IOSAI.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/certifi/cacert.pem" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/cv2/opencv_videoio_ffmpeg4120_64.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/jaraco/text/Lorem ipsum.txt" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/libcrypto-3.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/libffi-8.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/libssl-3.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/numpy.libs/libscipy_openblas64_-43e11ff0749b8cbe0a615c9cf6737e0e.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/numpy.libs/msvcp140-263139962577ecda4cd9469ca360a746.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/python3.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/python312.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/pythoncom312.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/pywintypes312.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/add.png" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/advertisement.png" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/back.png" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/comment.png" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/icon.ico" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/bz2.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/getopt.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevice_id.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevicebackup.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevicebackup2.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevicebtlogger.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevicecrashreport.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevicedate.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevicedebug.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevicedebugserverproxy.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevicedevmodectl.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevicediagnostics.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/ideviceenterrecovery.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/ideviceimagemounter.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/ideviceinfo.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevicename.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevicenotificationproxy.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevicepair.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/ideviceprovision.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevicerestore.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevicescreenshot.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevicesetlocation.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/idevicesyslog.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/inetcat.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/iproxy.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/irecovery.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/libcrypto-3.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/libcurl.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/libssl-3.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/plistutil.exe" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/readline.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/zip.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/iproxy/zlib1.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/like.png" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/search.png" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/tcl86t.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/tk86t.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/vcruntime140.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/vcruntime140_1.dll" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/out/Main.dist/zlib1.dll" beforeDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -153,7 +98,9 @@
|
|||||||
<workItem from="1755259951484" duration="5216000" />
|
<workItem from="1755259951484" duration="5216000" />
|
||||||
<workItem from="1755265222367" duration="2238000" />
|
<workItem from="1755265222367" duration="2238000" />
|
||||||
<workItem from="1755494675056" duration="9621000" />
|
<workItem from="1755494675056" duration="9621000" />
|
||||||
<workItem from="1755512435623" duration="2909000" />
|
<workItem from="1755512435623" duration="6297000" />
|
||||||
|
<workItem from="1755520236323" duration="4470000" />
|
||||||
|
<workItem from="1755526764397" duration="34000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
@@ -161,6 +108,6 @@
|
|||||||
<option name="version" value="3" />
|
<option name="version" value="3" />
|
||||||
</component>
|
</component>
|
||||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||||
<SUITE FILE_PATH="coverage/iOSAI$Main.coverage" NAME="Main Coverage Results" MODIFIED="1755515386914" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
|
<SUITE FILE_PATH="coverage/iOSAI$Main.coverage" NAME="Main Coverage Results" MODIFIED="1755525511400" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -9,8 +9,6 @@ WdaAppBundleId = "com.vv.wda.xctrunner"
|
|||||||
anchorList: list[AnchorModel] = []
|
anchorList: list[AnchorModel] = []
|
||||||
# 线程锁
|
# 线程锁
|
||||||
anchorListLock = threading.Lock()
|
anchorListLock = threading.Lock()
|
||||||
# 账号token
|
|
||||||
accountToken = "xHtil6YiAH2QxDgAYVwCfVafx7xkOoeHVfiVgfqfdwe88KZW5jbRsjDS9ZGFILJSGuXTu4V29MgHaYnO3jy2dxpqs77DtAQGnW6AlJ7NItSWSmSaoKRXtCYEng9KlCft"
|
|
||||||
# 打招呼数据
|
# 打招呼数据
|
||||||
prologueList = []
|
prologueList = []
|
||||||
# 评论列表
|
# 评论列表
|
||||||
|
|||||||
@@ -31,6 +31,68 @@ class Deviceinfo(object):
|
|||||||
self.manager = FlaskSubprocessManager.get_instance()
|
self.manager = FlaskSubprocessManager.get_instance()
|
||||||
# 已发给前端的设备模型列表(用于拔出时发 type=2)
|
# 已发给前端的设备模型列表(用于拔出时发 type=2)
|
||||||
self.deviceModelList: List[DeviceModel] = []
|
self.deviceModelList: List[DeviceModel] = []
|
||||||
|
# 最大可连接设备限制
|
||||||
|
self.maxDeviceCount = 6
|
||||||
|
|
||||||
|
# ===== iproxy:一次性完成 路径定位 + 环境变量配置 + 启动器准备 =====
|
||||||
|
try:
|
||||||
|
self.iproxy_path = self._iproxy_path() # 绝对路径
|
||||||
|
self.iproxy_dir = self.iproxy_path.parent
|
||||||
|
|
||||||
|
# 1) 配置环境(PATH/DLL),放到初始化里一次性处理
|
||||||
|
os.environ["PATH"] = str(self.iproxy_dir) + os.pathsep + os.environ.get("PATH", "")
|
||||||
|
try:
|
||||||
|
# 仅 Windows 有效;其他平台忽略
|
||||||
|
os.add_dll_directory(str(self.iproxy_dir))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# 2) 预构建通用 Popen 参数(隐藏窗口、工作目录、文本模式等)
|
||||||
|
self._creationflags = 0x08000000 if os.name == "nt" else 0
|
||||||
|
self._popen_kwargs = dict(
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
cwd=str(self.iproxy_dir),
|
||||||
|
shell=False,
|
||||||
|
text=True,
|
||||||
|
encoding="utf-8",
|
||||||
|
bufsize=1,
|
||||||
|
creationflags=self._creationflags,
|
||||||
|
)
|
||||||
|
|
||||||
|
# 3) 准备一个“启动器”(闭包):仅接受 (udid, local_port, remote_port) 参数
|
||||||
|
def _spawn_iproxy(udid: str, local_port: int, remote_port: int = 9100) -> subprocess.Popen:
|
||||||
|
args = [str(self.iproxy_path), "-u", udid, str(local_port), str(remote_port)]
|
||||||
|
p = subprocess.Popen(args, **self._popen_kwargs)
|
||||||
|
|
||||||
|
# 异步日志转发(可选)
|
||||||
|
def _pipe_to_log(name: str, stream):
|
||||||
|
try:
|
||||||
|
for line in iter(stream.readline, ''):
|
||||||
|
s = line.strip()
|
||||||
|
if s:
|
||||||
|
LogManager.info(f"[iproxy {name}] {s}", udid)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
import threading
|
||||||
|
threading.Thread(target=_pipe_to_log, args=("STDOUT", p.stdout), daemon=True).start()
|
||||||
|
threading.Thread(target=_pipe_to_log, args=("STDERR", p.stderr), daemon=True).start()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return p
|
||||||
|
|
||||||
|
self._spawn_iproxy = _spawn_iproxy # 保存启动器
|
||||||
|
LogManager.info(f"iproxy 启动器已就绪,目录: {self.iproxy_dir}")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
# 没找到 iproxy 也允许实例化成功,但后续启动会失败并给出明确日志
|
||||||
|
self.iproxy_path = None
|
||||||
|
self.iproxy_dir = None
|
||||||
|
self._spawn_iproxy = None
|
||||||
|
LogManager.error(f"初始化 iproxy 失败:{e}")
|
||||||
|
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
# 监听设备连接(死循环,内部捕获异常)
|
# 监听设备连接(死循环,内部捕获异常)
|
||||||
@@ -42,13 +104,13 @@ class Deviceinfo(object):
|
|||||||
lists = Usbmux().device_list()
|
lists = Usbmux().device_list()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# 另一台电脑常见:usbmuxd 连接失败(未安装 iTunes/Apple Mobile Device Support)
|
# 另一台电脑常见:usbmuxd 连接失败(未安装 iTunes/Apple Mobile Device Support)
|
||||||
LogManager.warning(f"usbmuxd 连接失败: {e}。请确认已安装 iTunes/Apple Mobile Device Support,并在手机上“信任此电脑”", "listener")
|
LogManager.warning(f"usbmuxd 连接失败: {e}。请确认已安装 iTunes/Apple Mobile Device Support,并在手机上“信任此电脑”")
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 新接入设备
|
# 新接入设备
|
||||||
for device in lists:
|
for device in lists:
|
||||||
if device not in self.deviceArray:
|
if (device not in self.deviceArray) and (len(self.deviceArray) < self.maxDeviceCount):
|
||||||
self.screenProxy += 1
|
self.screenProxy += 1
|
||||||
try:
|
try:
|
||||||
self.connectDevice(device.udid)
|
self.connectDevice(device.udid)
|
||||||
@@ -143,91 +205,33 @@ class Deviceinfo(object):
|
|||||||
# 根目录与 iproxy 可执行文件定位
|
# 根目录与 iproxy 可执行文件定位
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
def _base_dir(self) -> Path:
|
def _base_dir(self) -> Path:
|
||||||
"""
|
|
||||||
打包后:返回 exe 所在目录;
|
|
||||||
源码运行:返回项目根目录(Module 的上一级)
|
|
||||||
"""
|
|
||||||
if getattr(sys, "frozen", False):
|
if getattr(sys, "frozen", False):
|
||||||
return Path(sys.executable).resolve().parent
|
return Path(sys.executable).resolve().parent
|
||||||
return Path(__file__).resolve().parents[1] # iOSAI/ 作为根
|
return Path(__file__).resolve().parents[1] # iOSAI/ 作为根
|
||||||
|
|
||||||
def _iproxy_path(self) -> Path:
|
def _iproxy_path(self) -> Path:
|
||||||
"""返回 iproxy 可执行文件的完整路径"""
|
|
||||||
exe = "iproxy.exe" if os.name == "nt" else "iproxy"
|
exe = "iproxy.exe" if os.name == "nt" else "iproxy"
|
||||||
base = self._base_dir()
|
base = self._base_dir()
|
||||||
# 常见放置位置(按优先级)
|
|
||||||
candidates = [
|
candidates = [
|
||||||
base / "resources" / "iproxy" / exe # 推荐:打包资源目录
|
base / "resources" / "iproxy" / exe, # 推荐放置
|
||||||
]
|
]
|
||||||
for p in candidates:
|
for p in candidates:
|
||||||
if p.exists():
|
if p.exists():
|
||||||
return p
|
return p
|
||||||
|
raise FileNotFoundError(f"iproxy not found, tried: {[str(c) for c in candidates]}")
|
||||||
tried = [str(c) for c in candidates]
|
|
||||||
raise FileNotFoundError(f"iproxy not found, tried: {tried}")
|
|
||||||
|
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
# 端口映射:启动 iproxy
|
# 端口映射:仅做“转发端口”这件事(调用已准备好的启动器)
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
def relayDeviceScreenPort(self, udid: str) -> Optional[subprocess.Popen]:
|
def relayDeviceScreenPort(self, udid: str) -> Optional[subprocess.Popen]:
|
||||||
|
if not self._spawn_iproxy:
|
||||||
|
LogManager.error("iproxy 启动器未就绪,无法建立端口映射(初始化时未找到 iproxy)。", udid)
|
||||||
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
iproxy = self._iproxy_path() # 例如 .../resources/iproxy/iproxy.exe
|
p = self._spawn_iproxy(udid, self.screenProxy, 9100)
|
||||||
iproxy_dir = iproxy.parent
|
|
||||||
|
|
||||||
# 继承环境并把 iproxy 目录加入 PATH(放最前)
|
|
||||||
env = os.environ.copy()
|
|
||||||
env["PATH"] = str(iproxy_dir) + os.pathsep + env.get("PATH", "")
|
|
||||||
|
|
||||||
# 可选:帮助本进程解析该目录下 DLL(py3.8+)
|
|
||||||
try:
|
|
||||||
os.add_dll_directory(str(iproxy_dir))
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Windows 隐藏子进程窗口
|
|
||||||
creationflags = 0x08000000 if os.name == "nt" else 0
|
|
||||||
|
|
||||||
# 绝对路径 + shell=False,避免 PATH/别名干扰
|
|
||||||
args = [str(iproxy), "-u", udid, str(self.screenProxy), "9100"]
|
|
||||||
|
|
||||||
|
|
||||||
# (可选)把子进程输出写到你的日志里,排查更方便
|
|
||||||
def _pipe_to_log(name: str, stream):
|
|
||||||
try:
|
|
||||||
for line in iter(stream.readline, ''):
|
|
||||||
line = line.rstrip('\r\n')
|
|
||||||
if line:
|
|
||||||
LogManager.info(f"[iproxy {name}] {line}", udid)
|
|
||||||
except Exception:
|
|
||||||
print("遇到错误了")
|
|
||||||
pass
|
|
||||||
|
|
||||||
p = subprocess.Popen(
|
|
||||||
args,
|
|
||||||
stdout=subprocess.PIPE,
|
|
||||||
stderr=subprocess.PIPE,
|
|
||||||
cwd=str(iproxy_dir),
|
|
||||||
env=env,
|
|
||||||
shell=False,
|
|
||||||
text=True,
|
|
||||||
encoding="utf-8",
|
|
||||||
bufsize=1,
|
|
||||||
creationflags=creationflags,
|
|
||||||
)
|
|
||||||
|
|
||||||
# 启动异步日志转发(不要阻塞主线程;需要时可删除)
|
|
||||||
try:
|
|
||||||
import threading
|
|
||||||
threading.Thread(target=_pipe_to_log, args=("STDOUT", p.stdout), daemon=True).start()
|
|
||||||
threading.Thread(target=_pipe_to_log, args=("STDERR", p.stderr), daemon=True).start()
|
|
||||||
except Exception as e:
|
|
||||||
print("这里有错误")
|
|
||||||
print(e)
|
|
||||||
pass
|
|
||||||
|
|
||||||
LogManager.info(f"启动 iproxy 成功,本地 {self.screenProxy} -> 设备 9100", udid)
|
LogManager.info(f"启动 iproxy 成功,本地 {self.screenProxy} -> 设备 9100", udid)
|
||||||
return p
|
return p
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LogManager.error(f"启动 iproxy 失败:{e}", udid)
|
LogManager.error(f"启动 iproxy 失败:{e}", udid)
|
||||||
return None
|
return None
|
||||||
@@ -16,7 +16,6 @@ from Entity.ResultData import ResultData
|
|||||||
from Utils.ControlUtils import ControlUtils
|
from Utils.ControlUtils import ControlUtils
|
||||||
from Utils.ThreadManager import ThreadManager
|
from Utils.ThreadManager import ThreadManager
|
||||||
from script.ScriptManager import ScriptManager
|
from script.ScriptManager import ScriptManager
|
||||||
from Entity.Variables import accountToken
|
|
||||||
from Entity.Variables import anchorList, addModelToAnchorList
|
from Entity.Variables import anchorList, addModelToAnchorList
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@@ -75,28 +74,41 @@ listener_thread.start()
|
|||||||
|
|
||||||
@app.route('/passToken', methods=['POST'])
|
@app.route('/passToken', methods=['POST'])
|
||||||
def passToken():
|
def passToken():
|
||||||
|
try:
|
||||||
|
data = request.get_json()
|
||||||
|
token = data['token']
|
||||||
|
Requester.requestPrologue(token)
|
||||||
|
return ResultData(data="").toJson()
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
return ResultData(data="").toJson()
|
||||||
|
|
||||||
|
@app.route('/getName', methods=['POST'])
|
||||||
|
def getName():
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
accountToken = data['token']
|
accountToken = data['token']
|
||||||
print(accountToken)
|
print(accountToken)
|
||||||
|
return accountToken
|
||||||
|
|
||||||
Requester.requestPrologue()
|
|
||||||
return ResultData(data="").toJson()
|
|
||||||
|
|
||||||
|
|
||||||
# 获取设备列表
|
# 获取设备列表
|
||||||
@app.route('/deviceList', methods=['GET'])
|
@app.route('/deviceList', methods=['GET'])
|
||||||
def deviceList():
|
def deviceList():
|
||||||
while not dataQueue.empty():
|
try:
|
||||||
obj = dataQueue.get()
|
while not dataQueue.empty():
|
||||||
type = obj["type"]
|
obj = dataQueue.get()
|
||||||
if type == 1:
|
type = obj["type"]
|
||||||
listData.append(obj)
|
if type == 1:
|
||||||
else:
|
listData.append(obj)
|
||||||
for data in listData:
|
else:
|
||||||
if data.get("deviceId") == obj.get("deviceId") and data.get("screenPort") == obj.get("screenPort"):
|
for data in listData:
|
||||||
listData.remove(data)
|
if data.get("deviceId") == obj.get("deviceId") and data.get("screenPort") == obj.get("screenPort"):
|
||||||
return ResultData(data=listData).toJson()
|
listData.remove(data)
|
||||||
|
return ResultData(data=listData).toJson()
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
return ResultData(data=[]).toJson()
|
||||||
|
|
||||||
# 获取设备应用列表
|
# 获取设备应用列表
|
||||||
@app.route('/deviceAppList', methods=['POST'])
|
@app.route('/deviceAppList', methods=['POST'])
|
||||||
|
|||||||
@@ -41,15 +41,15 @@ class LogManager:
|
|||||||
return logger
|
return logger
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def info(cls, text, udid):
|
def info(cls, text, udid="system"):
|
||||||
cls._setupLogger(udid, "infoLogger", "info.log", level=logging.INFO).info(f"[{udid}] {text}")
|
cls._setupLogger(udid, "infoLogger", "info.log", level=logging.INFO).info(f"[{udid}] {text}")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def warning(cls, text, udid):
|
def warning(cls, text, udid="system"):
|
||||||
cls._setupLogger(udid, "warningLogger", "warning.log", level=logging.WARNING).warning(f"[{udid}] {text}")
|
cls._setupLogger(udid, "warningLogger", "warning.log", level=logging.WARNING).warning(f"[{udid}] {text}")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def error(cls, text, udid):
|
def error(cls, text, udid="system"):
|
||||||
cls._setupLogger(udid, "errorLogger", "error.log", level=logging.ERROR).error(f"[{udid}] {text}")
|
cls._setupLogger(udid, "errorLogger", "error.log", level=logging.ERROR).error(f"[{udid}] {text}")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import requests
|
import requests
|
||||||
from Entity.Variables import accountToken, prologueList
|
from Entity.Variables import prologueList
|
||||||
|
|
||||||
BaseUrl = "https://crawlclient.api.yolozs.com/api/common/"
|
BaseUrl = "https://crawlclient.api.yolozs.com/api/common/"
|
||||||
# BaseUrl = "http://192.168.1.174:8101/api/common/"
|
# BaseUrl = "http://192.168.1.174:8101/api/common/"
|
||||||
@@ -10,9 +10,9 @@ class Requester():
|
|||||||
prologue = "prologue"
|
prologue = "prologue"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def requestPrologue(cls):
|
def requestPrologue(cls, token):
|
||||||
headers = {
|
headers = {
|
||||||
"vvtoken": accountToken,
|
"vvtoken": token,
|
||||||
}
|
}
|
||||||
url = BaseUrl + cls.prologue
|
url = BaseUrl + cls.prologue
|
||||||
result = requests.get(headers=headers, url=url)
|
result = requests.get(headers=headers, url=url)
|
||||||
|
|||||||
Reference in New Issue
Block a user