-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubmeq.py
executable file
·43 lines (35 loc) · 1.17 KB
/
submeq.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
#!/usr/bin/python
import sys
import subprocess
import os
import time
problem_number = int(sys.argv[1])
outproblemname = "problem{0:06d}".format(problem_number)
subfile = os.path.join("reptiloid-db", outproblemname, "best_submitted")
if not os.access(subfile, os.F_OK):
print "Problem not already submitted"
exit(1)
fp = os.stat("problems/prob" + str(problem_number))
print "OK"
for f in os.listdir("problems/"):
if f == "problems/prob" + str(problem_number):
continue
try:
fi = os.stat(os.path.join("problems", f))
except OSError:
continue
if fp.st_size <> fi.st_size:
continue
try:
out = subprocess.check_output(["diff",
"problems/prob" + str(problem_number),
os.path.join("problems", f)],
stderr = subprocess.STDOUT)
except subprocess.CalledProcessError:
continue
if len(out) == 0:
print "Submitting", f
submitted = subprocess.call(["./reptiloid.py", f.lstrip("prob"),
str(subfile)])
if submitted == 0:
time.sleep(1)