mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-14 11:18:06 +08:00
Rework exception handling logic in freeimage_plugin.py
This commit is contained in:
@@ -32,17 +32,20 @@ def _load_library(libname, loader_path):
|
||||
libdir = os.path.dirname(loader_path)
|
||||
else:
|
||||
libdir = loader_path
|
||||
if sys.platform == 'win32':
|
||||
loader = ctypes.windll
|
||||
else:
|
||||
loader = ctypes.cdll
|
||||
for ln in libname_ext:
|
||||
try:
|
||||
libpath = os.path.join(libdir, ln)
|
||||
if sys.platform == 'win32':
|
||||
return ctypes.windll[libpath]
|
||||
else:
|
||||
return ctypes.cdll[libpath]
|
||||
except OSError, e:
|
||||
return loader[os.path.join(libdir, ln)]
|
||||
except OSError:
|
||||
pass
|
||||
# TODO: Setup errno and other bits to something correctly
|
||||
raise OSError(
|
||||
'Unable to find library in any of the foloowing paths: %s' %
|
||||
[os.path.join(libdir, ln) for ln in libname_ext])
|
||||
|
||||
raise e
|
||||
|
||||
lib_dirs = [os.path.dirname(__file__),
|
||||
'/lib',
|
||||
|
||||
Reference in New Issue
Block a user