Skip to content

Commit

Permalink
OS Detection for encrypt lib
Browse files Browse the repository at this point in the history
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
  • Loading branch information
brantje committed Aug 7, 2016
1 parent d5bb09f commit 71ec99a
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit 71ec99a

Please sign in to comment.