1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from api.database import db_session
10 from api.database.v1.models import Tasks
11 from api.database.v1.models import AsyncTasks
14 class TasksHandler(object):
16 def insert(self, kwargs):
17 task = Tasks(**kwargs)
22 def get_task_by_taskid(self, task_id):
23 task = Tasks.query.filter_by(task_id=task_id).first()
29 def update_attr(self, task_id, attr):
30 task = self.get_task_by_taskid(task_id)
32 for k, v in attr.items():
37 class AsyncTaskHandler(object):
38 def insert(self, kwargs):
39 task = AsyncTasks(**kwargs)
44 def get_task_by_taskid(self, task_id):
45 task = AsyncTasks.query.filter_by(task_id=task_id).first()
51 def update_attr(self, task_id, attr):
52 task = self.get_task_by_taskid(task_id)
54 for k, v in attr.items():