Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS Detection for encrypt lib #2768

Merged
merged 1 commit into from
Aug 7, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import platform
platform.system() # one of 'Linux', 'Windows', or 'Java'

https://docs.python.org/2/library/platform.html#platform.system

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