Commit 942bb015 authored by Romain Bignon's avatar Romain Bignon

happn: fix set of position

parent d09a318d
Pipeline #689 failed with stages
......@@ -154,5 +154,7 @@ class HappnBrowser(DomainBrowser):
self.request('/api/users/me/accepted/%s' % id, method='POST')
def set_position(self, lat, lng):
self.request('/api/users/%s/devices/%s' % (self.my_id, self.device_id), method='PUT',
data={'latitude': lat, 'longitude': lng, 'altitude': 0.0})
r = self.request('/api/users/%s/devices/%s' % (self.my_id, self.device_id), method='PUT',
data={'latitude': lat, 'longitude': lng, 'altitude': 0.0})
return r['data']['position']
......@@ -95,12 +95,12 @@ class ProfilesWalker(Optimization):
d = geopy.distance.VincentyDistance(kilometers=random()*self._max_distance)
pos = d.destination(point=self._location, bearing=randint(0,360))
try:
self._browser.set_position(pos.latitude, pos.longitude)
pos = self._browser.set_position(pos.latitude, pos.longitude)
except BrowserHTTPError:
self._logger.warning('Unable to update position for now, it will be retried later.')
self._logger.warning('NB: don\'t be afraid, happn only allows to update position every 20 minutes.')
else:
self._logger.info('You are now here: https://www.google.com/maps/place//@%s,%s,17z', pos.latitude, pos.longitude)
self._logger.info('You are now here: https://www.google.com/maps/place//@%s,%s,17z', pos['latitude'], pos['longitude'])
self._last_position_update = datetime.datetime.now()
for thread in self._browser.get_threads():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment