diff options
Diffstat (limited to 'graders')
-rwxr-xr-x | graders/lab1.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/graders/lab1.py b/graders/lab1.py new file mode 100755 index 0000000..86e595f --- /dev/null +++ b/graders/lab1.py @@ -0,0 +1,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 |