summaryrefslogtreecommitdiffstats
path: root/graders/lab1.py
blob: 86e595fef8d510e9a0061da17606d831c07c789e (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
#!/usr/bin/env python

from sandbox import Sandbox, SandboxConfig
import sys
from os import path

importname = sys.argv[1]
if importname.endswith('.py'):
	importname = importname[:len(importname)-3]
else:
	print '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():
	exec("import %s as submission" % 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