From 7075c5a0157d6568d40e67f3414fe959c10611cc Mon Sep 17 00:00:00 2001 From: David Manthey Date: Mon, 8 Nov 2021 08:15:26 -0500 Subject: [PATCH 1/2] Handle a change in the Glymur library. A missing file doesn't raise an error. --- CHANGELOG.md | 5 +++++ sources/openjpeg/large_image_source_openjpeg/__init__.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b21c6834..d0135bbef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## Version 1.8.6 + +### Bug Fixes +- A change in the Glymur library affected how missing files were handled ([#675](../../pull/675)) + ## Version 1.8.5 ### Improvements diff --git a/sources/openjpeg/large_image_source_openjpeg/__init__.py b/sources/openjpeg/large_image_source_openjpeg/__init__.py index 1cc14c51a..c43df0065 100644 --- a/sources/openjpeg/large_image_source_openjpeg/__init__.py +++ b/sources/openjpeg/large_image_source_openjpeg/__init__.py @@ -92,6 +92,10 @@ def __init__(self, path, **kwargs): self._pixelInfo = {} try: self._openjpeg = glymur.Jp2k(largeImagePath) + if not self._openjpeg.shape: + if not os.path.isfile(self._largeImagePath): + raise FileNotFoundError() + raise TileSourceError('File cannot be opened via Glymur and OpenJPEG.') except (glymur.jp2box.InvalidJp2kError, struct.error): raise TileSourceError('File cannot be opened via Glymur and OpenJPEG.') except FileNotFoundError: From 7179458c67ad4c8a5a012de2e1b6598d8668d929 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Mon, 8 Nov 2021 09:01:08 -0500 Subject: [PATCH 2/2] Work around pyproj older versions. --- sources/gdal/large_image_source_gdal/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sources/gdal/large_image_source_gdal/__init__.py b/sources/gdal/large_image_source_gdal/__init__.py index 5a606c94e..ed4f952af 100644 --- a/sources/gdal/large_image_source_gdal/__init__.py +++ b/sources/gdal/large_image_source_gdal/__init__.py @@ -25,8 +25,11 @@ import numpy import palettable import PIL.Image -import pyproj -from osgeo import gdal, gdal_array, gdalconst, osr +from osgeo import gdal, gdal_array, gdalconst, osr # noqa I001 +# pyproj stopped supporting older pythons, so its database is aging; as such, +# if on those older versions of python if it is imported before gdal, there can +# be a database version conflect; importing after gdal avoids this. +import pyproj # noqa I001 from pkg_resources import DistributionNotFound, get_distribution import large_image