Exemplo n.º 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)
Exemplo n.º 2
0
def update_deferred(score, unint_attack_hist, freq, unintended_pts, end_time):
    curr_time = time.time()
    end_time = iso8601_to_timestamp(end_time)
    end_time = min(curr_time, end_time)
    for attack_id, start_time in unint_attack_hist.iteritems():
        attacker = attack_id.split('_')[0]
        pts = compute_unintended(start_time, end_time, freq, unintended_pts)
        compute_score(score, attacker, pts)
Exemplo n.º 3
0
def get_github_issue(repo_owner, repo_name, issue_no, github):
    '''Retrieve an issue on github.com using the given parameters.'''
    query = '/repos/%s/%s/issues/%s' % (repo_owner, repo_name, issue_no)
    r = github.get(query)
    if r is None:
        print('Could not get Issue from %s' % query)
        print('Response:', r)
        sys.exit(-1)
    else:
        print('[*] Successfully obtained issue #%s' % issue_no)
        print('[*] title:', r['title'])
        print('[*] creater:', r['user']['login'])
        dt = datetime.strptime(r['created_at'],'%Y-%m-%dT%H:%M:%SZ')
        # XXX do not assume it is in Korea, just use the current tz.
        open_time = dt + timedelta(hours = 9) # Change to the Korea time
        print('[*] open time:', open_time)
        title = r['title']
        submitter = r['user']['login']
        create_time = r['created_at']
        content = r['body']
        create_timestamp = int(iso8601_to_timestamp(create_time))
        return (title, submitter, create_timestamp, content)
Exemplo n.º 4
0
def get_issue_gen_time(noti):
    return iso8601_to_timestamp(noti['updated_at'])