From 97b657edc2a323f832c81f0e34ce5761bd21f7e9 Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 24 May 2018 12:07:39 +0530 Subject: Pep8 changes --- yaksh/cpp_code_evaluator.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'yaksh/cpp_code_evaluator.py') diff --git a/yaksh/cpp_code_evaluator.py b/yaksh/cpp_code_evaluator.py index 4c8e938..aab4995 100644 --- a/yaksh/cpp_code_evaluator.py +++ b/yaksh/cpp_code_evaluator.py @@ -1,9 +1,7 @@ #!/usr/bin/env python from __future__ import unicode_literals -import traceback -import pwd import os -from os.path import join, isfile +from os.path import isfile import subprocess # Local imports @@ -51,12 +49,13 @@ class CppCodeEvaluator(BaseEvaluator): return user_output_path, ref_output_path def get_commands(self, clean_ref_code_path, user_output_path, - ref_output_path): - compile_command = 'g++ {0} -c -o {1}'.format(self.submit_code_path, - user_output_path) - compile_main = 'g++ {0} {1} -o {2}'.format(clean_ref_code_path, - user_output_path, - ref_output_path) + ref_output_path): + compile_command = 'g++ {0} -c -o {1}'.format( + self.submit_code_path, user_output_path) + compile_main = 'g++ {0} {1} -o {2}'.format( + clean_ref_code_path, user_output_path, + ref_output_path + ) return compile_command, compile_main def compile_code(self): @@ -65,7 +64,8 @@ class CppCodeEvaluator(BaseEvaluator): else: self.submit_code_path = self.create_submit_code_file('submit.c') self.test_code_path = self.create_submit_code_file('main.c') - self.write_to_submit_code_file(self.submit_code_path, self.user_answer) + self.write_to_submit_code_file(self.submit_code_path, + self.user_answer) self.write_to_submit_code_file(self.test_code_path, self.test_case) clean_ref_code_path = self.test_code_path if self.file_paths: @@ -132,10 +132,10 @@ class CppCodeEvaluator(BaseEvaluator): if main_err == '': ret = self._run_command([self.ref_output_path], - stdin=None, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE - ) + stdin=None, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) proc, stdout, stderr = ret if proc.returncode == 0: success, err = True, None -- cgit From 0adb0d3b79980544bb5a724ce3b106dbd8e01c9c Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 24 May 2018 12:37:54 +0530 Subject: Further pep8 changes --- yaksh/cpp_code_evaluator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'yaksh/cpp_code_evaluator.py') diff --git a/yaksh/cpp_code_evaluator.py b/yaksh/cpp_code_evaluator.py index aab4995..7ab06ec 100644 --- a/yaksh/cpp_code_evaluator.py +++ b/yaksh/cpp_code_evaluator.py @@ -151,7 +151,7 @@ class CppCodeEvaluator(BaseEvaluator): err = "{0} \n {1}".format(err, e.split(":", 1)[1]) else: err = "{0} \n {1}".format(err, e) - except: + except Exception: err = "{0} \n {1}".format(err, main_err) else: err = "Compilation Error:" @@ -162,7 +162,7 @@ class CppCodeEvaluator(BaseEvaluator): err = "{0} \n {1}".format(err, e.split(":", 1)[1]) else: err = "{0} \n {1}".format(err, e) - except: + except Exception: err = "{0} \n {1}".format(err, stdnt_stderr) return success, err, mark_fraction -- cgit From a2769e56ab99427beb196b85bf3fc125ffd9bac2 Mon Sep 17 00:00:00 2001 From: adityacp Date: Fri, 25 May 2018 11:57:11 +0530 Subject: Add tests for models and cpp, java evaluators --- yaksh/cpp_code_evaluator.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'yaksh/cpp_code_evaluator.py') diff --git a/yaksh/cpp_code_evaluator.py b/yaksh/cpp_code_evaluator.py index 7ab06ec..8bd3beb 100644 --- a/yaksh/cpp_code_evaluator.py +++ b/yaksh/cpp_code_evaluator.py @@ -129,7 +129,6 @@ class CppCodeEvaluator(BaseEvaluator): if stdnt_stderr == '': proc, main_out, main_err = self.compiled_test_code main_err = self._remove_null_substitute_char(main_err) - if main_err == '': ret = self._run_command([self.ref_output_path], stdin=None, @@ -143,7 +142,7 @@ class CppCodeEvaluator(BaseEvaluator): else: err = "{0} \n {1}".format(stdout, stderr) else: - err = "Error:" + err = "Test case Error:" try: error_lines = main_err.splitlines() for e in error_lines: -- cgit