mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
增加signal的文字提示
This commit is contained in:
parent
53b132a211
commit
e8fe2a7279
@ -82,7 +82,7 @@
|
|||||||
<td>{{ item.real_time }} ms</td>
|
<td>{{ item.real_time }} ms</td>
|
||||||
<td>{{ item.cpu_time }} ms</td>
|
<td>{{ item.cpu_time }} ms</td>
|
||||||
<td>{{ item.memory }} Byte</td>
|
<td>{{ item.memory }} Byte</td>
|
||||||
<td class="{{ item.result|translate_result_class }}">{{ item.result|translate_result }}</td>
|
<td class="{{ item.result|translate_result_class }}">{{ item.result|translate_result }} {% if item.signal %}({{ item.signal|translate_signal }}){% endif %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
26
utils/signal2str.py
Normal file
26
utils/signal2str.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# copy from https://github.com/DMOJ/judge/issues/162
|
||||||
|
try:
|
||||||
|
# in large part from http://code.activestate.com/recipes/578899-strsignal/
|
||||||
|
import signal
|
||||||
|
import ctypes
|
||||||
|
import ctypes.util
|
||||||
|
|
||||||
|
libc = ctypes.CDLL(ctypes.util.find_library("c"))
|
||||||
|
strsignal_c = ctypes.CFUNCTYPE(ctypes.c_char_p, ctypes.c_int)(("strsignal", libc), ((1,),))
|
||||||
|
NSIG = signal.NSIG
|
||||||
|
|
||||||
|
|
||||||
|
def strsignal_ctypes_wrapper(signo):
|
||||||
|
# The behavior of the C library strsignal() is unspecified if
|
||||||
|
# called with an out-of-range argument. Range-check on entry
|
||||||
|
# _and_ NULL-check on exit.
|
||||||
|
if 0 <= signo < NSIG:
|
||||||
|
s = strsignal_c(signo)
|
||||||
|
if s:
|
||||||
|
return s.decode("utf-8")
|
||||||
|
return "Unknown signal %d" % signo
|
||||||
|
|
||||||
|
|
||||||
|
strsignal = strsignal_ctypes_wrapper
|
||||||
|
except:
|
||||||
|
strsignal = lambda x: 'signal %d' % x
|
||||||
@ -1,5 +1,6 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
from django import template
|
from django import template
|
||||||
|
from utils.signal2str import strsignal
|
||||||
|
|
||||||
|
|
||||||
def translate_result(value):
|
def translate_result(value):
|
||||||
@ -17,6 +18,13 @@ def translate_result(value):
|
|||||||
return results[value]
|
return results[value]
|
||||||
|
|
||||||
|
|
||||||
|
def translate_signal(value):
|
||||||
|
if not value:
|
||||||
|
return ""
|
||||||
|
else:
|
||||||
|
return strsignal(value)
|
||||||
|
|
||||||
|
|
||||||
def translate_language(value):
|
def translate_language(value):
|
||||||
return {1: "C", 2: "C++", 3: "Java"}[value]
|
return {1: "C", 2: "C++", 3: "Java"}[value]
|
||||||
|
|
||||||
@ -33,3 +41,4 @@ register = template.Library()
|
|||||||
register.filter("translate_result", translate_result)
|
register.filter("translate_result", translate_result)
|
||||||
register.filter("translate_language", translate_language)
|
register.filter("translate_language", translate_language)
|
||||||
register.filter("translate_result_class", translate_result_class)
|
register.filter("translate_result_class", translate_result_class)
|
||||||
|
register.filter("translate_signal", translate_signal)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user