From 843aee4f4e1ed46cb104e9cf5915010f758a9ed2 Mon Sep 17 00:00:00 2001 From: xc-mezcal Date: Wed, 27 Jul 2016 11:55:23 -0400 Subject: [PATCH] Update the location & location_cache logic 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. --- pokemongo_bot/__init__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index 390e5bc194..d2a2ac8ef1 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -422,12 +422,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 using -l 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 @@ -438,7 +437,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('') @@ -452,8 +451,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.