fix(general): 修复无成功日志时的脚本判定逻辑
This commit is contained in:
@@ -601,6 +601,9 @@ class GeneralConfig(LQConfig):
|
||||
"Script", "ScriptPath", ".", FileValidator()
|
||||
)
|
||||
self.Script_Arguments = ConfigItem("Script", "Arguments", "")
|
||||
self.Script_IfTrackProcess = ConfigItem(
|
||||
"Script", "IfTrackProcess", False, BoolValidator()
|
||||
)
|
||||
self.Script_ConfigPath = ConfigItem(
|
||||
"Script", "ConfigPath", ".", FileValidator()
|
||||
)
|
||||
|
||||
@@ -152,9 +152,11 @@ class GeneralManager(QObject):
|
||||
self.set["Script"]["LogTimeStart"] - 1,
|
||||
self.set["Script"]["LogTimeEnd"],
|
||||
]
|
||||
self.success_log = [
|
||||
_.strip() for _ in self.set["Script"]["SuccessLog"].split("|")
|
||||
]
|
||||
self.success_log = (
|
||||
[_.strip() for _ in self.set["Script"]["SuccessLog"].split("|")]
|
||||
if self.set["Script"]["SuccessLog"]
|
||||
else []
|
||||
)
|
||||
self.error_log = [_.strip() for _ in self.set["Script"]["ErrorLog"].split("|")]
|
||||
|
||||
def run(self):
|
||||
@@ -304,9 +306,13 @@ class GeneralManager(QObject):
|
||||
)
|
||||
|
||||
# 运行脚本任务
|
||||
logger.info(
|
||||
f"{self.name} | 运行脚本任务:{self.script_exe_path},参数:{self.set['Script']['Arguments']}"
|
||||
)
|
||||
self.script_process_manager.open_process(
|
||||
self.script_exe_path,
|
||||
str(self.set["Script"]["Arguments"]).split(" "),
|
||||
tracking_time=60 if self.set["Script"]["IfTrackProcess"] else 0,
|
||||
)
|
||||
|
||||
# 监测运行状态
|
||||
@@ -430,7 +436,10 @@ class GeneralManager(QObject):
|
||||
try:
|
||||
# 创建通用脚本任务
|
||||
logger.info(f"{self.name} | 无参数启动通用脚本:{self.script_exe_path}")
|
||||
self.script_process_manager.open_process(self.script_exe_path)
|
||||
self.script_process_manager.open_process(
|
||||
self.script_exe_path,
|
||||
tracking_time=60 if self.set["Script"]["IfTrackProcess"] else 0,
|
||||
)
|
||||
|
||||
# 记录当前时间
|
||||
start_time = datetime.now()
|
||||
|
||||
@@ -2339,6 +2339,14 @@ class MemberManager(QWidget):
|
||||
configItem=self.config.Script_Arguments,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfTrackProcess = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="追踪脚本子进程",
|
||||
content="启用后将在脚本启动后 60s 内追踪其子进程,并仅在所有子进程结束后判定脚本中止",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Script_IfTrackProcess,
|
||||
parent=self,
|
||||
)
|
||||
self.card_ConfigPath = PathSettingCard(
|
||||
icon=FluentIcon.FOLDER,
|
||||
title="脚本配置文件路径 - [必填]",
|
||||
@@ -2438,6 +2446,7 @@ class MemberManager(QWidget):
|
||||
Layout.addWidget(self.card_RootPath)
|
||||
Layout.addWidget(self.card_ScriptPath)
|
||||
Layout.addWidget(self.card_Arguments)
|
||||
Layout.addWidget(self.card_IfTrackProcess)
|
||||
Layout.addWidget(self.card_ConfigPath)
|
||||
Layout.addWidget(self.card_LogPath)
|
||||
Layout.addWidget(self.card_LogPathFormat)
|
||||
|
||||
@@ -65,6 +65,7 @@ class ProcessManager(QObject):
|
||||
|
||||
process = subprocess.Popen(
|
||||
[path, *args],
|
||||
cwd=path.parent,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||
stdin=subprocess.DEVNULL,
|
||||
stdout=subprocess.DEVNULL,
|
||||
@@ -93,8 +94,9 @@ class ProcessManager(QObject):
|
||||
self.tracked_pids.add(self.main_pid)
|
||||
|
||||
# 递归获取所有子进程
|
||||
for child in main_proc.children(recursive=True):
|
||||
self.tracked_pids.add(child.pid)
|
||||
if tracking_time:
|
||||
for child in main_proc.children(recursive=True):
|
||||
self.tracked_pids.add(child.pid)
|
||||
|
||||
except psutil.NoSuchProcess:
|
||||
pass
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"version_info": {
|
||||
"4.4.0.3": {
|
||||
"修复BUG": [
|
||||
"适配 MAA 备选关卡字段修改"
|
||||
"适配 MAA 备选关卡字段修改",
|
||||
"修复无成功日志时的脚本判定逻辑"
|
||||
],
|
||||
"程序优化": [
|
||||
"`GameId`字段改为 `Stage`,与 MAA 保持一致"
|
||||
|
||||
Reference in New Issue
Block a user