From 29dfce792767624c839c7140ec31abf618a9c660 Mon Sep 17 00:00:00 2001 From: jevans Date: Mon, 17 Nov 2014 21:07:36 -0500 Subject: [PATCH] warn instead of raising IOError if openjpeg library cannot be found Improve error message when trying to read without openjpeg library. --- glymur/jp2k.py | 10 ++++------ glymur/lib/config.py | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/glymur/jp2k.py b/glymur/jp2k.py index d460ea6..e4a1a01 100644 --- a/glymur/jp2k.py +++ b/glymur/jp2k.py @@ -937,10 +937,8 @@ class Jp2k(Jp2kBox): elif opj.OPENJPEG is not None: img = self._read_openjpeg(**kwargs) else: - raise LibraryNotFoundError("You must have either a recent version " - "of OpenJPEG or the development " - "version of OpenJP2 installed before " - "using this functionality.") + raise LibraryNotFoundError("You must have OpenJPEG installed " + "before reading a JPEG2000 image.") return img def _subsampling_sanity_check(self): @@ -1235,8 +1233,8 @@ class Jp2k(Jp2kBox): """ if version.openjpeg_version_tuple[0] < 2: raise LibraryNotFoundError("You must have at least version 2.0.0 " - "of OpenJP2 installed before using " - "this functionality.") + "of OpenJPEG installed before using " + "read_bands.") dparam = self._populate_dparam(rlevel, ignore_pclr_cmap_cdef, layer=layer, tile=tile, area=area) diff --git a/glymur/lib/config.py b/glymur/lib/config.py index 04aece2..dc8ab29 100644 --- a/glymur/lib/config.py +++ b/glymur/lib/config.py @@ -146,7 +146,7 @@ def glymur_config(): 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. " - raise IOError(msg) + warnings.warn(msg, UserWarning) return libopenjp2_handle, libopenjpeg_handle