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 __future__ import absolute_import
13 from api.utils import influx as influx_utils
14 from api.utils import common as common_utils
15 from api.database.handlers import TasksHandler
17 logger = logging.getLogger(__name__)
21 return getResult(args)
26 task_id = args['task_id']
30 message = 'task_id must be provided'
31 return common_utils.error_handler(message)
33 task = TasksHandler().get_task_by_taskid(task_id)
36 return common_utils.result_handler(0, [])
39 testcases = task.details.split(',')
41 def get_data(testcase):
42 query_template = "select * from %s where task_id='%s'"
43 query_sql = query_template % (testcase, task_id)
44 data = common_utils.translate_to_str(influx_utils.query(query_sql))
47 result = {k: get_data(k) for k in testcases}
49 return common_utils.result_handler(1, result)
52 return common_utils.result_handler(2, task.error)
62 return switcher.get(status, lambda: 'nothing')()
64 return common_utils.error_handler('no such task')