コード例 #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()

    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."
コード例 #2
0
ファイル: submit.py プロジェクト: MilesShipman/FinalProject
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."
コード例 #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()

    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."
コード例 #4
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.")
コード例 #5
0
ファイル: submit.py プロジェクト: jonhilgart22/CS6476
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."
コード例 #6
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."
コード例 #7
0
ファイル: submit.py プロジェクト: mittonface/photo9
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."
コード例 #8
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.")
コード例 #9
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.")
コード例 #10
0
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.")
コード例 #11
0
ファイル: submit.py プロジェクト: jotielim/CS8803-O02
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."
コード例 #12
0
ファイル: submit.py プロジェクト: Strongtheory/Projects
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.")