def test_invalid_match_key(self):
     self.assertEqual(Match.validate_key_name(self.invalid_match_key),
                      False)
     self.assertEqual(Match.validate_key_name(self.invalid_match_key2),
                      False)
     self.assertEqual(Match.validate_key_name(self.invalid_match_key3),
                      False)
def main(key, url):
    print "Configuring GAE Remote API on {} to import {}".format(url, key)
    if 'localhost' in url:
        remote_api_stub.ConfigureRemoteApi(None, '/_ah/remote_api', local_auth_func, url)
    else:
        remote_api_stub.ConfigureRemoteApiForOAuth(url, '/_ah/remote_api')

    print "Loading data from The Blue Alliance requires an API key"
    print "Please go to https://thebluealliance.com/account and generate a read API key"
    apiv3_key = raw_input("Enter your API key: ")

    global AUTH_TOKEN
    AUTH_TOKEN = apiv3_key

    if Match.validate_key_name(key):
        match_data = fetch_match(key)
        store_match(match_data)

    elif Event.validate_key_name(key):
        update_event(key)
    elif Team.validate_key_name(key):
        team_data = fetch_team(key)
        store_team(team_data)
    elif key.isdigit():
        event_keys = [event['key'] for event in fetch_endpoint('events/{}'.format(key))]
        for event in event_keys:
            update_event(event)
    else:
        print "Unknown key :("
Beispiel #3
0
def main(key, url):
    print "Configuring GAE Remote API on {} to import {}".format(url, key)
    if 'localhost' in url:
        remote_api_stub.ConfigureRemoteApi(None, '/_ah/remote_api',
                                           local_auth_func, url)
    else:
        remote_api_stub.ConfigureRemoteApiForOAuth(url, '/_ah/remote_api')

    print "Loading data from The Blue Alliance requires an API key"
    print "Please go to https://thebluealliance.com/account and generate a read API key"
    apiv3_key = raw_input("Enter your API key: ")

    global AUTH_TOKEN
    AUTH_TOKEN = apiv3_key

    if Match.validate_key_name(key):
        match_data = fetch_match(key)
        store_match(match_data)

    elif Event.validate_key_name(key):
        update_event(key)
    elif Team.validate_key_name(key):
        team_data = fetch_team(key)
        store_team(team_data)
    elif key.isdigit():
        event_keys = [
            event['key'] for event in fetch_endpoint('events/{}'.format(key))
        ]
        for event in event_keys:
            update_event(event)
    else:
        print "Unknown key :("
def match_short(match_key):
    if not Match.validate_key_name(match_key):
        return ''
    match_id = match_key.split('_')[1]
    if match_id.startswith('qm'):
        return 'Q{}'.format(match_id[2:])
    return match_id.replace('m', '-').upper()
def match_short(match_key):
    if not Match.validate_key_name(match_key):
        return ''
    match_id = match_key.split('_')[1]
    if match_id.startswith('qm'):
        return 'Q{}'.format(match_id[2:])
    return match_id.replace('m', '-').upper()
def main(key, url):
    print "Configuring GAE Remote API on {} to import {}".format(url, key)
    if 'localhost' in url:
        remote_api_stub.ConfigureRemoteApi(None, '/_ah/remote_api',
                                           local_auth_func, url)
    else:
        remote_api_stub.ConfigureRemoteApiForOAuth(url, '/_ah/remote_api')

    print "Loading data from The Blue Alliance requires an API key"
    print "Please go to https://thebluealliance.com/account and generate a read API key"
    apiv3_key = raw_input("Enter your API key: ")

    global AUTH_TOKEN
    AUTH_TOKEN = apiv3_key

    if Match.validate_key_name(key):
        match_data = fetch_match(key)
        store_match(match_data)

    elif Event.validate_key_name(key):
        event_data = fetch_event(key)
        event = store_event(event_data)

        event_teams = fetch_event_detail(key, 'teams')
        teams = map(store_team, event_teams)
        map(lambda t: store_eventteam(t, event), teams)

        event_matches = fetch_event_detail(key, 'matches')
        map(store_match, event_matches)

        event_rankings = fetch_event_detail(key, 'rankings')
        store_eventdetail(event, 'rankings2',
                          event_rankings['rankings'] if event_rankings else [])

        event_alliances = fetch_event_detail(key, 'alliances')
        store_eventdetail(event, 'alliance_selections', event_alliances)

        event_awards = fetch_event_detail(key, 'awards')
        map(lambda t: store_award(t, event), event_awards)

    elif Team.validate_key_name(key):
        team_data = fetch_team(key)
        store_team(team_data)

    else:
        print "Unknown key :("
