def update_event_data_files( global_config, year, event, directory ):
    
    result = False
    
    event_code = CompAlias.get_eventcode_by_alias(event)
    
    my_team = global_config['my_team']
    # for now, we only support updating files in the EventData directory, so only continue if that's the 
    # directory that was specified.
    if directory.upper() == 'EVENTDATA':
        # call each of the get_event_xxx() functions to attempt to retrieve the json data. This action
        # will also store the json payload to the EventData directory completing the desired 
        # operation
        get_event_standings_json( global_config, year, event_code )
        get_event_rank_list_json( global_config, year, event_code )
        get_event_stats_json( global_config, year, event_code, 'oprs' )
        get_event_matchresults_json(global_config, year, event_code, 'qual')
        get_event_matchresults_json(global_config, year, event_code, 'quarters')
        get_event_matchresults_json(global_config, year, event_code, 'semis')
        get_event_matchresults_json(global_config, year, event_code, 'finals')
        get_event_matchresults_json(global_config, year, event_code, 'qual', my_team)
        get_event_matchresults_json(global_config, year, event_code, 'quarters', my_team)
        get_event_matchresults_json(global_config, year, event_code, 'semis', my_team)
        get_event_matchresults_json(global_config, year, event_code, 'finals', my_team)
        get_event_matchschedule_json(global_config, year, event_code, my_team)
        get_event_matchschedule_json(global_config, year, event_code)
        
        result = True
        
    return result
def get_comp_and_eventcode_list(season=None):

    my_config = ScoutingAppMainWebServer.global_config
    complist = list()
    if season == None:
        season = my_config["this_season"]
    this_comp = my_config["this_competition"]
    complist.append((this_comp, CompAlias.get_eventcode_by_alias(this_comp)))

    other_competitions = CompAlias.get_comp_and_eventcode_list()

    for comp in other_competitions:
        if comp and comp[0].upper() != my_config["this_competition"].upper():
            complist.append(comp)

    return complist
def map_comp_to_event_code(comp):
    my_config = ScoutingAppMainWebServer.global_config

    if len(comp) > 4:
        season_str = comp[-4:]
        if season_str[0] == "2" and season_str[1] == "0" and season_str[2] == "1":
            comp = comp[0:-4]

    event_info = CompAlias.get_event_by_alias(comp)
    if event_info != None:
        comp = event_info.event_code

    return comp
def get_comp_list():

    my_config = ScoutingAppMainWebServer.global_config
    complist = list()
    season = my_config["this_season"]
    this_comp = my_config["this_competition"]
    complist.append(this_comp + season)

    other_competitions = CompAlias.get_comp_alias_list()

    for comp in other_competitions:
        if comp and comp.upper() != my_config["this_competition"].upper():
            complist.append(comp + season)

    return complist
def map_event_code_to_short_comp(event_name, season=None):
    my_config = ScoutingAppMainWebServer.global_config

    if season == None:
        if event_name.startswith("201"):
            season = event_name[0:4]
        else:
            season = my_config["this_season"]

    if event_name.startswith("201"):
        comp = event_name[4:]
    else:
        comp = event_name
    event_info = CompAlias.get_event_by_code(comp)
    if event_info != None:
        comp = event_info.event_alias

    return comp
    
    # Parse the command line arguments
    (options,args) = parser.parse_args()

    global_config = {}
    
    ConfigUtils.read_config(global_config, './config/ScoutingAppConfig.txt')

    logger = Logger.get_logger('./config', 'logging.conf', 'scouting.fileproc')
    global_config['logger'] = logger

    # load the competition alias file if one is specified
    if options.comp_alias_file != '':
        comp_alias_file = './config/' + options.comp_alias_file        
        logger.debug('Loading Competition Alias file: %s' % comp_alias_file)
        CompAlias.read_comp_alias_config(comp_alias_file)

    session = DbSession.open_db_session((global_config['db_name'] + global_config['this_season']), DataModel)

    counter = 0
    done = False

    while not done:
        try:
            global_config['logger'].debug( 'Scanning for new files to process' )
            print 'Scanning for new files to process'
            start_time = datetime.datetime.now()
            
            competition = global_config['this_competition'] + global_config['this_season']
            competition_dir = './static/data/' + competition
            input_dir = competition_dir + '/ScoutingData/'