-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubmit.py
47 lines (35 loc) · 1.41 KB
/
submit.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
44
45
46
47
import time
import os
import sys
import argparse
import json
import datetime
from bonnie.submission import Submission
def main():
parser = argparse.ArgumentParser(description='Submits code to the Udacity site.')
parser.add_argument('--provider', choices = ['gt', 'udacity'], default = 'gt')
parser.add_argument('--environment', choices = ['local', 'development', 'staging', 'production'], default = 'production')
args = parser.parse_args()
quiz = 'lab2'
submission = Submission('cse6220', quiz,
filenames = ["ForceBarnesHut.cc", "ForceBarnesHut.hh",
"MortonKeyCalculator.cc", "MortonKeyCalculator.hh"],
environment = args.environment,
provider = args.provider)
timestamp = "{:%Y-%m-%d-%H-%M-%S}".format(datetime.datetime.now())
while not submission.poll():
time.sleep(3.0)
if submission.feedback():
if submission.console():
sys.stdout.write(submission.console())
filename = "%s-result-%s.json" % (quiz, timestamp)
with open(filename, "w") as fd:
json.dump(submission.feedback(), fd, indent=4, separators=(',', ': '))
print "(Details available in %s.)" % filename
elif submission.error_report():
error_report = submission.error_report()
print json.dumps(error_report, indent=4)
else:
print "Unknown error."
if __name__ == '__main__':
main()