(get)
| 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): |
nothing calls this directly
no test coverage detected