summaryrefslogtreecommitdiff
path: root/yaksh/code_server.py
diff options
context:
space:
mode:
authorankitjavalkar2016-03-11 12:11:49 +0530
committerankitjavalkar2016-05-05 18:59:22 +0530
commit1e993bee18028c59d809f49d853b60e41326991c (patch)
treee1af06404a634e54f9ad8a27c6948b131481b127 /yaksh/code_server.py
parentceb4f2cbc1a03835a3c7e34d806ec21e47e3f059 (diff)
downloadonline_test-1e993bee18028c59d809f49d853b60e41326991c.tar.gz
online_test-1e993bee18028c59d809f49d853b60e41326991c.tar.bz2
online_test-1e993bee18028c59d809f49d853b60e41326991c.zip
Add a python standard out evaluator
Diffstat (limited to 'yaksh/code_server.py')
-rwxr-xr-xyaksh/code_server.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/yaksh/code_server.py b/yaksh/code_server.py
index 2762f12..7951ac8 100755
--- a/yaksh/code_server.py
+++ b/yaksh/code_server.py
@@ -31,7 +31,7 @@ import re
import json
# Local imports.
from settings import SERVER_PORTS, SERVER_POOL_PORT
-from language_registry import get_registry, registry
+from language_registry import get_registry, create_evaluator_instance, unpack_json
MY_DIR = abspath(dirname(__file__))
@@ -58,13 +58,14 @@ class CodeServer(object):
self.queue = queue
# Public Protocol ##########
- def check_code(self, language, json_data, in_dir=None):
+ def check_code(self, language, test_case_type, json_data, in_dir=None):
"""Calls relevant EvaluateCode class based on language to check the
answer code
"""
- code_evaluator = self._create_evaluator_instance(language, json_data,
+ code_evaluator = create_evaluator_instance(language, test_case_type, json_data,
in_dir)
- result = code_evaluator.evaluate()
+ data = unpack_json(json_data) #@@@ def should be here
+ result = code_evaluator.evaluate(**data)
# Put us back into the server pool queue since we are free now.
self.queue.put(self.port)
@@ -79,15 +80,14 @@ class CodeServer(object):
self.queue.put(self.port)
server.serve_forever()
- # Private Protocol ##########
- def _create_evaluator_instance(self, language, json_data, in_dir):
- """Create instance of relevant EvaluateCode class based on language"""
- # set_registry()
- registry1 = get_registry()
- print registry
- cls = registry1.get_class(language)
- instance = cls.from_json(language, json_data, in_dir)
- return instance
+ # # Private Protocol ##########
+ # def _create_evaluator_instance(self, language, json_data, in_dir):
+ # """Create instance of relevant EvaluateCode class based on language"""
+ # # set_registry()
+ # registry = get_registry()
+ # cls = registry.get_class(language)
+ # instance = cls.from_json(language, json_data, in_dir)
+ # return instance
###############################################################################