1 # ############################################################################
2 # Copyright (c) 2017 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 # ############################################################################
11 from api.utils import common as common_utils
12 from api.database.models import AsyncTasks
16 return _get_status(args)
19 def _get_status(args):
21 task_id = args['task_id']
24 message = 'measurement and task_id must be provided'
25 return common_utils.error_handler(message)
27 asynctask = AsyncTasks.query.filter_by(task_id=task_id).first()
30 status = asynctask.status
31 error = asynctask.error if asynctask.error else []
33 return common_utils.result_handler(status, error)
34 except AttributeError:
35 return common_utils.error_handler('no such task')