only check a library folder if it actually exists

otherwise this breaks for no reason if /usr/local/lib is missing.
pull/861/head
Michael Görner 2016-04-22 11:35:44 +02:00
parent f905f5700f
commit f1a984bd3b
1 changed files with 20 additions and 19 deletions

View File

@ -205,26 +205,27 @@ def search_library():
candidates = [] candidates = []
# test every file # test every file
for curfolder in [folder]+additional_dirs: for curfolder in [folder]+additional_dirs:
for filename in os.listdir(curfolder): if os.path.isdir(curfolder):
# our minimum requirement for candidates is that for filename in os.listdir(curfolder):
# they should contain 'assimp' somewhere in # our minimum requirement for candidates is that
# their name # they should contain 'assimp' somewhere in
if filename.lower().find('assimp')==-1 or\ # their name
os.path.splitext(filename)[-1].lower() not in ext_whitelist: if filename.lower().find('assimp')==-1 or\
continue os.path.splitext(filename)[-1].lower() not in ext_whitelist:
continue
library_path = os.path.join(curfolder, filename) library_path = os.path.join(curfolder, filename)
logger.debug('Try ' + library_path) logger.debug('Try ' + library_path)
try: try:
dll = ctypes.cdll.LoadLibrary(library_path) dll = ctypes.cdll.LoadLibrary(library_path)
except Exception as e: except Exception as e:
logger.warning(str(e)) logger.warning(str(e))
# OK, this except is evil. But different OSs will throw different # OK, this except is evil. But different OSs will throw different
# errors. So just ignore any errors. # errors. So just ignore any errors.
continue continue
# see if the functions we need are in the dll # see if the functions we need are in the dll
loaded = try_load_functions(library_path, dll) loaded = try_load_functions(library_path, dll)
if loaded: candidates.append(loaded) if loaded: candidates.append(loaded)
if not candidates: if not candidates:
# no library found # no library found