fix: 修复更新时主程序退出不彻底与ADB路径与模拟器路径相关问题
This commit is contained in:
@@ -606,7 +606,7 @@ class MaaUserConfig(QConfig):
|
|||||||
|
|
||||||
class AppConfig(GlobalConfig):
|
class AppConfig(GlobalConfig):
|
||||||
|
|
||||||
VERSION = "4.3.4.3"
|
VERSION = "4.3.4.4"
|
||||||
|
|
||||||
gameid_refreshed = Signal()
|
gameid_refreshed = Signal()
|
||||||
PASSWORD_refreshed = Signal()
|
PASSWORD_refreshed = Signal()
|
||||||
|
|||||||
@@ -287,6 +287,11 @@ class MaaManager(QObject):
|
|||||||
self.ADB_path = Path(
|
self.ADB_path = Path(
|
||||||
set["Configurations"]["Default"]["Connect.AdbPath"]
|
set["Configurations"]["Default"]["Connect.AdbPath"]
|
||||||
)
|
)
|
||||||
|
self.ADB_path = (
|
||||||
|
self.ADB_path
|
||||||
|
if self.ADB_path.is_absolute()
|
||||||
|
else self.maa_root_path / self.ADB_path
|
||||||
|
)
|
||||||
self.ADB_address = set["Configurations"]["Default"][
|
self.ADB_address = set["Configurations"]["Default"][
|
||||||
"Connect.Address"
|
"Connect.Address"
|
||||||
]
|
]
|
||||||
@@ -300,8 +305,6 @@ class MaaManager(QObject):
|
|||||||
]
|
]
|
||||||
== "True"
|
== "True"
|
||||||
)
|
)
|
||||||
# 添加静默进程标记
|
|
||||||
Config.silence_list.append(self.emulator_path)
|
|
||||||
|
|
||||||
# 增强任务:任务开始前强杀ADB
|
# 增强任务:任务开始前强杀ADB
|
||||||
if "ADB" in self.set["RunSet"]["EnhanceTask"]:
|
if "ADB" in self.set["RunSet"]["EnhanceTask"]:
|
||||||
@@ -315,12 +318,34 @@ class MaaManager(QObject):
|
|||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
# 忽略错误,因为可能本来就没有连接
|
# 忽略错误,因为可能本来就没有连接
|
||||||
logger.warning(f"{self.name} | 释放ADB时出现异常:{e}")
|
logger.warning(f"{self.name} | 释放ADB时出现异常:{e}")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"{self.name} | 释放ADB时出现异常:{e}")
|
||||||
|
self.push_info_bar.emit(
|
||||||
|
"error",
|
||||||
|
"释放ADB时出现异常",
|
||||||
|
"请检查MAA中ADB路径设置",
|
||||||
|
-1,
|
||||||
|
)
|
||||||
|
|
||||||
if self.if_open_emulator_process:
|
if self.if_open_emulator_process:
|
||||||
self.emulator_process = subprocess.Popen(
|
try:
|
||||||
[self.emulator_path, *self.emulator_arguments],
|
self.emulator_process = subprocess.Popen(
|
||||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
[self.emulator_path, *self.emulator_arguments],
|
||||||
)
|
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"{self.name} | 启动模拟器时出现异常:{e}")
|
||||||
|
self.push_info_bar.emit(
|
||||||
|
"error",
|
||||||
|
"启动模拟器时出现异常",
|
||||||
|
"请检查MAA中模拟器路径设置",
|
||||||
|
-1,
|
||||||
|
)
|
||||||
|
self.if_open_emulator = True
|
||||||
|
break
|
||||||
|
|
||||||
|
# 添加静默进程标记
|
||||||
|
Config.silence_list.append(self.emulator_path)
|
||||||
|
|
||||||
# 创建MAA任务
|
# 创建MAA任务
|
||||||
maa = subprocess.Popen(
|
maa = subprocess.Popen(
|
||||||
@@ -388,6 +413,14 @@ class MaaManager(QObject):
|
|||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
# 忽略错误,因为可能本来就没有连接
|
# 忽略错误,因为可能本来就没有连接
|
||||||
logger.warning(f"{self.name} | 释放ADB时出现异常:{e}")
|
logger.warning(f"{self.name} | 释放ADB时出现异常:{e}")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"{self.name} | 释放ADB时出现异常:{e}")
|
||||||
|
self.push_info_bar.emit(
|
||||||
|
"error",
|
||||||
|
"释放ADB时出现异常",
|
||||||
|
"请检查MAA中ADB路径设置",
|
||||||
|
-1,
|
||||||
|
)
|
||||||
if self.if_kill_emulator:
|
if self.if_kill_emulator:
|
||||||
if "Emulator" in self.set["RunSet"]["EnhanceTask"]:
|
if "Emulator" in self.set["RunSet"]["EnhanceTask"]:
|
||||||
System.kill_process(self.emulator_path)
|
System.kill_process(self.emulator_path)
|
||||||
|
|||||||
@@ -26,13 +26,12 @@ v4.3
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from PySide6.QtWidgets import QWidget, QVBoxLayout
|
from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout
|
||||||
from PySide6.QtCore import Qt
|
from PySide6.QtCore import Qt
|
||||||
from qfluentwidgets import (
|
from qfluentwidgets import (
|
||||||
ScrollArea,
|
ScrollArea,
|
||||||
FluentIcon,
|
FluentIcon,
|
||||||
MessageBox,
|
MessageBox,
|
||||||
Dialog,
|
|
||||||
HyperlinkCard,
|
HyperlinkCard,
|
||||||
HeaderCardWidget,
|
HeaderCardWidget,
|
||||||
ExpandGroupSettingCard,
|
ExpandGroupSettingCard,
|
||||||
@@ -42,13 +41,12 @@ from qfluentwidgets import (
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
import time
|
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from packaging import version
|
from packaging import version
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, List, Union
|
from typing import Dict, Union
|
||||||
|
|
||||||
from app.core import Config, MainInfoBar, Network
|
from app.core import Config, MainInfoBar, Network
|
||||||
from app.services import Crypto, System, Notify
|
from app.services import Crypto, System, Notify
|
||||||
@@ -405,9 +403,12 @@ class Setting(QWidget):
|
|||||||
|
|
||||||
subprocess.Popen(
|
subprocess.Popen(
|
||||||
[Config.app_path / "AUTO_Updater.active.exe"],
|
[Config.app_path / "AUTO_Updater.active.exe"],
|
||||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP
|
||||||
|
| subprocess.DETACHED_PROCESS
|
||||||
|
| subprocess.CREATE_NO_WINDOW,
|
||||||
)
|
)
|
||||||
self.window().close()
|
self.window().close()
|
||||||
|
QApplication.quit()
|
||||||
|
|
||||||
# 无版本更新
|
# 无版本更新
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import zipfile
|
|||||||
import requests
|
import requests
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
import psutil
|
||||||
import win32crypt
|
import win32crypt
|
||||||
import base64
|
import base64
|
||||||
from packaging import version
|
from packaging import version
|
||||||
@@ -180,7 +181,11 @@ class ZipExtractProcess(QThread):
|
|||||||
self.accomplish.emit()
|
self.accomplish.emit()
|
||||||
break
|
break
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
self.info.emit(f"解压出错:{self.name}正在运行,正在等待其关闭")
|
if self.name == "AUTO_MAA":
|
||||||
|
self.info.emit(f"解压出错:AUTO_MAA正在运行,正在尝试将其关闭")
|
||||||
|
self.kill_process(self.app_path / "AUTO_MAA.exe")
|
||||||
|
else:
|
||||||
|
self.info.emit(f"解压出错:{self.name}正在运行,正在等待其关闭")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -190,6 +195,30 @@ class ZipExtractProcess(QThread):
|
|||||||
self.info.emit(f"解压更新时出错:\n{e}")
|
self.info.emit(f"解压更新时出错:\n{e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def kill_process(self, path: Path) -> None:
|
||||||
|
"""根据路径中止进程"""
|
||||||
|
|
||||||
|
for pid in self.search_pids(path):
|
||||||
|
killprocess = subprocess.Popen(
|
||||||
|
f"taskkill /F /PID {pid}",
|
||||||
|
shell=True,
|
||||||
|
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||||
|
)
|
||||||
|
killprocess.wait()
|
||||||
|
|
||||||
|
def search_pids(self, path: Path) -> list:
|
||||||
|
"""根据路径查找进程PID"""
|
||||||
|
|
||||||
|
pids = []
|
||||||
|
for proc in psutil.process_iter(["pid", "exe"]):
|
||||||
|
try:
|
||||||
|
if proc.info["exe"] and proc.info["exe"].lower() == str(path).lower():
|
||||||
|
pids.append(proc.info["pid"])
|
||||||
|
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
|
||||||
|
# 进程可能在此期间已结束或无法访问,忽略这些异常
|
||||||
|
pass
|
||||||
|
return pids
|
||||||
|
|
||||||
|
|
||||||
class DownloadManager(QDialog):
|
class DownloadManager(QDialog):
|
||||||
"""下载管理器"""
|
"""下载管理器"""
|
||||||
@@ -518,7 +547,8 @@ class DownloadManager(QDialog):
|
|||||||
|
|
||||||
if "deleted" in info:
|
if "deleted" in info:
|
||||||
for file_path in info["deleted"]:
|
for file_path in info["deleted"]:
|
||||||
(self.app_path / file_path).unlink()
|
if (self.app_path / file_path).exists():
|
||||||
|
(self.app_path / file_path).unlink()
|
||||||
|
|
||||||
(self.app_path / "changes.json").unlink()
|
(self.app_path / "changes.json").unlink()
|
||||||
|
|
||||||
@@ -531,12 +561,16 @@ class DownloadManager(QDialog):
|
|||||||
if not self.isInterruptionRequested and self.name == "AUTO_MAA":
|
if not self.isInterruptionRequested and self.name == "AUTO_MAA":
|
||||||
subprocess.Popen(
|
subprocess.Popen(
|
||||||
[self.app_path / "AUTO_MAA.exe"],
|
[self.app_path / "AUTO_MAA.exe"],
|
||||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP
|
||||||
|
| subprocess.DETACHED_PROCESS
|
||||||
|
| subprocess.CREATE_NO_WINDOW,
|
||||||
)
|
)
|
||||||
elif not self.isInterruptionRequested and self.name == "MAA":
|
elif not self.isInterruptionRequested and self.name == "MAA":
|
||||||
subprocess.Popen(
|
subprocess.Popen(
|
||||||
[self.app_path / "MAA.exe"],
|
[self.app_path / "MAA.exe"],
|
||||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP
|
||||||
|
| subprocess.DETACHED_PROCESS
|
||||||
|
| subprocess.CREATE_NO_WINDOW,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.update_info(f"{self.name}更新成功!")
|
self.update_info(f"{self.name}更新成功!")
|
||||||
|
|||||||
@@ -1,8 +1,17 @@
|
|||||||
{
|
{
|
||||||
"main_version": "4.3.4.3",
|
"main_version": "4.3.4.4",
|
||||||
"updater_version": "1.0.0.0",
|
"updater_version": "1.0.0.0",
|
||||||
"announcement": "\n## 新增功能\n- 屏蔽MuMu模拟器开屏广告功能上线\n- 更新器支持多线程下载\n- 添加强制关闭ADB与模拟器等增强任务项\n## 修复BUG\n- 修复统计信息HTML模板公招匹配错误\n- 修复密码显示按钮动画异常\n- 修复`检测到MAA未能实际执行任务`报错被异常屏蔽\n- 修复MAA超时判定异常失效\n## 程序优化\n- 关机等电源操作添加100s倒计时\n- 人工排查弹窗方法优化\n- 人工排查时自动屏蔽静默操作\n- 公告样式优化",
|
"announcement": "\n## 新增功能\n- 屏蔽MuMu模拟器开屏广告功能上线\n- 更新器支持多线程下载\n- 添加强制关闭ADB与模拟器等增强任务项\n## 修复BUG\n- 修复统计信息HTML模板公招匹配错误\n- 修复密码显示按钮动画异常\n- 修复`检测到MAA未能实际执行任务`报错被异常屏蔽\n- 修复MAA超时判定异常失效\n## 程序优化\n- 关机等电源操作添加100s倒计时\n- 人工排查弹窗方法优化\n- 人工排查时自动屏蔽静默操作\n- 公告样式优化",
|
||||||
"version_info": {
|
"version_info": {
|
||||||
|
"4.3.4.4": {
|
||||||
|
"修复BUG": [
|
||||||
|
"修复更新时主程序退出不彻底"
|
||||||
|
],
|
||||||
|
"程序优化": [
|
||||||
|
"ADB路径与模拟器路径添加报错提示",
|
||||||
|
"ADB路径兼容相对路径"
|
||||||
|
]
|
||||||
|
},
|
||||||
"4.3.4.3": {
|
"4.3.4.3": {
|
||||||
"修复BUG": [
|
"修复BUG": [
|
||||||
"修复更新器使用mirrorc下载时删除已弃用的文件卡死"
|
"修复更新器使用mirrorc下载时删除已弃用的文件卡死"
|
||||||
|
|||||||
Reference in New Issue
Block a user