Commit e89cdc69 authored by Projects's avatar Projects

Additional search paths for .so library in python

parent 33768135
......@@ -32,23 +32,28 @@ class Manager:
FTDI_DEVICE_ID = 0x6010 # FTDI Product ID
def __init__(self):
self.api = None
self._load_solib()
self._devices = self._get_devarray(self.VENDOR_ID, self.DEVICE_ID)
def _load_solib(self):
"""try to load attn dyn library from script dir or ../lib."""
self.solib = './liboattnusb.so'
solib = 'liboattnusb.so'
scriptdir = os.path.dirname(os.path.realpath(__file__))
rootdir = os.path.dirname(scriptdir)
libdir = os.path.join(rootdir, 'lib', self.solib)
try:
self.api = CDLL(self.solib)
except OSError as e:
pass
try:
self.api = CDLL(libdir)
except OSError as e:
paths = (solib,
os.path.join(rootdir, 'lib', solib),
os.path.join(rootdir, '..', 'lib', solib))
for p in paths:
try:
self.api = CDLL(p)
break
except OSError as e:
pass
if self.api is None:
raise RuntimeError('cannot load oattn solib, exiting')
self.api.oau_factory_program_eeprom.argtypes = [c_int, c_int, c_char_p]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment