Added warning when neither library found, monkey-patched version.
Did some things I'm not proud of... Should revisit this.
This commit is contained in:
parent
589ca8201d
commit
b909272181
4 changed files with 13 additions and 2 deletions
|
|
@ -1,4 +1,3 @@
|
|||
"""This package organizes individual libraries employed by glymur."""
|
||||
from . import openjp2 as _openjp2
|
||||
from . import openjpeg as _openjpeg
|
||||
#from . import test
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@ def load_openjpeg(libopenjpeg_path):
|
|||
'bin', 'openjpeg.dll')
|
||||
if os.path.exists(path):
|
||||
libopenjpeg_path = path
|
||||
else:
|
||||
# No sense trying further on Linux
|
||||
return None
|
||||
|
||||
try:
|
||||
if os.name == "nt":
|
||||
|
|
@ -124,6 +127,10 @@ def glymur_config():
|
|||
libs = read_config_file()
|
||||
libopenjp2_handle = load_openjp2(libs['openjp2'])
|
||||
libopenjpeg_handle = load_openjpeg(libs['openjpeg'])
|
||||
if libopenjp2_handle is None and libopenjpeg_handle is None:
|
||||
msg = "Neither the openjp2 nor the openjpeg library could be loaded. "
|
||||
msg += "Operating in severely degraded mode."
|
||||
warnings.warn(msg, UserWarning)
|
||||
return libopenjp2_handle, libopenjpeg_handle
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,13 +22,15 @@ def version():
|
|||
return library_version
|
||||
|
||||
# Need to get the minor version, make sure we are at least at 1.4.x
|
||||
#import pdb; pdb.set_trace()
|
||||
if OPENJPEG is not None:
|
||||
_MINOR = version().split('.')[1]
|
||||
else:
|
||||
# Does not really matter. But version should not be called if there is no
|
||||
# OpenJPEG library found.
|
||||
_MINOR = 0
|
||||
# Redefine version so that we can use it.
|
||||
def version():
|
||||
return '0.0.0'
|
||||
|
||||
|
||||
class EventMgrType(ctypes.Structure):
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@ def load_tests(loader, tests, ignore):
|
|||
return tests
|
||||
|
||||
|
||||
@unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None and
|
||||
glymur.lib.openjpeg.OPENJPEG is None,
|
||||
"Missing openjp2 library.")
|
||||
class TestConfig(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue