コード例 #1
0
def main(new_round, round_number): 
    """
    """
    choices = read_choices(round_number)

    print(len(choices))

    if len(choices) == 0: 

        with open('intro.txt') as file:

            text = file.read() 

            text = text.format(get_fixtures_text(new_round))

        uname, pword = utils.get_facebook_details()

        client = fbcb.login_to_facebook(uname, pword)

        thread_type = client.fetchThreadInfo('3365583033489198')['3365583033489198'].type

        fbcb.send_message(text, '3365583033489198', thread_type, client)

        return True  

    save_results(round_number)

    points = find_points(round_number, choices)

    utils.input_into_sql(points, 'points', 'append')

    send_weekly_message(new_round, round_number,'3365583033489198')
コード例 #2
0
def initialize_scores(choices):
    '''
    '''
    df = {k:0 for k in choices.keys()}

    scores = pd.DataFrame(df, index = ['scores']).T

    scores = scores.reset_index()

    scores['round'] = '1'

    scores.columns = ['name', 'score', 'round']
    
    utils.input_into_sql(scores, 'scores', 'append')
コード例 #3
0
ファイル: crontab_test.py プロジェクト: tobygaskell/tesseract
def save_current_round(round_number):
    '''
    '''
    DW = main.DP_round()

    DP = main.draw_weekend(round_number)

    data = pd.DataFrame({
        "round_number": [round_number],
        'draw_weekend': [DW],
        "double_points_weekend": [DP]
    })

    utils.input_into_sql(data, 'round_info', 'append')

    return True
コード例 #4
0
def save_results(round_number): 
    """
    """
    played = get_team_lists(round_number)[4]

    data = {'team':[],'apponent': [],'result': [],'scores': []} 

    for i in played: 

        data['team'].append(i['homeTeam']['team_name'])

        data['apponent'].append(i['awayTeam']['team_name'])

        data['result'].append(get_result(i['homeTeam']['team_name'], round_number))

        data['scores'].append('{} - {}'.format(i['goalsHomeTeam'],i['goalsAwayTeam']))

        data['team'].append(i['awayTeam']['team_name'])

        data['apponent'].append(i['homeTeam']['team_name'])

        data['result'].append(get_result(i['awayTeam']['team_name'], round_number))

        data['scores'].append('{} - {}'.format(i['goalsAwayTeam'],i['goalsHomeTeam']))

    data['round'] = round_number

    df = pd.DataFrame(data)

    return utils.input_into_sql(df, 'results', 'append')
コード例 #5
0
def add_dummy_added_info():

    for i in range(int(utils.get_current_round())):

        round = i + 1

        DW = main.DP_round()

        DP = main.draw_weekend(round)

        data = pd.DataFrame({
            'round_number': [round],
            'draw_weekend': [DW],
            'double_points_weekend': [DP]
        })

        utils.input_into_sql(data, 'round_info', 'append')
コード例 #6
0
def add_dummy_choices(num_of_players):

    players = [
        ''.join(random.choice(string.ascii_uppercase) for _ in range(10))
        for i in range(num_of_players)
    ]

    for i in range(int(utils.get_current_round())):

        for name in players:

            choice = random.choice(teams)

            data = pd.DataFrame({
                'name': [name],
                'choice': [choice],
                'round': [(i + 1)]
            })

            utils.input_into_sql(data, 'choices', 'append')