aboutsummaryrefslogtreecommitdiffstats
path: root/api/views.py
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2016-11-22 00:14:57 +0000
committerchenjiankun <chenjiankun1@huawei.com>2016-11-24 07:44:05 +0000
commit73edf3d28e7d17a64ddc9ffea206ec825c488bc6 (patch)
tree3dbbbbeabc0c2ea9a87af237ac667902d295d093 /api/views.py
parentd491d77dea52e459dc6f1e1ec39703e26a4857e7 (diff)
Create API to get test case result
JIRA: YARDSTICK-416 Change-Id: I722566bb0e5bc5288cd6302559e56a3f92ebbeca Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'api/views.py')
-rw-r--r--api/views.py35
1 files changed, 24 insertions, 11 deletions
diff --git a/api/views.py b/api/views.py
index 883091222..e78389f5a 100644
--- a/api/views.py
+++ b/api/views.py
@@ -1,4 +1,11 @@
-import json
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
import logging
from flask import request
@@ -6,7 +13,7 @@ from flask_restful import Resource
from api.utils import common as common_utils
from api.actions import test as test_action
-from api import conf
+from api.actions import result as result_action
logger = logging.getLogger(__name__)
@@ -17,13 +24,19 @@ class Test(Resource):
args = common_utils.translate_to_str(request.json.get('args', {}))
logger.debug('Input args is: action: %s, args: %s', action, args)
- if action not in conf.TEST_ACTION:
- logger.error('Wrong action')
- result = {
- 'status': 'error',
- 'message': 'wrong action'
- }
- return json.dumps(result)
+ try:
+ return getattr(test_action, action)(args)
+ except AttributeError:
+ return common_utils.error_handler('Wrong action')
- method = getattr(test_action, action)
- return method(args)
+
+class Result(Resource):
+ def get(self):
+ args = common_utils.translate_to_str(request.args)
+ action = args.get('action', '')
+ logger.debug('Input args is: action: %s, args: %s', action, args)
+
+ try:
+ return getattr(result_action, action)(args)
+ except AttributeError:
+ return common_utils.error_handler('Wrong action')
#fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * wm8350.h - WM8903 audio codec interface
 *
 * Copyright 2008 Wolfson Microelectronics PLC.
 *
 *  This program is free software; you can redistribute  it and/or modify it
 *  under  the terms of  the GNU General  Public License as published by the
 *  Free Software Foundation;  either version 2 of the  License, or (at your
 *  option) any later version.
 */

#ifndef _WM8350_H
#define _WM8350_H

#include <sound/soc.h>
#include <linux/mfd/wm8350/audio.h>

enum wm8350_jack {
	WM8350_JDL = 1,
	WM8350_JDR = 2,
};

int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which,
			  struct snd_soc_jack *jack, int report);
int wm8350_mic_jack_detect(struct snd_soc_codec *codec,
			   struct snd_soc_jack *jack,
			   int detect_report, int short_report);

#endif