Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tejado committed Jul 29, 2016
2 parents 1b35513 + fbe8030 commit e4a2852
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
21 changes: 11 additions & 10 deletions examples/spiral_poi_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def init_config():
load.update(json.load(data))

# Read passed in Arguments
required = lambda x: not x in load
required = lambda x: x not in load
parser.add_argument("-a", "--auth_service", help="Auth Service ('ptc' or 'google')",
required=required("auth_service"))
parser.add_argument("-u", "--username", help="Username", required=required("username"))
Expand Down Expand Up @@ -178,14 +178,15 @@ def find_poi(api, lat, lng):
timestamps = [0,] * len(cell_ids)
api.get_map_objects(latitude = util.f2i(lat), longitude = util.f2i(lng), since_timestamp_ms = timestamps, cell_id = cell_ids)
response_dict = api.call()
if 'status' in response_dict['responses']['GET_MAP_OBJECTS']:
if response_dict['responses']['GET_MAP_OBJECTS']['status'] == 1:
for map_cell in response_dict['responses']['GET_MAP_OBJECTS']['map_cells']:
if 'wild_pokemons' in map_cell:
for pokemon in map_cell['wild_pokemons']:
pokekey = get_key_from_pokemon(pokemon)
pokemon['hides_at'] = time.time() + pokemon['time_till_hidden_ms']/1000
poi['pokemons'][pokekey] = pokemon
if (response_dict['responses']):
if 'status' in response_dict['responses']['GET_MAP_OBJECTS']:
if response_dict['responses']['GET_MAP_OBJECTS']['status'] == 1:
for map_cell in response_dict['responses']['GET_MAP_OBJECTS']['map_cells']:
if 'wild_pokemons' in map_cell:
for pokemon in map_cell['wild_pokemons']:
pokekey = get_key_from_pokemon(pokemon)
pokemon['hides_at'] = time.time() + pokemon['time_till_hidden_ms']/1000
poi['pokemons'][pokekey] = pokemon

# time.sleep(0.51)
# new dict, binary data
Expand All @@ -195,7 +196,7 @@ def find_poi(api, lat, lng):
print_gmaps_dbug(coords)

def get_key_from_pokemon(pokemon):
return '{}-{}'.format(pokemon['spawnpoint_id'], pokemon['pokemon_data']['pokemon_id'])
return '{}-{}'.format(pokemon['spawn_point_id'], pokemon['pokemon_data']['pokemon_id'])

def print_gmaps_dbug(coords):
url_string = 'http://maps.googleapis.com/maps/api/staticmap?size=400x400&path='
Expand Down
7 changes: 7 additions & 0 deletions pgoapi/rpc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ def _build_sub_requests(self, mainrequest, subrequest_list):
r.append(i)
except Exception as e:
self.log.warning('Argument %s with value %s unknown inside %s (Exception: %s)', key, i, proto_name, str(e))
elif isinstance(value, dict):
for k in value.keys():
try:
r = getattr(subrequest_extension, key)
setattr(r, k, value[k])
except Exception as e:
self.log.warning('Argument %s with value %s unknown inside %s (Exception: %s)', key, str(value), proto_name, str(e))
else:
try:
setattr(subrequest_extension, key, value)
Expand Down

0 comments on commit e4a2852

Please sign in to comment.