Skip to content

Commit

Permalink
Send raw compiler ANSI output to the site; #478
Browse files Browse the repository at this point in the history
  • Loading branch information
Xyene committed Sep 17, 2019
1 parent ab93e6a commit c3c0a94
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 13 deletions.
6 changes: 2 additions & 4 deletions dmoj/graders/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ def _generate_binary(self):
return executors[siggrader].Executor(self.problem.id, entry, aux_sources=aux_sources,
writable=handler_data['writable'] or (1, 2),
fds=handler_data['fds'], defines=['-DSIGNATURE_GRADER'])
except CompileError as compilation_error:
self.judge.packet_manager.compile_error_packet(ansi.format_ansi(
compilation_error.args[0] or 'compiler exited abnormally'
))
except CompileError as compile_error:
self.judge.packet_manager.compile_error_packet(compile_error.args[0] or 'compiler exited abnormally')

# Compile error is fatal
raise
Expand Down
4 changes: 2 additions & 2 deletions dmoj/graders/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ def _generate_binary(self):
except CompileError as compilation_error:
error = compilation_error.args[0]
error = error.decode('mbcs') if os.name == 'nt' and isinstance(error, six.binary_type) else error
self.judge.packet_manager.compile_error_packet(ansi.format_ansi(error or 'compiler exited abnormally'))
self.judge.packet_manager.compile_error_packet(error or 'compiler exited abnormally')

# Compile error is fatal
raise

# Carry on grading in case of compile warning
if hasattr(binary, 'warning') and binary.warning:
self.judge.packet_manager.compile_message_packet(ansi.format_ansi(binary.warning or ''))
self.judge.packet_manager.compile_message_packet(binary.warning or '')
return binary
5 changes: 0 additions & 5 deletions dmoj/utils/ansi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import six
from termcolor import colored
import ansi2html

from dmoj.utils.unicode import utf8text

Expand All @@ -14,10 +13,6 @@ def strip_ansi(s):
return re.sub(r'\x1b\[([0-9,A-Z]{1,2}(;[0-9]{1,2})?(;[0-9]{3})?)?[m|K]?', '', s)


def format_ansi(s):
return ansi2html.Ansi2HTMLConverter(inline=True).convert(utf8text(s), full=False)


def ansi_style(text):
from dmoj.judgeenv import no_ansi

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
watchdog
pyyaml
ansi2html
termcolor
colorama
cython
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def unavailable(self, e):
],
},
ext_modules=cythonize(extensions),
install_requires=['watchdog', 'pyyaml', 'ansi2html', 'termcolor', 'pygments', 'six', 'setproctitle', 'pylru'],
install_requires=['watchdog', 'pyyaml', 'termcolor', 'pygments', 'six', 'setproctitle', 'pylru'],
tests_require=["mock ; python_version<'3.3'", 'requests'],
extras_require={
'test': ["mock ; python_version<'3.3'", 'requests'],
Expand Down

0 comments on commit c3c0a94

Please sign in to comment.