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