summaryrefslogtreecommitdiff
path: root/yaksh/r_code_evaluator.py
diff options
context:
space:
mode:
authorprathamesh2020-04-02 16:33:20 +0530
committerprathamesh2020-04-02 16:53:00 +0530
commit2e360f7d5772c3059a42db8915530cde952a01c6 (patch)
treef253fc25a4f449dda1fa7bcfccb816ecf119cb29 /yaksh/r_code_evaluator.py
parent61abccdcb0b0a44f4db60e3bb4d09d1ec5dc50e3 (diff)
downloadonline_test-2e360f7d5772c3059a42db8915530cde952a01c6.tar.gz
online_test-2e360f7d5772c3059a42db8915530cde952a01c6.tar.bz2
online_test-2e360f7d5772c3059a42db8915530cde952a01c6.zip
Show prettified R error messages and fix filter
R language available in filter form. Values taken from models. R messages are prettified like python assertion messages. Text up to first colon in the R error message removed, as it is simply a filename or unwanted text.
Diffstat (limited to 'yaksh/r_code_evaluator.py')
-rw-r--r--yaksh/r_code_evaluator.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/yaksh/r_code_evaluator.py b/yaksh/r_code_evaluator.py
index 11bc970..8eaeb38 100644
--- a/yaksh/r_code_evaluator.py
+++ b/yaksh/r_code_evaluator.py
@@ -7,6 +7,7 @@ import re
# Local imports
from .base_evaluator import BaseEvaluator
from .file_utils import copy_files, delete_files
+from .error_messages import prettify_exceptions
class RCodeEvaluator(BaseEvaluator):
@@ -49,9 +50,8 @@ class RCodeEvaluator(BaseEvaluator):
# Throw message if there are commmands that terminates scilab
add_err = ""
if terminate_commands:
- add_err = "Please do not use quit() q() in your\
- code.\n Otherwise your code will not be evaluated\
- correctly.\n"
+ add_err = "Please do not use quit() q() in your code.\
+ \n Otherwise your code will not be evaluated.\n"
cmd = 'Rscript main.r'
ret = self._run_command(cmd, shell=True, stdout=subprocess.PIPE,
@@ -66,10 +66,12 @@ class RCodeEvaluator(BaseEvaluator):
success, err = True, None
mark_fraction = 1.0 if self.partial_grading else 0.0
else:
- err = add_err + stdout
+ err = stdout + add_err
else:
- err = add_err + stderr
-
+ err = stderr + add_err
+ if err:
+ err = re.sub(r'.*?: ', '', err, count=1)
+ err = prettify_exceptions('Error', err)
return success, err, mark_fraction
def _remove_r_quit(self, string):