MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / batch_delete_task

Method batch_delete_task

mod/project/node/executorMod.py:292–315  ·  view source on GitHub ↗
(get)

Source from the content-addressed store, hash-verified

290
291 @staticmethod
292 def batch_delete_task(get):
293 task_ids: List[int] = list_args(get, "task_ids")
294 if not task_ids:
295 return json_response(status=False, msg="请选择要删除的任务")
296 task_ids = [int(i) for i in task_ids]
297 e_db = TaskFlowsDB()
298 task_list = e_db.CommandTask.query("id IN ({})".format(",".join(["?"] * len(task_ids))), (*task_ids,))
299 if not task_list:
300 return json_response(status=False, msg="任务不存在")
301 for i in task_list:
302 pid_file = "{}/logs/executor_log/{}.pid".format(public.get_panel_path(), i.id)
303 if os.path.exists(pid_file):
304 pid: str = public.readFile(pid_file)
305 if pid and pid.isdigit():
306 public.ExecShell("kill -9 {}".format(pid))
307 os.remove(pid_file)
308
309 log_list = e_db.CommandLog.query("command_task_id = ?", (i.id,))
310 for j in log_list:
311 j.remove_log()
312 e_db.CommandLog.delete(j.id)
313 e_db.CommandTask.delete(i.id)
314
315 return json_response(status=True, msg="删除成功")
316
317 @staticmethod
318 def retry_task(get):

Callers

nothing calls this directly

Calls 12

list_argsFunction · 0.90
json_responseFunction · 0.90
TaskFlowsDBClass · 0.90
readFileMethod · 0.80
ExecShellMethod · 0.80
queryMethod · 0.45
formatMethod · 0.45
joinMethod · 0.45
existsMethod · 0.45
removeMethod · 0.45
remove_logMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected