This repository has been archived by the owner on Jan 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
judger.py
47 lines (45 loc) · 1.83 KB
/
judger.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from util.puller import pull, get_data_dir, get_test_case
from util.problem_locker import gloal_problem_lock
from update import upload_result
from report.models import Report
from compiler import compile
from runner import run
from create_tempfile import create_tempfile
from judge_result import Judge_result
def judge_submission( submission ):
'''
Judge the target submission
'''
if submission.language is None:
raise RuntimeError( 'Unknown Language' )
else:
upload_result( Report(
result = Judge_result.PR,
submission = submission.submission ))
st , info = pull( lock = gloal_problem_lock.get( submission.problem ) , problem = submission.problem )
if not st:
raise RuntimeError( "Pull error: " + str( info ) )
st , info = create_tempfile(
sourcefile = submission.sourcefile,
work_dir = submission.work_dir,
lang = submission.language,
code = submission.code)
if st != 'Success':
raise RuntimeError( "Judger Error during creating tempfile: " + str( info ) )
if submission.language.value.compile is True:
result , information = compile(
submission = submission)
if result is Judge_result.CE:
upload_result( Report(
result = result,
complete = True,
submission = submission.submission,
compileerror_msg = information))
return
elif result is Judge_result.JE:
raise RuntimeError( "Judger Error during compiling: " + str( information ) )
submission.case = get_test_case( submission.problem )
if len( submission.case ) == 0:
raise RuntimeError( "Judger Error, because there is no test-data" )
submission.data_dir = get_data_dir( get_data_dir( submission.problem ) )
run( sub = submission )