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() app_data_dir = os.path.abspath(".bonnie") submission = Submission('cs6250', 'Project-6', filenames=["dns_firewall.py"], exclude=False, environment=args.environment, provider=args.provider, app_data_dir=app_data_dir) while not submission.poll(): time.sleep(3.0) if submission.result(): print json.dumps(submission.result(), indent=4) elif submission.error_report(): print submission.error_report() else: print "Unknown error."
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') parser.add_argument('--writeup', action='store_true', default=False) args = parser.parse_args() quiz = 'finalproject' filenames = ["finalproject.pdf"] if not os.path.isfile(filenames[0]): print "%s is not present in the directory." % filenames[0] return elif (os.stat(filenames[0]).st_size >> 20) >= 6: print "Please keep your files under 6MB." return submission = Submission('cs6475', quiz, filenames = filenames, environment = args.environment, provider = args.provider) while not submission.poll(): time.sleep(3.0) if submission.result(): result = submission.result() print json.dumps(result, indent=4) elif submission.error_report(): error_report = submission.error_report() print json.dumps(error_report, indent=4) else: print "Unknown error."
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() files = ['pr2_sandbox.c'] quiz = 'pr2_sandbox' app_data_dir = os.path.abspath(".bonnie") submission = Submission('cs8803-02', quiz, filenames=files, environment=args.environment, provider=args.provider) while not submission.poll(): time.sleep(3.0) if submission.result(): print submission.result() elif submission.error_report(): print submission.error_report() else: print "Unknown error."
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') parser.add_argument('--writeup', action='store_true', default=False) args = parser.parse_args() if args.writeup: quiz = 'writeup9' filenames = ["assignment9.pdf"] else: quiz = 'assignment9' filenames = ["assignment9.py"] if not os.path.isfile(filenames[0]): print "%s is not present in the directory." % filenames[0] return elif (os.stat(filenames[0]).st_size >> 20) >= 6: print "Please keep your files under 6MB." return submission = Submission('cs6475', quiz, filenames=filenames, environment=args.environment, provider=args.provider) while not submission.poll(): time.sleep(3.0) if submission.result(): result = submission.result() print json.dumps(result, indent=4) elif submission.error_report(): error_report = submission.error_report() print json.dumps(error_report, indent=4) else: print "Unknown error."
def main(): parser = argparse.ArgumentParser( description='Submits code to the Udacity site.') parser.add_argument('--assignment', choices=[ 'P1', 'P2', 'P3', 'error-check', 'error-check-2', 'error-check-3' ], required=True) parser.add_argument('--provider', choices=['gt', 'udacity'], default='gt') parser.add_argument( '--environment', choices=['local', 'development', 'staging', 'production'], default='production') parser.add_argument('--files', type=str, nargs='+', default=[]) args = parser.parse_args() app_data_dir = os.path.abspath(".bonnie") files = args.files agent_file = os.path.join('ravensproject', 'Agent.java') if agent_file not in files: files.append(agent_file) forbidden_exts = ['.class', '.pyc'] expected_exts = ['.java', '.py'] def ext(file): _, extension = os.path.splitext(file) return extension for file in files: if ext(file) in forbidden_exts: print("Wait! You don't really want to submit a", ext(file), "file! Please submit your .java or .py files only.") return elif ext(file) not in expected_exts: print( "Warning: you're submitting a", ext(file), "file. This may not be what you intend. Press ctrl-C or cmd-C now to cancel..." ) time.sleep(3.0) submission = Submission('cs7637', args.assignment, filenames=args.files, environment=args.environment, provider=args.provider, app_data_dir=app_data_dir) while not submission.poll(): time.sleep(3.0) if submission.result(): result = submission.result() if 'Execution' in result.get('Error', {}): eprint('Execution error!') eprint(result['Error']['Execution']) elif 'Build' in result.get('Error', {}): eprint('Build error!') eprint(result['Error']['Build']) else: if ('Problems' in result) & ('Sets' in result): print('Problem,Correct?,Correct Answer,Agent\'s Answer') problems = result['Problems'] for key in problems: problem = problems[key] success = '1' if problem['Correct?'] == 'Correct' else '0' print(','.join([ '"' + problem['Problem'] + '"', success, problem['Correct Answer'], problem['Agent\'s Answer'] ])) eprint(json.dumps(result['Sets'], indent=4)) else: eprint(json.dumps(result, indent=4)) elif submission.error_report(): error_report = submission.error_report() eprint(json.dumps(error_report, indent=4)) else: eprint("Unknown error.")
def main(): parser = argparse.ArgumentParser( description='Submits code to the Udacity site.') parser.add_argument('quiz', choices=[ 'echo', 'transfer', 'gfclient', 'gfserver', 'gfclient_mt', 'gfserver_mt' ]) parser.add_argument('--provider', choices=['gt', 'udacity'], default='gt') parser.add_argument( '--environment', choices=['local', 'development', 'staging', 'production'], default='production') args = parser.parse_args() path_map = { 'echo': 'echo', 'transfer': 'transfer', 'gfclient': 'gflib', 'gfserver': 'gflib', 'gfclient_mt': 'mtgf', 'gfserver_mt': 'mtgf' } quiz_map = { 'echo': 'pr1_echo_client_server', 'transfer': 'pr1_transfer', 'gfclient': 'pr1_gfclient', 'gfserver': 'pr1_gfserver', 'gfclient_mt': 'pr1_gfclient_mt', 'gfserver_mt': 'pr1_gfserver_mt' } files_map = { 'pr1_echo_client_server': ['echoclient.c', 'echoserver.c', '../readme-student'], 'pr1_transfer': ['transferclient.c', 'transferserver.c'], 'pr1_gfclient': ['gfclient.c'], 'pr1_gfserver': ['gfserver.c'], 'pr1_gfclient_mt': ['gfclient_download.c'], 'pr1_gfserver_mt': ['gfserver_main.c', 'handler.c'] } quiz = quiz_map[args.quiz] os.chdir(path_map[args.quiz]) submission = Submission('cs8803-02', quiz, filenames=files_map[quiz], 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.result(): result = submission.result() filename = "%s-result-%s.json" % (args.quiz, timestamp) with open(filename, "w") as fd: json.dump(result, fd, indent=4, separators=(',', ': ')) for t in result['tests']: description = '{:70s}'.format(t['description'][:69] + ":") passfail = t['output']['passfail'] print '%s %s' % (description, passfail.rjust(9)) print "(Details available in %s.)" % os.path.join( path_map[args.quiz], filename) elif submission.error_report(): error_report = submission.error_report() filename = "%s-error-report-%s.json" % (args.quiz, timestamp) with open(filename, "w") as fd: json.dump(error_report, fd, indent=4, separators=(',', ': ')) print "Something went wrong. Please see the error report in %s." % os.path.join( path_map[args.quiz], filename) else: print "Unknown error."
def main(): parser = argparse.ArgumentParser(description='Submits code to the Udacity site.') parser.add_argument('--assignment', choices = ['P1', 'P2', 'P3', 'error-check', 'error-check-2', 'error-check-3'], required=True) parser.add_argument('--provider', choices = ['gt', 'udacity'], default = 'gt') parser.add_argument('--environment', choices = ['local', 'development', 'staging', 'production'], default = 'production') parser.add_argument('--files', type=str, nargs='+', default = []) args = parser.parse_args() app_data_dir = os.path.abspath(".bonnie") files = args.files agent_file = 'Agent.py' language_file = 'language.txt' if agent_file not in files: files.append(agent_file) if language_file not in files: files.append(language_file) forbidden_exts = ['.class', '.pyc'] expected_exts = ['.java', '.py', '.txt'] def ext(file): _, extension = os.path.splitext(file) return extension for file in files: if ext(file) in forbidden_exts: print("Wait! You don't really want to submit a", ext(file), "file! Please submit your .java or .py files only.") return elif ext(file) not in expected_exts: print ("Warning: you're submitting a", ext(file), "file. This may not be what you intend. Press ctrl-C or cmd-C now to cancel...") time.sleep(3.0) submission = Submission('cs7637', args.assignment, filenames = args.files, environment = args.environment, provider = args.provider, app_data_dir = app_data_dir) while not submission.poll(): time.sleep(3.0) if submission.result(): result = submission.result() if 'Execution' in result.get('Error', {}): eprint('Execution error!') #eprint(result['Error']['Execution']) eprint(json.dumps(result['Error'], indent=4)) elif 'Build' in result.get('Error', {}): eprint('Build error!') eprint(result['Error']['Build']) else: if ('Problems' in result) & ('Sets' in result): print('Problem,Correct?,Correct Answer,Agent\'s Answer') problems = result['Problems'] for key in problems: problem = problems[key] success = '1' if problem['Correct?'] == 'Correct' else '0' print(','.join([ '"'+problem['Problem']+'"',success,problem['Correct Answer'],problem['Agent\'s Answer'] ])) eprint(json.dumps(result['Sets'], indent=4)) else: eprint(json.dumps(result, indent=4)) elif submission.error_report(): error_report = submission.error_report() eprint(json.dumps(error_report, indent=4)) else: eprint("Unknown error.")