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

Method delete_task

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

Source from the content-addressed store, hash-verified

264
265 @staticmethod
266 def delete_task(get):
267 e_db = TaskFlowsDB()
268 task_id = get.get('task_id/d', 0)
269 if not task_id:
270 return json_response(status=False, msg="任务ID不能为空")
271
272 task = e_db.CommandTask.find("id = ?", (task_id,))
273 if not task:
274 return json_response(status=False, msg="任务不存在")
275
276 pid_file = "{}/logs/executor_log/{}.pid".format(public.get_panel_path(), task_id)
277 if os.path.exists(pid_file):
278 pid: str = public.readFile(pid_file)
279 if pid and pid.isdigit():
280 public.ExecShell("kill -9 {}".format(pid))
281 os.remove(pid_file)
282
283 log_list = e_db.CommandLog.query("command_task_id = ?", (task_id,))
284 for i in log_list:
285 i.remove_log()
286 e_db.CommandLog.delete(i.id)
287
288 e_db.CommandTask.delete(task_id)
289 return json_response(status=True, msg="删除成功")
290
291 @staticmethod
292 def batch_delete_task(get):

Callers

nothing calls this directly

Calls 12

TaskFlowsDBClass · 0.90
json_responseFunction · 0.90
readFileMethod · 0.80
ExecShellMethod · 0.80
getMethod · 0.45
findMethod · 0.45
formatMethod · 0.45
existsMethod · 0.45
removeMethod · 0.45
queryMethod · 0.45
remove_logMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected