summaryrefslogtreecommitdiff
path: root/yaksh/cpp_code_evaluator.py
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh/cpp_code_evaluator.py')
-rw-r--r--yaksh/cpp_code_evaluator.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/yaksh/cpp_code_evaluator.py b/yaksh/cpp_code_evaluator.py
index 31b84b2..adef658 100644
--- a/yaksh/cpp_code_evaluator.py
+++ b/yaksh/cpp_code_evaluator.py
@@ -19,9 +19,10 @@ class CppCodeEvaluator(CodeEvaluator):
self.submit_code_path = self.create_submit_code_file('submit.c')
self.compiled_user_answer = None
self.compiled_test_code = None
+ self.user_output_path = ""
+ self.ref_output_path = ""
def teardown(self):
- super(CppCodeEvaluator, self).teardown()
# Delete the created file.
os.remove(self.submit_code_path)
if os.path.exists(self.ref_output_path):
@@ -30,9 +31,11 @@ class CppCodeEvaluator(CodeEvaluator):
os.remove(self.user_output_path)
if self.files:
delete_files(self.files)
+ super(CppCodeEvaluator, self).teardown()
+
def set_file_paths(self):
- user_output_path = os.getcwd() + '/output'
+ user_output_path = os.getcwd() + '/output_file'
ref_output_path = os.getcwd() + '/executable'
return user_output_path, ref_output_path
@@ -105,7 +108,6 @@ class CppCodeEvaluator(CodeEvaluator):
Returns (False, error_msg): If mandatory arguments are not files or
if the required permissions are not given to the file(s).
"""
-
success = False
proc, stdnt_out, stdnt_stderr = self.compiled_user_answer
stdnt_stderr = self._remove_null_substitute_char(stdnt_stderr)
@@ -126,28 +128,28 @@ class CppCodeEvaluator(CodeEvaluator):
if proc.returncode == 0:
success, err = True, "Correct answer"
else:
- err = stdout + "\n" + stderr
+ err = "{0} \n {1}".format(stdout, stderr)
else:
err = "Error:"
try:
error_lines = main_err.splitlines()
for e in error_lines:
if ':' in e:
- err = err + "\n" + e.split(":", 1)[1]
+ err = "{0} \n {1}".format(err, e.split(":", 1)[1])
else:
- err = err + "\n" + e
+ err = "{0} \n {1}".format(err, e)
except:
- err = err + "\n" + main_err
+ err = "{0} \n {1}".format(err, main_err)
else:
err = "Compilation Error:"
try:
error_lines = stdnt_stderr.splitlines()
for e in error_lines:
if ':' in e:
- err = err + "\n" + e.split(":", 1)[1]
+ err = "{0} \n {1}".format(err, e.split(":", 1)[1])
else:
- err = err + "\n" + e
+ err = "{0} \n {1}".format(err, e)
except:
- err = err + "\n" + stdnt_stderr
+ err = "{0} \n {1}".format(err, stdnt_stderr)
return success, err