summaryrefslogtreecommitdiff
path: root/yaksh/r_code_evaluator.py
diff options
context:
space:
mode:
authorPalaparthy Adityachandra2020-04-07 14:26:42 +0530
committerGitHub2020-04-07 14:26:42 +0530
commite08af49ea33585f101335d0c25b1ea22f85fcdd0 (patch)
tree52a59e94012fd4badbe57f4f1fb031c80e306742 /yaksh/r_code_evaluator.py
parent12af42a922679a33ce52df24499e165474fbd7d2 (diff)
parent2e360f7d5772c3059a42db8915530cde952a01c6 (diff)
downloadonline_test-e08af49ea33585f101335d0c25b1ea22f85fcdd0.tar.gz
online_test-e08af49ea33585f101335d0c25b1ea22f85fcdd0.tar.bz2
online_test-e08af49ea33585f101335d0c25b1ea22f85fcdd0.zip
Merge pull request #678 from prathamesh920/r-clean-error-messages
Show prettified R error messages and fix filter
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):