summaryrefslogtreecommitdiff
path: root/yaksh/cpp_stdio_evaluator.py
diff options
context:
space:
mode:
authoradityacp2018-05-28 12:38:21 +0530
committeradityacp2018-06-07 14:50:47 +0530
commitd0c7f9eb35651fadffb53e32d6baf8a2efb55840 (patch)
treec66695a5579049877630a4d284037d3a35a5c8d5 /yaksh/cpp_stdio_evaluator.py
parenta2769e56ab99427beb196b85bf3fc125ffd9bac2 (diff)
downloadonline_test-d0c7f9eb35651fadffb53e32d6baf8a2efb55840.tar.gz
online_test-d0c7f9eb35651fadffb53e32d6baf8a2efb55840.tar.bz2
online_test-d0c7f9eb35651fadffb53e32d6baf8a2efb55840.zip
One more round of pep8 changes
Diffstat (limited to 'yaksh/cpp_stdio_evaluator.py')
-rw-r--r--yaksh/cpp_stdio_evaluator.py45
1 files changed, 18 insertions, 27 deletions
diff --git a/yaksh/cpp_stdio_evaluator.py b/yaksh/cpp_stdio_evaluator.py
index 51471e1..4e8f8df 100644
--- a/yaksh/cpp_stdio_evaluator.py
+++ b/yaksh/cpp_stdio_evaluator.py
@@ -25,9 +25,14 @@ class CppStdIOEvaluator(StdIOEvaluator):
self.weight = test_case_data.get('weight')
def teardown(self):
- os.remove(self.submit_code_path)
+ if os.path.exists(self.submit_code_path):
+ os.remove(self.submit_code_path)
if self.files:
delete_files(self.files)
+ if os.path.exists(self.ref_output_path):
+ os.remove(self.ref_output_path)
+ if os.path.exists(self.user_output_path):
+ os.remove(self.user_output_path)
def set_file_paths(self):
user_output_path = os.getcwd() + '/output_file'
@@ -77,31 +82,17 @@ class CppStdIOEvaluator(StdIOEvaluator):
if stdnt_stderr == '':
proc, main_out, main_err = self.compiled_test_code
main_err = self._remove_null_substitute_char(main_err)
- if main_err == '':
- proc = subprocess.Popen("./executable",
- shell=True,
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- preexec_fn=os.setpgrp
- )
- success, err = self.evaluate_stdio(self.user_answer, proc,
- self.expected_input,
- self.expected_output
- )
- os.remove(self.ref_output_path)
- else:
- err = "Error:"
- try:
- error_lines = main_err.splitlines()
- for e in error_lines:
- if ':' in e:
- err = err + "\n" + e.split(":", 1)[1]
- else:
- err = err + "\n" + e
- except:
- err = err + "\n" + main_err
- os.remove(self.user_output_path)
+ proc = subprocess.Popen("./executable",
+ shell=True,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ preexec_fn=os.setpgrp
+ )
+ success, err = self.evaluate_stdio(self.user_answer, proc,
+ self.expected_input,
+ self.expected_output
+ )
else:
err = "Compilation Error:"
try:
@@ -111,7 +102,7 @@ class CppStdIOEvaluator(StdIOEvaluator):
err = err + "\n" + e.split(":", 1)[1]
else:
err = err + "\n" + e
- except:
+ except Exception:
err = err + "\n" + stdnt_stderr
mark_fraction = 1.0 if self.partial_grading and success else 0.0
return success, err, mark_fraction