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:
John Evans 2013-07-25 18:41:38 -04:00
commit b909272181
4 changed files with 13 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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):

View file

@ -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):