示例#1
0
def get_team_list_json_from_tba(global_config, comp):
    
    global_config['logger'].debug( 'GET Team List For Competition From TBA %s', comp )

    result = []
    result.append('{ "teams" : ')
    
    event_code = WebCommonUtils.map_comp_to_event_code(comp)
    season = WebCommonUtils.map_comp_to_season(comp)
    
    url_str = '/api/v2/event/%s%s/teams' % (season,event_code.lower())
    try:
        # retrieve the string itself as a formatted json string
        event_data = TbaIntf.get_from_tba(url_str)
    except:
        event_data = '[ ]'

    result.append( event_data )
    result.append('  }\n')
    return ''.join(result)
示例#2
0
def get_team_list_json_from_tba(global_config, comp):
    
    global_config['logger'].debug( 'GET Team List For Competition From TBA %s', comp )

    web.header('Content-Type', 'application/json')
    result = []
    result.append('{ "teams" : ')
    
    event_code = WebCommonUtils.map_comp_to_event_code(comp)
    season = WebCommonUtils.map_comp_to_season(comp)
    
    url_str = 'http://www.thebluealliance.com/api/v2/event/%s%s/teams?X-TBA-App-Id=frc1073:scouting-system:v01' % (season,event_code)
    event_data = ''
    try:
        event_data = urllib2.urlopen(url_str).read()
    except:
        event_data = '[ ]'
        pass

    result.append( event_data )
    result.append('  }\n')
    return ''.join(result)