diff options
author | Linda Wang <wangwulin@huawei.com> | 2017-09-05 12:22:27 +0000 |
---|---|---|
committer | Linda Wang <wangwulin@huawei.com> | 2017-09-05 12:22:27 +0000 |
commit | 808319c010baf449808214ec06237b4703af39c6 (patch) | |
tree | 6fddac942ac6cf3a164cc046b2fcce264aa9ffcb /functest/api/resources/v1/tasks.py | |
parent | 38906080fd7c30a7f39ce9daa68d9150d63f80e3 (diff) |
unify all the return status as number
Change-Id: I835a368fe78329e60e811e40c24f3609c7a8960c
Signed-off-by: Linda Wang <wangwulin@huawei.com>
Diffstat (limited to 'functest/api/resources/v1/tasks.py')
-rw-r--r-- | functest/api/resources/v1/tasks.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/functest/api/resources/v1/tasks.py b/functest/api/resources/v1/tasks.py index e05db51b..f099918f 100644 --- a/functest/api/resources/v1/tasks.py +++ b/functest/api/resources/v1/tasks.py @@ -50,12 +50,15 @@ class V1Task(ApiResource): if status not in ['IN PROGRESS', 'FAIL', 'FINISHED']: return api_utils.result_handler(status=1, data='internal server error') + + switcher = {'IN PROGRESS': 0, 'FAIL': 1, 'FINISHED': 2} if status == 'IN PROGRESS': - result = {'status': status, 'result': ''} + result = {'status': switcher.get(status), 'result': ''} elif status == 'FAIL': - result = {'status': status, 'error': task.error} + result = {'status': switcher.get(status), 'error': task.error} else: - result = {'status': status, 'result': json.loads(task.result)} + result = {'status': switcher.get(status), + 'result': json.loads(task.result)} return jsonify(result) @@ -92,4 +95,7 @@ class V1TaskLog(ApiResource): return_data = {'data': data} - return api_utils.result_handler(status=task.status, data=return_data) + switcher = {'IN PROGRESS': 0, 'FAIL': 1, 'FINISHED': 2} + + return api_utils.result_handler(status=switcher.get(task.status), + data=return_data) |