-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathojrunnerwin.py
32 lines (29 loc) · 1.13 KB
/
ojrunnerwin.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
import config
import subprocess
import sys
import random
class Runner:
def __init__(self):
return
def compile(self, judger, srcPath, outPath):
cmd = config.langCompile[judger.lang] % {'src': srcPath, 'target': outPath}
p = subprocess.Popen(cmd, shell = True,
stdout = subprocess.PIPE, stdin = subprocess.PIPE, stderr = subprocess.STDOUT)
retval = p.wait()
return (retval, p.stdout.read())
def judge(self, judger, srcPath, outPath, inFile, ansFile, memlimit, timelimit):
cmd = "".join([sys.path[0], "/", config.langRun[judger.lang] % {'src': srcPath, 'target': outPath}])
p = subprocess.Popen(cmd, shell = True,
stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
retVal = 9
try:
out, err = p.communicate(input = judger.readData(inFile), timeout = int(timelimit) / 1000)
except subprocess.TimeoutExpired:
p.kill()
retVal = 5
if(retVal == 9):
if(p.returncode != 0):
retVal = 6
else:
retVal = 2
return retVal