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 ##############################################################################
12 from api.utils import influx as influx_utils
13 from api.utils import common as common_utils
14 from api.database.handlers import TasksHandler
16 logger = logging.getLogger(__name__)
20 return getResult(args)
25 task_id = args['task_id']
29 message = 'task_id must be provided'
30 return common_utils.error_handler(message)
32 task = TasksHandler().get_task_by_taskid(task_id)
35 return common_utils.result_handler(0, [])
38 testcases = task.details.split(',')
40 def get_data(testcase):
41 query_template = "select * from %s where task_id='%s'"
42 query_sql = query_template % (testcase, task_id)
43 data = common_utils.translate_to_str(influx_utils.query(query_sql))
46 result = {k: get_data(k) for k in testcases}
48 return common_utils.result_handler(1, result)
51 return common_utils.result_handler(2, task.error)
61 return switcher.get(status, lambda: 'nothing')()
63 return common_utils.error_handler('no such task')