def update_team_data_files( global_config, year, event, directory, team=None ):
    
    global_config['logger'].debug( 'Updating Team DataFiles' )

    session = DbSession.open_db_session(global_config['db_name'] + year)
    comp = event+year

    result = False
    team_list = []
    if team == None or team == '':
        team_list = DataModel.getTeamsInNumericOrder(session, comp)
    else:
        team_list.append(team)
        
    # for now, we only support updating files in the TeamData directory, so only continue if that's the 
    # directory that was specified.
    if directory.upper() == 'TEAMDATA' or directory.upper() == 'EVENTDATA':
        for team_entry in team_list:
            
            # TODO: added a special test here to skip teams with a number greater than 10000. Some data
            # was erroneously entered with team numbers really high...
            if team_entry.team < 10000:
                get_team_info_json(global_config, comp, team_entry.team, store_json_file=True)
                get_team_score_json(global_config, team_entry.team, comp, store_json_file=True)
                get_team_score_breakdown_json(global_config, team_entry.team, comp, store_json_file=True)
                get_team_scouting_notes_json(global_config, comp, team_entry.team, store_json_file=True)           
                get_team_scouting_mediafiles_json(global_config, comp, str(team_entry.team), store_json_file=True)
                get_team_scouting_datafiles_json(global_config, comp, str(team_entry.team), store_json_file=True)
                get_team_scouting_data_summary_json(global_config, comp, team_entry.team, attr_filter=[], filter_name=None, store_json_file=True)
        result = True
        
    session.remove()
    return result
Ejemplo n.º 2
0
def get_team_list_json(global_config, comp):
    global team_info_dict
    
    global_config['logger'].debug( 'GET Team List For Competition %s', comp )
    session = DbSession.open_db_session(global_config['db_name'])

    web.header('Content-Type', 'application/json')
    result = []

    result.append('{ "teams" : [\n')

    team_list = DataModel.getTeamsInNumericOrder(session, comp)
    for team in team_list:
        team_info = None
        # TODO - Remove this hardcoded number for the valid team number. This check prevents
        # requesting information for invalid team numbers, which has been known to happen when
        # tablet operators enter bogus team numbers by mistake
        if team.team < 10000:
            team_info = DataModel.getTeamInfo(session, int(team.team))
            
        if team_info:
            result.append('   { "team_number": "%s", "nickname": "%s" }' % (team.team,team_info.nickname))
            result.append(',\n')
        
    if len(team_list) > 0:         
        result = result[:-1]

        result.append(' ] }\n')
        return ''.join(result)
    else:
        return get_team_list_json_from_tba(global_config, comp)
def get_page(global_config, access_level):
    global_config['logger'].debug( 'GET Home Page' )
    
    session = DbSession.open_db_session(global_config['db_name'] + global_config['this_season'])
    page = ''
            
    page += '<hr>'
    
    comp = global_config['this_competition'] + global_config['this_season']
    
    page += '<h3>FIRST FRC Competition Data' + '</h3>'
    page += '<hr>'
    page += '<ul>'
    page += '<li><a href="/events">FRC Events List</a></li>'
    if global_config.has_key('event_code'):
        event_code = global_config['event_code']
        page += '<li><a href="/eventstandings/%s">%s Info</a></li>' % (event_code,comp)
    page += '</ul>'
    page += '<hr>'
    page += '<h3> Team Scoring Summary' + '</h3>'
    page += '<hr>'
    page += '<ul>'
    page += '<li><a href="/rankchart">Team Rankings</a></li>'
    page += '<li><a href="/recalculaterankings">Recalculate Team Rankings</a></li>'
    
    page += '<li><a href="/static/attr/' + comp + '.csv"> ' + comp + '.csv</a></li>'
    other_competitions = global_config['other_competitions'].split(',')
    season = global_config['this_season']

    for comp in other_competitions:
        if comp and comp != global_config['this_competition']:
            page += '<li><a href="/static/attr/' + comp + season + '.csv"> ' + comp + season + '.csv</a></li>'
    page += '</ul>'
    page += '<hr>'
    page += '<h3> Team Links' + '</h3>'
    page += '<hr>'
    page += '<ul>'
    
    team_list_str = global_config['team_list']
    if team_list_str != None and team_list_str != '':
        if team_list_str.count(',') > 0:
            team_list = team_list_str.split(',')
            #team_list.sort()
            for team in team_list:
                page += '<li><a href="/teamdata/' + team + '">' + 'Team ' + team + '</a></li>'
        else:
            page += '<li><a href="/teamdata/' + team_list_str + '">' + 'Team ' + team_list_str + '</a></li>'
    else:
        comp = global_config['this_competition']
        team_list = DataModel.getTeamsInNumericOrder(session, comp+season)
        for entry in team_list:
            page += '<li><a href="/teamdata/' + str(entry.team) + '">' + 'Team ' + str(entry.team) + '</a></li>'
    page += '</ul>'
    session.remove()
    return page
Ejemplo n.º 4
0
def get_team_list_json(global_config, comp, store_json_file=False):
    global team_info_dict
    
    global_config['logger'].debug( 'GET Team List For Competition %s', comp )

    season = WebCommonUtils.map_comp_to_season(comp)
    session = DbSession.open_db_session(global_config['db_name'] + season)

    result = []

    result.append('{ "teams" : [\n')

    team_list = DataModel.getTeamsInNumericOrder(session, comp)
    for team in team_list:
        team_info = None
        # TODO - Remove this hardcoded number for the valid team number. This check prevents
        # requesting information for invalid team numbers, which has been known to happen when
        # tablet operators enter bogus team numbers by mistake
        if team.team < 10000:
            team_info = DataModel.getTeamInfo(session, int(team.team))
            
        if team_info:
            result.append('   { "team_number": "%s", "nickname": "%s" }' % (team.team,team_info.nickname))
            result.append(',\n')
        else:
            result.append('   { "team_number": "%s", "nickname": "%s" }' % (team.team,'Unknown'))
            result.append(',\n')
        
    if len(team_list) > 0:         
        result = result[:-1]
        result.append(' ] }\n')
        json_str = ''.join(result)
    else:
        json_str = get_team_list_json_from_tba(global_config, comp)

    if store_json_file is True:
        try:
            FileSync.put( global_config, '%s/EventData/%s.json' % (comp,'teams'), 'text', json_str)
        except:
            raise
        
    return json_str