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