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 #2
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 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 #5
0
 def team_id_validator(cls, value):
     error_message = "{} is not a valid team id".format(value)
     team_key_error = {"team_id": error_message}
     if Team.validate_key_name(value) is False:
         return team_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_valid_team_key(self):
     self.assertEqual(Team.validate_key_name(self.valid_team_key), True)
     self.assertEqual(Team.validate_key_name(self.valid_team_key2), True)
 def test_invalid_team_key(self):
     self.assertEqual(Team.validate_key_name(self.invalid_team_key), False)
     self.assertEqual(Team.validate_key_name(self.invalid_team_key2), False)
     self.assertEqual(Team.validate_key_name(self.invalid_team_key3), False)
Beispiel #10
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 #11
0
 def team_id_validator(cls, value):
     error_message = "{} is not a valid team id".format(value)
     team_key_error = { "team_id": error_message}
     if Team.validate_key_name(value) is False:
         return team_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_invalid_team_key(self):
     self.assertEqual(Team.validate_key_name(self.invalid_team_key), False)
     self.assertEqual(Team.validate_key_name(self.invalid_team_key2), False)
     self.assertEqual(Team.validate_key_name(self.invalid_team_key3), False)
 def test_valid_team_key(self):
     self.assertEqual(Team.validate_key_name(self.valid_team_key), True)
     self.assertEqual(Team.validate_key_name(self.valid_team_key2), True)