Skip to content

Commit

Permalink
Fix hash/encrypt library searching (#5804)
Browse files Browse the repository at this point in the history
* Corrected maxos niantic lib filename

Filename is libniantichash-macos-64.dylib not libniantichash-osx-64.so

* Better search for encrypt/hash files

Instead of just looking in root, or encrypt_location, or whatever the
heck the last person did... will first search local or encrypt_location.
If not found, will search pgoapi/lib. If still not found, abort.
  • Loading branch information
Gobberwart authored and solderzzc committed Nov 10, 2016
1 parent ac7f30e commit f6fec58
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
42 changes: 25 additions & 17 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,51 +979,59 @@ def get_encryption_lib(self):
if _platform == "Windows" or _platform == "win32":
# Check if we are on 32 or 64 bit
if sys.maxsize > 2**32:
file_name = 'src/pgoapi/pgoapi/lib/encrypt64.dll'
file_name = 'encrypt64.dll'
else:
file_name = 'src/pgoapi/pgoapi/lib/encrypt32.dll'
file_name = 'encrypt32.dll'
if _platform.lower() == "darwin":
file_name= 'src/pgoapi/pgoapi/lib/libencrypt-osx-64.so'
file_name= 'libencrypt-osx-64.so'
if _platform.lower() == "linux" or _platform.lower() == "linux2":
file_name = 'src/pgoapi/pgoapi/lib/libencrypt-linux-x86-64.so'
file_name = 'libencrypt-linux-x86-64.so'
if self.config.encrypt_location == '':
path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
else:
path = self.config.encrypt_location

full_path = path + '/'+ file_name
if not os.path.isfile(full_path):
full_path = ''
if os.path.isfile(path + '/' + file_name): # check encrypt_location or local dir first
full_path = path + '/' + file_name
elif os.path.isfile(path + '/src/pgoapi/pgoapi/lib/' + file_name): # if not found, check pgoapi lib folder
full_path = path + '/src/pgoapi/pgoapi/lib/' + file_name

if full_path == '':
self.logger.error(file_name + ' is not found! Please place it in the bots root directory or set encrypt_location in config.')
self.logger.info('Platform: '+ _platform + ' ' + file_name + ' directory: '+ path)
sys.exit(1)
else:
self.logger.info('Found '+ file_name +'! Platform: ' + _platform + ' ' + file_name + ' directory: ' + path)
self.logger.info('Found '+ file_name +'! Platform: ' + _platform + ' ' + file_name + ' directory: ' + full_path)

return full_path

def get_hash_lib(self):
if _platform == "Windows" or _platform == "win32":
# Check if we are on 32 or 64 bit
if sys.maxsize > 2**32:
file_name = 'src/pgoapi/pgoapi/lib/niantichash64.dll'
file_name = 'niantichash64.dll'
else:
file_name = 'src/pgoapi/pgoapi/lib/niantichash32.dll'
file_name = 'niantichash32.dll'
if _platform.lower() == "darwin":
file_name= 'src/pgoapi/pgoapi/lib/libniantichash-osx-64.so'
file_name= 'libniantichash-macos-64.dylib'
if _platform.lower() == "linux" or _platform.lower() == "linux2":
file_name = 'src/pgoapi/pgoapi/lib/libniantichash-linux-x86-64.so'
file_name = 'libniantichash-linux-x86-64.so'
if self.config.encrypt_location == '':
path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
else:
path = self.config.encrypt_location

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 + ' ' + file_name + ' directory: '+ path)
full_path = ''
if os.path.isfile(path + '/' + file_name): # check encrypt_location or local dir first
full_path = path + '/'+ file_name
elif os.path.isfile(path + '/src/pgoapi/pgoapi/lib/' + file_name): # if not found, check pgoapi lib folder
full_path = path + '/src/pgoapi/pgoapi/lib/' + file_name

if full_path == '':
self.logger.error(file_name + ' is not found! Please place it in the bots root directory or set encrypt_location in config.')
sys.exit(1)
else:
self.logger.info('Found '+ file_name +'! Platform: ' + _platform + ' ' + file_name + ' directory: ' + path)
self.logger.info('Found '+ file_name +'! Platform: ' + _platform + ' ' + file_name + ' directory: ' + full_path)

return full_path

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
numpy==1.11.0
networkx==1.11
-e git+https://github.com/pogodevorg/pgoapi.git/@v0.43.3-alpha#egg=pgoapi
-e git+https://github.com/sebastienvercammen/pgoapi.git#egg=pgoapi
geopy==1.11.0
geographiclib==1.46.3
protobuf==3.0.0b4
Expand Down

0 comments on commit f6fec58

Please sign in to comment.