From 97b657edc2a323f832c81f0e34ce5761bd21f7e9 Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 24 May 2018 12:07:39 +0530 Subject: Pep8 changes --- yaksh/java_code_evaluator.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'yaksh/java_code_evaluator.py') diff --git a/yaksh/java_code_evaluator.py b/yaksh/java_code_evaluator.py index e6dc628..55e6c9f 100644 --- a/yaksh/java_code_evaluator.py +++ b/yaksh/java_code_evaluator.py @@ -1,11 +1,8 @@ #!/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 -import importlib # Local imports from .base_evaluator import BaseEvaluator @@ -62,8 +59,8 @@ class JavaCodeEvaluator(BaseEvaluator): # create student code and moderator code file self.submit_code_path = self.create_submit_code_file('Test.java') self.test_code_path = self.create_submit_code_file('main.java') - 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 @@ -78,11 +75,11 @@ class JavaCodeEvaluator(BaseEvaluator): user_code_directory = os.getcwd() + '/' ref_file_name = (clean_ref_code_path.split('/')[-1]).split('.')[0] - self.user_output_path = self.set_file_paths(user_code_directory, - 'Test' + self.user_output_path = self.set_file_paths( + user_code_directory, 'Test' ) - self.ref_output_path = self.set_file_paths(user_code_directory, - ref_file_name + self.ref_output_path = self.set_file_paths( + user_code_directory, ref_file_name ) compile_command, self.compile_main = self.get_commands( clean_ref_code_path, @@ -93,13 +90,15 @@ class JavaCodeEvaluator(BaseEvaluator): ref_file_name ) - self.compiled_user_answer = self._run_command(compile_command, + self.compiled_user_answer = self._run_command( + compile_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) - self.compiled_test_code = self._run_command(self.compile_main, + self.compiled_test_code = self._run_command( + self.compile_main, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE @@ -141,9 +140,9 @@ class JavaCodeEvaluator(BaseEvaluator): if main_err == '': ret = self._run_command(self.run_command_args, shell=True, - 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/java_code_evaluator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'yaksh/java_code_evaluator.py') diff --git a/yaksh/java_code_evaluator.py b/yaksh/java_code_evaluator.py index 55e6c9f..2612509 100644 --- a/yaksh/java_code_evaluator.py +++ b/yaksh/java_code_evaluator.py @@ -158,7 +158,7 @@ class JavaCodeEvaluator(BaseEvaluator): err = err + "\n" + e.split(":", 1)[1] else: err = err + "\n" + e - except: + except Exception: err = err + "\n" + main_err else: err = "Compilation Error:" @@ -169,7 +169,7 @@ class JavaCodeEvaluator(BaseEvaluator): err = err + "\n" + e.split(":", 1)[1] else: err = err + "\n" + e - except: + except Exception: err = err + "\n" + 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/java_code_evaluator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yaksh/java_code_evaluator.py') diff --git a/yaksh/java_code_evaluator.py b/yaksh/java_code_evaluator.py index 2612509..5f2288d 100644 --- a/yaksh/java_code_evaluator.py +++ b/yaksh/java_code_evaluator.py @@ -150,7 +150,7 @@ class JavaCodeEvaluator(BaseEvaluator): else: err = stdout + "\n" + stderr else: - err = "Error:" + err = "Test case Error:" try: error_lines = main_err.splitlines() for e in error_lines: -- cgit