diff options
author | ankitjavalkar | 2016-12-07 14:59:07 +0530 |
---|---|---|
committer | ankitjavalkar | 2016-12-20 12:46:02 +0530 |
commit | dee13fa4f8006d5266c02d6290b0e98d31413a9f (patch) | |
tree | d34bfed626a5e23689047318eda966c2495a2cfa /yaksh/code_server.py | |
parent | 1400eeb1d5af1cd1d69e015a19a319ab35d357c4 (diff) | |
download | online_test-dee13fa4f8006d5266c02d6290b0e98d31413a9f.tar.gz online_test-dee13fa4f8006d5266c02d6290b0e98d31413a9f.tar.bz2 online_test-dee13fa4f8006d5266c02d6290b0e98d31413a9f.zip |
Refactor code server and python evaluator
Diffstat (limited to 'yaksh/code_server.py')
-rw-r--r--[-rwxr-xr-x] | yaksh/code_server.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/yaksh/code_server.py b/yaksh/code_server.py index b3c9c30..abe7cd8 100755..100644 --- a/yaksh/code_server.py +++ b/yaksh/code_server.py @@ -53,7 +53,7 @@ from tornado.web import Application, RequestHandler # Local imports from .settings import SERVER_PORTS, SERVER_POOL_PORT -from .language_registry import create_evaluator_instance, unpack_json +from .language_registry import create_evaluator_instance MY_DIR = abspath(dirname(__file__)) @@ -84,19 +84,24 @@ class CodeServer(object): """Calls relevant EvaluateCode class based on language to check the answer code """ - code_evaluator = create_evaluator_instance(language, - test_case_type, - json_data, - in_dir - ) - data = unpack_json(json_data) - result = code_evaluator.evaluate(**data) + # code_evaluator = create_evaluator_instance(language, + # test_case_type, + # json_data, + # in_dir + # ) + data = unpack_json_to_python_obj(json_data) + code_eval_instance = CodeEvaluator(in_dir) + result = code_eval_instance.evaluate(**data) #language, test_case_type, # Put us back into the server pool queue since we are free now. self.queue.put(self.port) return json.dumps(result) + def unpack_json_to_python_obj(self, json_data): + data = json.loads(json_data) + return data + def run(self): """Run XMLRPC server, serving our methods.""" server = SimpleXMLRPCServer(("0.0.0.0", self.port)) |