forked from ma6174/acmjudger
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjudge_one.py
69 lines (67 loc) · 2.19 KB
/
judge_one.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
# coding=utf-8
def judge_one_mem_time(
solution_id, problem_id, data_num, time_limit, mem_limit, language):
low_level()
'''评测一组数据'''
input_path = os.path.join(
config.data_dir, str(problem_id), 'data%s.in' %
data_num)
try:
input_data = file(input_path)
except:
return False
output_path = os.path.join(
config.work_dir, str(solution_id), 'out%s.txt' %
data_num)
temp_out_data = file(output_path, 'w')
if language == 'java':
cmd = 'java -cp %s Main' % (
os.path.join(config.work_dir,
str(solution_id)))
main_exe = shlex.split(cmd)
elif language == 'python2':
cmd = 'python2 %s' % (
os.path.join(config.work_dir,
str(solution_id),
'main.pyc'))
main_exe = shlex.split(cmd)
elif language == 'python3':
cmd = 'python3 %s' % (
os.path.join(config.work_dir,
str(solution_id),
'__pycache__/main.cpython-33.pyc'))
main_exe = shlex.split(cmd)
elif language == 'lua':
cmd = "lua %s" % (
os.path.join(config.work_dir,
str(solution_id),
"main"))
main_exe = shlex.split(cmd)
elif language == "ruby":
cmd = "ruby %s" % (
os.path.join(config.work_dir,
str(solution_id),
"main.rb"))
main_exe = shlex.split(cmd)
elif language == "perl":
cmd = "perl %s" % (
os.path.join(config.work_dir,
str(solution_id),
"main.pl"))
main_exe = shlex.split(cmd)
else:
main_exe = [os.path.join(config.work_dir, str(solution_id), 'main'), ]
runcfg = {
'args': main_exe,
'fd_in': input_data.fileno(),
'fd_out': temp_out_data.fileno(),
'timelimit': time_limit, # in MS
'memorylimit': mem_limit, # in KB
}
low_level()
rst = lorun.run(runcfg)
input_data.close()
temp_out_data.close()
logging.debug(rst)
return rst