def main(key, url):
    print "Configuring GAE Remote API on {} to import {}".format(url, key)
    if 'localhost' in url:
        remote_api_stub.ConfigureRemoteApi(None, '/_ah/remote_api', local_auth_func, url)
    else:
        remote_api_stub.ConfigureRemoteApiForOAuth(url, '/_ah/remote_api')

    print "Loading data from The Blue Alliance requires an API key"
    print "Please go to https://thebluealliance.com/account and generate a read API key"
    apiv3_key = raw_input("Enter your API key: ")

    global AUTH_TOKEN
    AUTH_TOKEN = apiv3_key

    if Match.validate_key_name(key):
        match_data = fetch_match(key)
        store_match(match_data)

    elif Event.validate_key_name(key):
        event_data = fetch_event(key)
        event = store_event(event_data)

        event_teams = fetch_event_detail(key, 'teams')
        teams = map(store_team, event_teams)
        map(lambda t: store_eventteam(t, event), teams)

        event_matches = fetch_event_detail(key, 'matches')
        map(store_match, event_matches)

        event_rankings = fetch_event_detail(key, 'rankings')
        store_eventdetail(event, 'rankings2', event_rankings['rankings'] if event_rankings else [])

        event_alliances = fetch_event_detail(key, 'alliances')
        store_eventdetail(event, 'alliance_selections', event_alliances)

        event_awards = fetch_event_detail(key, 'awards')
        map(lambda t: store_award(t, event), event_awards)

    elif Team.validate_key_name(key):
        team_data = fetch_team(key)
        store_team(team_data)

    else:
        print "Unknown key :("
Beispiel #8
0
 def match_id_validator(cls, value):
     error_message = "{} is not a valid match id".format(value)
     match_key_error = {"match_id": error_message}
     if Match.validate_key_name(value) is False:
         return match_key_error
 def is_valid_model_key(cls, key):
     return (Team.validate_key_name(key) or Event.validate_key_name(key)
             or Match.validate_key_name(key)
             or District.validate_key_name(key))
 def is_valid_model_key(cls, key):
     return (Team.validate_key_name(key) or Event.validate_key_name(key)
             or Match.validate_key_name(key)
             or key[3:] in DistrictType.abbrevs)
 def test_invalid_match_key(self):
     self.assertEqual(Match.validate_key_name(self.invalid_match_key), False)
     self.assertEqual(Match.validate_key_name(self.invalid_match_key2), False)
     self.assertEqual(Match.validate_key_name(self.invalid_match_key3), False)
 def test_valid_match_key(self):
     self.assertEqual(Match.validate_key_name(self.valid_match_key), True)
Beispiel #13
0
 def is_valid_model_key(cls, key):
     return (Team.validate_key_name(key) or
         Event.validate_key_name(key) or
         Match.validate_key_name(key) or
         key[3:] in DistrictType.abbrevs)
Beispiel #14
0
 def match_id_validator(cls, value):
     error_message = "{} is not a valid match id".format(value)
     match_key_error = { "match_id": error_message}
     if Match.validate_key_name(value) is False:
         return match_key_error
 def is_valid_model_key(cls, key):
     return (Team.validate_key_name(key) or
         Event.validate_key_name(key) or
         Match.validate_key_name(key) or
         District.validate_key_name(key))
 def test_valid_match_key(self):
     self.assertEqual(Match.validate_key_name(self.valid_match_key), True)