@@ -90,6 +90,7 @@ def execute_task(self, server: PluginServerInterface, hook: str, var_dict: dict
90
90
command .write (self .command )
91
91
92
92
os .system (command .getvalue ())
93
+ # mc command
93
94
elif self .task_type == TaskType .server_command :
94
95
# 替换参数
95
96
command = self .command
@@ -98,6 +99,7 @@ def execute_task(self, server: PluginServerInterface, hook: str, var_dict: dict
98
99
command = command .replace ('{$' + key + '}' , str (var_dict .get (key )))
99
100
100
101
server .execute (command )
102
+ # mcdr command
101
103
elif self .task_type == TaskType .mcdr_command :
102
104
# 替换参数
103
105
command = self .command
@@ -106,7 +108,8 @@ def execute_task(self, server: PluginServerInterface, hook: str, var_dict: dict
106
108
command = command .replace ('{$' + key + '}' , str (var_dict .get (key )))
107
109
108
110
server .execute_command (command )
109
-
111
+
112
+ # python code
110
113
elif self .task_type == TaskType .python_code :
111
114
if obj_dict is not None :
112
115
exec (self .command , obj_dict , {})
@@ -343,9 +346,15 @@ def parse_and_apply_scripts(script: str, server: PluginServerInterface):
343
346
content : dict [str , Union [str , Union [list , dict ]]] = yaml .load (f .read (), Loader = yaml .Loader )
344
347
345
348
for task in content .get ('tasks' ).values ():
349
+ cmd_file_path = str (task .get ('command_file' )).replace ('{hooks_config_path}' , server .get_data_folder ())
350
+
351
+ if not os .path .isfile (cmd_file_path ):
352
+ server .logger .warning (f'Script path for task { task .get ("name" )} is invalid! { task .get ("command_file" )} ' )
353
+
346
354
if (task .get ('command_file' ) is not None ) and (len (task .get ('command_file' )) > 0 ) and \
347
- (os .path .isfile (task .get ('command_file' ))):
348
- with open (task .get ('command_file' ), 'r' ) as command_file :
355
+ (os .path .isfile (cmd_file_path )):
356
+ with open (cmd_file_path , 'r' ) \
357
+ as command_file :
349
358
command_file_content = command_file .read ()
350
359
# 创建task
351
360
create_task (task .get ('task_type' ), command_file_content , task .get ('name' ),
0 commit comments