示例#1
0
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 = 'writeup1'

    require_pledges()

    filelist = glob.glob('image1.*')
    if len(filelist) != 1:
        raise RuntimeError(
            "There can only be one image file named image1.<EXT>")
    elif os.path.splitext(filelist[0])[-1][1:] not in IMG_EXTS:
        raise RuntimeError(
            "The image file extension must be one of the following types: {!s}"
            .format(IMG_EXTS))
    files = ['assignment1.pdf', filelist[0]]

    print "Submission processing...\n"
    submission = Submission('cs6475',
                            quiz,
                            filenames=files,
                            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("\n(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.")
示例#2
0
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('part', choices=['ps06', 'ps06_report'])

    args = parser.parse_args()
    quiz = args.part

    if quiz == "ps06":
        filenames = ["ps6.py", "experiment.py"]
    else:
        filenames = ['ps06_report.pdf', "experiment.py"]

    require_pledges()

    print "Submission processing...\n"
    submission = Submission('cs6476',
                            quiz,
                            filenames=filenames,
                            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."
示例#3
0
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."
示例#4
0
文件: submit.py 项目: sanzo1/cs6475-1
def main(args):

    check_files(args.filenames)

    require_pledges()

    print "Submitting files..."
    submission = Submission('cs6475',
                            args.quiz,
                            filenames=args.filenames,
                            environment=args.environment,
                            provider=args.provider)

    print "\nWaiting for results..."
    while not submission.poll():
        print "    Refresh in {} seconds...".format(REFRESH_TIME)
        time.sleep(REFRESH_TIME)
    print "    Done!"

    print "\nResults:\n--------"
    if submission.feedback():

        if submission.console():
            print submission.console()

        timestamp = "{:%Y-%m-%d-%H-%M-%S}".format(datetime.datetime.now())
        filename = "%s-result-%s.json" % (args.quiz, timestamp)

        with open(filename, "w") as fd:
            json.dump(submission.feedback(),
                      fd,
                      indent=4,
                      separators=(',', ': '))

        print("\n(Details available in %s)\n" % filename)

    elif submission.error_report():
        error_report = submission.error_report()
        print(json.dumps(error_report, indent=4))

    else:
        print("Unknown error.")
示例#5
0
def main(args):

    # Look for a set of 4-8 images in the current directory
    IMG_EXTS = ["png", "jpeg", "jpg", "gif", "tiff", "tif", "raw", "bmp"]
    image_files = glob.glob('image_[1-8].*')
    extensions = set(
        map(lambda x: os.path.splitext(x)[-1][1:].lower(), image_files))
    if not (4 <= len(image_files) <= 8):
        raise RuntimeError(
            "Wrong number of images found in submission folder. " +
            "You must submit at least 4 images and no more than 8.")
    elif 0 < len(extensions) < 1:
        raise RuntimeError(
            "Wrong number of image types found in submission folder " +
            "All images must be of only one type. Choose from: {!s}".format(
                IMG_EXTS))
    args.filenames.extend(image_files)

    final_files = glob.glob('final.*')
    extensions = set(
        map(lambda x: os.path.splitext(x)[-1][1:].lower(), final_files))
    if len(extensions) != 1:
        raise RuntimeError(
            "Wrong number of final images found in submission folder. " +
            "There must be exactly one 'final.<EXT>' image file.")
    args.filenames.extend(final_files)

    check_files(args.filenames)

    require_pledges()

    print "Submitting files..."
    submission = Submission('cs6475',
                            args.quiz,
                            filenames=args.filenames,
                            environment=args.environment,
                            provider=args.provider,
                            max_zip_size=33 * 2**20)

    print "\nWaiting for results..."
    while not submission.poll():
        print "    Refresh in {} seconds...".format(REFRESH_TIME)
        time.sleep(REFRESH_TIME)
    print "    Done!"

    print "\nResults:\n--------"
    if submission.feedback():

        if submission.console():
            print submission.console()

        timestamp = "{:%Y-%m-%d-%H-%M-%S}".format(datetime.datetime.now())
        filename = "%s-result-%s.json" % (args.quiz, timestamp)

        with open(filename, "w") as fd:
            json.dump(submission.feedback(),
                      fd,
                      indent=4,
                      separators=(',', ': '))

        print("\n(Details available in %s)\n" % filename)

    elif submission.error_report():
        error_report = submission.error_report()
        print(json.dumps(error_report, indent=4))

    else:
        print("Unknown error.")