feat(general): 通用脚本启动附加命令添加额外的语法以适应UI可执行文件与任务可执行文件不同的情况
This commit is contained in:
@@ -140,7 +140,35 @@ class GeneralManager(QObject):
|
|||||||
"""提取配置信息"""
|
"""提取配置信息"""
|
||||||
|
|
||||||
self.script_root_path = Path(self.set["Script"]["RootPath"])
|
self.script_root_path = Path(self.set["Script"]["RootPath"])
|
||||||
self.script_exe_path = Path(self.set["Script"]["ScriptPath"])
|
self.script_path = Path(self.set["Script"]["ScriptPath"])
|
||||||
|
|
||||||
|
arguments_list = []
|
||||||
|
path_list = []
|
||||||
|
|
||||||
|
for argument in [
|
||||||
|
_.strip()
|
||||||
|
for _ in str(self.set["Script"]["Arguments"]).split("|")
|
||||||
|
if _.strip()
|
||||||
|
]:
|
||||||
|
arg = [_.strip() for _ in argument.split("%") if _.strip()]
|
||||||
|
if len(arg) > 1:
|
||||||
|
path_list.append((self.script_path / arg[0]).resolve())
|
||||||
|
arguments_list.append(
|
||||||
|
[_.strip() for _ in arg[1].split(" ") if _.strip()]
|
||||||
|
)
|
||||||
|
elif len(arg) > 0:
|
||||||
|
path_list.append(self.script_path)
|
||||||
|
arguments_list.append(
|
||||||
|
[_.strip() for _ in arg[0].split(" ") if _.strip()]
|
||||||
|
)
|
||||||
|
|
||||||
|
self.script_exe_path = path_list[0] if len(path_list) > 0 else self.script_path
|
||||||
|
self.script_arguments = arguments_list[0] if len(arguments_list) > 0 else []
|
||||||
|
self.script_set_exe_path = (
|
||||||
|
path_list[1] if len(path_list) > 1 else self.script_path
|
||||||
|
)
|
||||||
|
self.script_set_arguments = arguments_list[1] if len(arguments_list) > 1 else []
|
||||||
|
|
||||||
self.script_config_path = Path(self.set["Script"]["ConfigPath"])
|
self.script_config_path = Path(self.set["Script"]["ConfigPath"])
|
||||||
self.script_log_path = (
|
self.script_log_path = (
|
||||||
Path(self.set["Script"]["LogPath"]).with_stem(
|
Path(self.set["Script"]["LogPath"]).with_stem(
|
||||||
@@ -353,12 +381,12 @@ class GeneralManager(QObject):
|
|||||||
|
|
||||||
# 运行脚本任务
|
# 运行脚本任务
|
||||||
logger.info(
|
logger.info(
|
||||||
f"运行脚本任务:{self.script_exe_path},参数:{self.set['Script']['Arguments']}",
|
f"运行脚本任务:{self.script_exe_path},参数:{self.script_arguments}",
|
||||||
module=f"通用调度器-{self.name}",
|
module=f"通用调度器-{self.name}",
|
||||||
)
|
)
|
||||||
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(" "),
|
self.script_arguments,
|
||||||
tracking_time=60 if self.set["Script"]["IfTrackProcess"] else 0,
|
tracking_time=60 if self.set["Script"]["IfTrackProcess"] else 0,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -437,6 +465,7 @@ class GeneralManager(QObject):
|
|||||||
module=f"通用调度器-{self.name}",
|
module=f"通用调度器-{self.name}",
|
||||||
)
|
)
|
||||||
self.script_process_manager.kill()
|
self.script_process_manager.kill()
|
||||||
|
System.kill_process(self.script_exe_path)
|
||||||
if self.set["Game"]["Enabled"]:
|
if self.set["Game"]["Enabled"]:
|
||||||
logger.info(
|
logger.info(
|
||||||
f"中止游戏/模拟器进程:{list(self.game_process_manager.tracked_pids)}",
|
f"中止游戏/模拟器进程:{list(self.game_process_manager.tracked_pids)}",
|
||||||
@@ -554,11 +583,12 @@ class GeneralManager(QObject):
|
|||||||
try:
|
try:
|
||||||
# 创建通用脚本任务
|
# 创建通用脚本任务
|
||||||
logger.info(
|
logger.info(
|
||||||
f"无参数启动通用脚本:{self.script_exe_path}",
|
f"运行脚本任务:{self.script_set_exe_path},参数:{self.script_set_arguments}",
|
||||||
module=f"通用调度器-{self.name}",
|
module=f"通用调度器-{self.name}",
|
||||||
)
|
)
|
||||||
self.script_process_manager.open_process(
|
self.script_process_manager.open_process(
|
||||||
self.script_exe_path,
|
self.script_set_exe_path,
|
||||||
|
self.script_set_arguments,
|
||||||
tracking_time=60 if self.set["Script"]["IfTrackProcess"] else 0,
|
tracking_time=60 if self.set["Script"]["IfTrackProcess"] else 0,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -913,7 +943,10 @@ class GeneralManager(QObject):
|
|||||||
logger.info(f"开始配置脚本运行参数:{index}", module=f"通用调度器-{self.name}")
|
logger.info(f"开始配置脚本运行参数:{index}", module=f"通用调度器-{self.name}")
|
||||||
|
|
||||||
# 配置前关闭可能未正常退出的脚本进程
|
# 配置前关闭可能未正常退出的脚本进程
|
||||||
System.kill_process(self.script_exe_path)
|
if self.mode == "自动代理":
|
||||||
|
System.kill_process(self.script_exe_path)
|
||||||
|
elif self.mode == "设置通用脚本":
|
||||||
|
System.kill_process(self.script_set_exe_path)
|
||||||
|
|
||||||
# 预导入配置文件
|
# 预导入配置文件
|
||||||
if self.mode == "设置通用脚本":
|
if self.mode == "设置通用脚本":
|
||||||
|
|||||||
@@ -2458,7 +2458,7 @@ class ScriptManager(QWidget):
|
|||||||
self.card_UpdateConfigMode = ComboBoxSettingCard(
|
self.card_UpdateConfigMode = ComboBoxSettingCard(
|
||||||
icon=FluentIcon.PAGE_RIGHT,
|
icon=FluentIcon.PAGE_RIGHT,
|
||||||
title="脚本配置文件更新时机",
|
title="脚本配置文件更新时机",
|
||||||
content="在选定的时机自动更新配置文件",
|
content="在选定的时机自动更新程序保存的配置文件",
|
||||||
texts=[
|
texts=[
|
||||||
"从不",
|
"从不",
|
||||||
"仅任务成功后",
|
"仅任务成功后",
|
||||||
@@ -2481,7 +2481,7 @@ class ScriptManager(QWidget):
|
|||||||
self.card_LogPathFormat = LineEditSettingCard(
|
self.card_LogPathFormat = LineEditSettingCard(
|
||||||
icon=FluentIcon.PAGE_RIGHT,
|
icon=FluentIcon.PAGE_RIGHT,
|
||||||
title="脚本日志文件名格式",
|
title="脚本日志文件名格式",
|
||||||
content="若脚本日志文件名中随时间变化,请填入时间格式,留空则不启用",
|
content="若脚本日志文件名中随时间变化,请填入时间格式文本,留空则不启用",
|
||||||
text="请输入脚本日志文件名格式",
|
text="请输入脚本日志文件名格式",
|
||||||
qconfig=self.config,
|
qconfig=self.config,
|
||||||
configItem=self.config.Script_LogPathFormat,
|
configItem=self.config.Script_LogPathFormat,
|
||||||
@@ -2489,8 +2489,8 @@ class ScriptManager(QWidget):
|
|||||||
)
|
)
|
||||||
self.card_LogTimeStart = SpinBoxSettingCard(
|
self.card_LogTimeStart = SpinBoxSettingCard(
|
||||||
icon=FluentIcon.PAGE_RIGHT,
|
icon=FluentIcon.PAGE_RIGHT,
|
||||||
title="脚本日志时间起始位置 - [必填]",
|
title="脚本日志时间戳起始位置 - [必填]",
|
||||||
content="脚本日志中时间的起始位置,单位为字符",
|
content="脚本日志中时间戳的起始位置,单位为字符",
|
||||||
range=(1, 1024),
|
range=(1, 1024),
|
||||||
qconfig=self.config,
|
qconfig=self.config,
|
||||||
configItem=self.config.Script_LogTimeStart,
|
configItem=self.config.Script_LogTimeStart,
|
||||||
@@ -2498,8 +2498,8 @@ class ScriptManager(QWidget):
|
|||||||
)
|
)
|
||||||
self.card_LogTimeEnd = SpinBoxSettingCard(
|
self.card_LogTimeEnd = SpinBoxSettingCard(
|
||||||
icon=FluentIcon.PAGE_RIGHT,
|
icon=FluentIcon.PAGE_RIGHT,
|
||||||
title="脚本日志时间结束位置 - [必填]",
|
title="脚本日志时间戳结束位置 - [必填]",
|
||||||
content="脚本日志中时间的结束位置,单位为字符",
|
content="脚本日志中时间戳的结束位置,单位为字符",
|
||||||
range=(1, 1024),
|
range=(1, 1024),
|
||||||
qconfig=self.config,
|
qconfig=self.config,
|
||||||
configItem=self.config.Script_LogTimeEnd,
|
configItem=self.config.Script_LogTimeEnd,
|
||||||
@@ -2507,8 +2507,8 @@ class ScriptManager(QWidget):
|
|||||||
)
|
)
|
||||||
self.card_LogTimeFormat = LineEditSettingCard(
|
self.card_LogTimeFormat = LineEditSettingCard(
|
||||||
icon=FluentIcon.PAGE_RIGHT,
|
icon=FluentIcon.PAGE_RIGHT,
|
||||||
title="脚本日志时间格式 - [必填]",
|
title="脚本日志时间戳格式 - [必填]",
|
||||||
content="脚本日志中时间的格式",
|
content="脚本日志中时间戳的格式",
|
||||||
text="请输入脚本日志时间格式",
|
text="请输入脚本日志时间格式",
|
||||||
qconfig=self.config,
|
qconfig=self.config,
|
||||||
configItem=self.config.Script_LogTimeFormat,
|
configItem=self.config.Script_LogTimeFormat,
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
"4.4.1.5": {
|
"4.4.1.5": {
|
||||||
"新增功能": [
|
"新增功能": [
|
||||||
"适配 MAA 长期开放剿灭关卡",
|
"适配 MAA 长期开放剿灭关卡",
|
||||||
"新增完成任务后自动复原脚本配置"
|
"新增完成任务后自动复原脚本配置",
|
||||||
|
"通用脚本启动附加命令添加额外的语法以适应UI可执行文件与任务可执行文件不同的情况"
|
||||||
],
|
],
|
||||||
"程序优化": [
|
"程序优化": [
|
||||||
"优化调度队列配置逻辑",
|
"优化调度队列配置逻辑",
|
||||||
|
|||||||
Reference in New Issue
Block a user