Skip to content

Commit

Permalink
Update the location & location_cache logic (#1217)
Browse files Browse the repository at this point in the history
Previously, the location_cache can't be used, even people set location_cache to TRUE. Everytime, it starts from the initial position.

Now the bot check the initial position first. 
Then check if people set location_cache. If so, read it and update it, otherwise use the initial location.
If there is no initial location and no location cache, print msg and exit.
  • Loading branch information
xc-mezcal authored and douglascamata committed Jul 27, 2016
1 parent 4d07a18 commit 15e0161
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,11 @@ def _set_starting_position(self):
logger.log('GeoPosition: {}'.format(self.position))
logger.log('')
has_position = True
return
except:
logger.log('[x] The location given in the config could not be parsed. Checking for a cached location.')
pass

if self.config.location_cache and not has_position:
if self.config.location_cache:
try:
#
# save location flag used to pull the last known location from
Expand All @@ -449,7 +448,7 @@ def _set_starting_position(self):
location_json = json.load(f)
location = (location_json['lat'],
location_json['lng'], 0.0)
print(location)
#print(location)
self.api.set_position(*location)

logger.log('')
Expand All @@ -463,8 +462,11 @@ def _set_starting_position(self):
has_position = True
return
except:
sys.exit(
"No cached Location. Please specify initial location.")
if(has_position == False):
sys.exit(
"No cached Location. Please specify initial location.")
logger.log('[x] Parsing cached location failed, try to use the initial location...')
pass

def _get_pos_by_name(self, location_name):
# Check if the given location is already a coordinate.
Expand Down

0 comments on commit 15e0161

Please sign in to comment.