From ac8d6720bc75676e05462cc38ad144d5aedc14e7 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Wed, 21 Sep 2016 15:07:43 +0530 Subject: Migrate python code server and evaluators to python 2/3 compatible --- yaksh/stdio_evaluator.py | 1 + 1 file changed, 1 insertion(+) (limited to 'yaksh/stdio_evaluator.py') diff --git a/yaksh/stdio_evaluator.py b/yaksh/stdio_evaluator.py index efb2ae5..f1def95 100644 --- a/yaksh/stdio_evaluator.py +++ b/yaksh/stdio_evaluator.py @@ -15,6 +15,7 @@ class StdIOEvaluator(CodeEvaluator): def evaluate_stdio(self, user_answer, proc, expected_input, expected_output): success = False ip = expected_input.replace(",", " ") + print (type(expected_input), type(ip)) user_output, output_err = proc.communicate(input='{0}\n'.format(ip)) expected_output = expected_output.replace("\r", "") if not expected_input: -- cgit From 6b6e58b06bd49e36edd87a027c08d223571a0c0b Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Tue, 27 Sep 2016 15:08:18 +0530 Subject: Fix test cases and corresponding changes in evaluators for Python 2/3 compatibility --- yaksh/stdio_evaluator.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'yaksh/stdio_evaluator.py') diff --git a/yaksh/stdio_evaluator.py b/yaksh/stdio_evaluator.py index f1def95..b5924ff 100644 --- a/yaksh/stdio_evaluator.py +++ b/yaksh/stdio_evaluator.py @@ -15,8 +15,10 @@ class StdIOEvaluator(CodeEvaluator): def evaluate_stdio(self, user_answer, proc, expected_input, expected_output): success = False ip = expected_input.replace(",", " ") - print (type(expected_input), type(ip)) - user_output, output_err = proc.communicate(input='{0}\n'.format(ip)) + encoded_input = '{0}\n'.format(ip).encode('utf-8') + user_output_bytes, output_err_bytes = proc.communicate(encoded_input) + user_output = user_output_bytes.decode('utf-8') + output_err = output_err_bytes.decode('utf-8') expected_output = expected_output.replace("\r", "") if not expected_input: error_msg = "Expected Output is {0} ".\ @@ -31,5 +33,5 @@ class StdIOEvaluator(CodeEvaluator): err = " Incorrect answer\n" + error_msg +\ "\n Your output is {0}".format(repr(user_output)) else: - err = "Error:"+"\n"+output_err + err = "Error:\n {0}".format(output_err) return success, err -- cgit From cb0569a32422a195d4165ef405ac5560024dabda Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Thu, 29 Sep 2016 18:10:09 +0530 Subject: Add unicode_literal import for Python2 --- yaksh/stdio_evaluator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'yaksh/stdio_evaluator.py') diff --git a/yaksh/stdio_evaluator.py b/yaksh/stdio_evaluator.py index b5924ff..326d2e7 100644 --- a/yaksh/stdio_evaluator.py +++ b/yaksh/stdio_evaluator.py @@ -1,9 +1,10 @@ +from __future__ import unicode_literals + # Local imports from code_evaluator import CodeEvaluator class StdIOEvaluator(CodeEvaluator): - def setup(self): super(StdIOEvaluator, self).setup() pass -- cgit From b515ee32315cc406a28549e3ba10d47d5e0e523b Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Fri, 30 Sep 2016 11:18:11 +0530 Subject: - Remove unused imports - Fix minor test case issues --- yaksh/stdio_evaluator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yaksh/stdio_evaluator.py') diff --git a/yaksh/stdio_evaluator.py b/yaksh/stdio_evaluator.py index 326d2e7..7530b96 100644 --- a/yaksh/stdio_evaluator.py +++ b/yaksh/stdio_evaluator.py @@ -1,7 +1,7 @@ from __future__ import unicode_literals # Local imports -from code_evaluator import CodeEvaluator +from .code_evaluator import CodeEvaluator class StdIOEvaluator(CodeEvaluator): -- cgit