blob: f2c6c4219f2cc7d56c95c228a4a1fcc26b9a0d0b (
plain)
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
|
#!/usr/bin/env python
import sys
sys.path.append('/home/dotcloud/env/lib/python2.6/site-packages')
from sandbox import Sandbox, SandboxConfig
from os import path
importname = sys.argv[1]
if importname.endswith('.py'):
importname = importname[:len(importname)-3]
else:
print >> sys.stderr, 'Filename did not end with .py for some reason...'
sys.exit(2)
sys.path.insert(0, path.expanduser('~/submissions'))
sys.dont_write_bytecode = True
def run():
submission = __import__(importname)
if submission.test() == 1:
return 100
else:
return 0
config = SandboxConfig()
config.timeout = 5
config.allowModule(importname, 'test')
sandbox = Sandbox(config)
score = sandbox.call(run)
print score
|