Ejemplo n.º 1
0
    # const vars
    step_size = 0.0025
    step_limit = 5

    # debug vars, used to test slack integration w/o waiting
    use_cache = False
    cached_filename = 'cached_pokedata.json'
    search_timeout = 30

    position, address = get_pos_by_name(location_name)
    logger.info('location_name: %s', address)

    api = PGoApi()
    pokesearch = Pokesearch(api, auth_service, username, password, position)
    pokeslack = Pokeslack(rarity_limit, slack_webhook_url)

    if not use_cache or not os.path.exists(cached_filename):
        logger.info('searching starting at latlng: (%s, %s)', position[0],
                    position[1])
        pokesearch.login()
        while True:
            pokemons = []
            for pokemon in pokesearch.search(position[0], position[1],
                                             step_limit, step_size):
                pokemon_position = (pokemon['latitude'], pokemon['longitude'],
                                    0)
                distance = vincenty(position, pokemon_position).miles
                expires_in = pokemon['disappear_time'] - datetime.utcnow()
                logger.info(
                    "adding pokemon: %s - %s, rarity: %s, expires in: %s, distance: %s miles",