From e927195fec5883c11a8e95dd6046856063c4931c Mon Sep 17 00:00:00 2001 From: Sander Date: Sun, 7 Aug 2016 16:29:11 +0200 Subject: [PATCH 1/2] OS Detection for encrypt lib (#2768) Fix 32bit check, darwin and linux use the same file Make it a function Check if file exists, if not show error Define file_name first Fix return Check if file exists, if not show error Print info about paths Fix for 32/64bit detection --- pokemongo_bot/__init__.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index c31c1085b3..f60594b8d8 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -28,8 +28,8 @@ from pokemongo_bot.websocket_remote_control import WebsocketRemoteControl from worker_result import WorkerResult from tree_config_builder import ConfigException, MismatchTaskApiVersion, TreeConfigBuilder - - +from sys import platform as _platform +import struct class PokemonGoBot(object): @property def position(self): @@ -591,6 +591,29 @@ def login(self): formatted="Login successful." ) + def get_encryption_lib(self): + file_name = '' + if _platform == "linux" or _platform == "linux2" or _platform == "darwin": + file_name = 'encrypt.so' + elif _platform == "Windows" or _platform == "win32": + # Check if we are on 32 or 64 bit + if sys.maxsize > 2**32: + file_name = 'encrypt_64.dll' + else: + file_name = 'encrypt.dll' + + path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) + full_path = path + '/'+ file_name + + if not os.path.isfile(full_path): + self.logger.error(file_name + ' is not found! Please place it in the bots root directory.') + self.logger.info('Platform: '+ _platform + ' Bot root directory: '+ path) + sys.exit(1) + else: + self.logger.info('Found '+ file_name +'! Platform: ' + _platform + ' Bot root directory: ' + path) + + return full_path + def _setup_api(self): # instantiate pgoapi self.api = ApiWrapper() @@ -602,8 +625,7 @@ def _setup_api(self): # chain subrequests (methods) into one RPC call self._print_character_info() - - self.api.activate_signature("encrypt.so") + self.api.activate_signature(self.get_encryption_lib()) self.logger.info('') self.update_inventory() # send empty map_cells and then our position From 4f7888bd5712c63c37f47d5c686d5a66a5c60b1e Mon Sep 17 00:00:00 2001 From: Peter Bonanni Date: Sun, 7 Aug 2016 09:32:30 -0500 Subject: [PATCH 2/2] Fix Typo in unexpected_response_retry (#2531) fixes #2525 #2523