Skip to content

Commit

Permalink
Fix get_gym_details requests to send client_version. (#2075)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienvercammen committed Jun 6, 2017
1 parent fd2cad1 commit f54f482
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions pogom/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,9 @@ def search_overseer_thread(args, new_location_queue, pause_bit, heartb,

t = Thread(target=search_worker_thread,
name='search-worker-{}'.format(i),
args=(args, account_queue, account_sets, account_failures,
account_captchas, search_items_queue, pause_bit,
args=(args, api_version, account_queue, account_sets,
account_failures, account_captchas,
search_items_queue, pause_bit,
threadStatus[workerId], db_updates_queue,
wh_queue, scheduler, key_scheduler))
t.daemon = True
Expand Down Expand Up @@ -751,9 +752,10 @@ def generate_hive_locations(current_location, step_distance,
return results


def search_worker_thread(args, account_queue, account_sets, account_failures,
account_captchas, search_items_queue, pause_bit,
status, dbq, whq, scheduler, key_scheduler):
def search_worker_thread(args, api_version, account_queue, account_sets,
account_failures, account_captchas,
search_items_queue, pause_bit, status, dbq, whq,
scheduler, key_scheduler):

log.debug('Search worker thread starting...')

Expand Down Expand Up @@ -1079,7 +1081,10 @@ def search_worker_thread(args, account_queue, account_sets, account_failures,
current_gym, len(gyms_to_update),
step_location[0], step_location[1])
time.sleep(random.random() + 2)
response = gym_request(api, step_location, gym)
response = gym_request(api,
step_location,
gym,
api_version)

# Make sure the gym was in range. (Sometimes the
# API gets cranky about gyms that are ALMOST 1km
Expand Down Expand Up @@ -1222,17 +1227,18 @@ def map_request(api, position, no_jitter=False):
return False


def gym_request(api, position, gym):
def gym_request(api, position, gym, api_version):
try:
log.debug('Getting details for gym @ %f/%f (%fkm away)',
log.debug('Getting details for gym @ %f/%f (%fkm away).',
gym['latitude'], gym['longitude'],
calc_distance(position, [gym['latitude'], gym['longitude']]))
req = api.create_request()
req.get_gym_details(gym_id=gym['gym_id'],
player_latitude=f2i(position[0]),
player_longitude=f2i(position[1]),
gym_latitude=gym['latitude'],
gym_longitude=gym['longitude'])
gym_longitude=gym['longitude'],
client_version=api_version)
req.check_challenge()
req.get_hatched_eggs()
req.get_inventory()
Expand All @@ -1245,7 +1251,7 @@ def gym_request(api, position, gym):
return x

except Exception as e:
log.warning('Exception while downloading gym details: %s', repr(e))
log.warning('Exception while downloading gym details: %s.', repr(e))
return False


Expand Down

0 comments on commit f54f482

Please sign in to comment.