Example #1
0
def show_score(token, config_file):
    config = load_config(config_file)
    scoreboard_url = config['score_board']
    freq = float(config['round_frequency'])
    unintended_pts = float(config['unintended_pts'])
    end_time = config['end_time']
    start_time = config['start_time']
    path = get_github_path(scoreboard_url)
    g = Github(config['player'], token)
    if g.get('/repos/' + path) is None:
        print('[*] Failed to access the repository %s' % path)
        sys.exit()
    r = g.get('/repos/' + path + '/contents/' + 'score.csv')
    if r is None:
        print('[*] Failed to get the score file.')
        sys.exit()
    csv = decode_content(r)
    display_score(csv, freq, unintended_pts, end_time)

    hour_from_start = 0
    log = {}

    graph_start_time = int(iso8601_to_timestamp(start_time))
    if is_timeover(config):
        graph_end_time = int(iso8601_to_timestamp(end_time))
    else:
        graph_end_time = int(time.time())

    for i in range(graph_start_time, graph_end_time, 3600):
        log[hour_from_start] = display_score(csv, freq, unintended_pts,
                                             end_time, i)
        hour_from_start = hour_from_start + 1

    make_html(log, config)
Example #2
0
    parser.add_argument("-i",
                        "--issue",
                        metavar="int",
                        required=True,
                        help="specify the GitHub Issue id")

    args = parser.parse_args()

    config = load_config(args.conf)

    github = Github(config['player'], args.token)

    scoreboard = prepare_scoreboard_repo(config['score_board'])

    # load comments
    comments = github.get("/repos/{}/{}/issues/{}/comments".format(
        config['repo_owner'], args.repo, args.issue))

    github_name = comments[0]['user']['login']

    # get student id and public key id

    matches = re.match(
        r"My NetID is (\w+), ?([\w| ]+), and my pub key id is (\w+)",
        comments[0]['body'])
    net_id = matches.group(1)
    name = matches.group(2)
    key_id = matches.group(3)

    print(
        "Found github username [{}], student id [{}], student name [{}], and key id [{}]"
        .format(github_name, net_id, name, key_id))