diff --git a/Dockerfile b/Dockerfile index a132323bd..ed61830dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ -FROM ubuntu:22.04 +FROM ubuntu:24.04 +ENV VIRTUAL_ENV=/opt/venv ENV INSTANCE_NAME=instance ENV TZ=UTC ENV PYTHONPATH='/opt/eoxserver' @@ -28,6 +29,7 @@ RUN apt-get update \ && apt-get install -y \ python3 \ python3-pip \ + python3-venv \ libpq-dev \ python3-gdal \ python3-mapscript \ @@ -39,6 +41,10 @@ RUN apt-get update \ && apt-get clean \ && rm -rf /var/lib/apt/lists/partial/* /tmp/* /var/tmp/* +# setting up a venv to install user packages in +RUN python3 -m venv --system-site-packages $VIRTUAL_ENV +ENV PATH="$VIRTUAL_ENV/bin:$PATH" + ENV PROMETHEUS_MULTIPROC_DIR /var/tmp/prometheus_multiproc_dir RUN mkdir $PROMETHEUS_MULTIPROC_DIR # make sure this is writable by webserver user @@ -47,8 +53,7 @@ WORKDIR /opt/eoxserver # install dependencies COPY requirements.txt . -RUN python3 -m pip install -U pip \ - && python3 -m pip install --no-cache-dir -r requirements.txt +RUN python3 -m pip install --no-cache-dir -r requirements.txt # install EOxServer COPY . . diff --git a/autotest/autotest/conf/eoxserver.conf b/autotest/autotest/conf/eoxserver.conf index a7e3d0433..ecea13aaf 100644 --- a/autotest/autotest/conf/eoxserver.conf +++ b/autotest/autotest/conf/eoxserver.conf @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,11 +25,11 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -#----------------------------------------------------------------------- +# ---------------------------------------------------------------------- # New style configuration -#----------------------------------------------------------------------- +# ---------------------------------------------------------------------- [core.system] @@ -82,9 +82,9 @@ role=Service provider supported_crs=4326, # WGS84 3857, # WGS84 Pseudo-Mercator 3035, #ETRS89 - 32661,32761, # WGS84 UPS-N and UPS-S - 32601,32602,32603,32604,32605,32606,32607,32608,32609,32610, # WGS84 UTM 1N-10N - 32611,32612,32613,32614,32615,32616,32617,32618,32619,32620, # WGS84 UTM 11N-20N + 32661,32761, # WGS84 UPS-N and UPS-S + 32601,32602,32603,32604,32605,32606,32607,32608,32609,32610, # WGS84 UTM 1N-10N + 32611,32612,32613,32614,32615,32616,32617,32618,32619,32620, # WGS84 UTM 11N-20N 32621,32622,32623,32624,32625,32626,32627,32628,32629,32630, # WGS84 UTM 21N-30N 32631,32632,32633,32634,32635,32636,32637,32638,32639,32640, # WGS84 UTM 31N-40N 32641,32642,32643,32644,32645,32646,32647,32648,32649,32650, # WGS84 UTM 41N-50N @@ -96,7 +96,7 @@ supported_crs=4326, # WGS84 32741,32742,32743,32744,32745,32746,32747,32748,32749,32750, # WGS84 UTM 41S-50S 32751,32752,32753,32754,32755,32756,32757,32758,32759,32760 # WGS84 UTM 51S-60S -# file formats supported by WMS +# file formats supported by WMS supported_formats=image/png,image/jpeg,image/gif,image/tiff mask_names=clouds @@ -108,9 +108,9 @@ mask_names=clouds #supported_crs=4326, # WGS84 # 3857, # WGS84 Pseudo-Mercator # 3035, # ETRS89 -# 32661,32761, # WGS84 UPS-N and UPS-S -# 32601,32602,32603,32604,32605,32606,32607,32608,32609,32610, # WGS84 UTM 1N-10N -# 32611,32612,32613,32614,32615,32616,32617,32618,32619,32620, # WGS84 UTM 11N-20N +# 32661,32761, # WGS84 UPS-N and UPS-S +# 32601,32602,32603,32604,32605,32606,32607,32608,32609,32610, # WGS84 UTM 1N-10N +# 32611,32612,32613,32614,32615,32616,32617,32618,32619,32620, # WGS84 UTM 11N-20N # 32621,32622,32623,32624,32625,32626,32627,32628,32629,32630, # WGS84 UTM 21N-30N # 32631,32632,32633,32634,32635,32636,32637,32638,32639,32640, # WGS84 UTM 31N-40N # 32641,32642,32643,32644,32645,32646,32647,32648,32649,32650, # WGS84 UTM 41N-50N @@ -122,7 +122,7 @@ mask_names=clouds # 32741,32742,32743,32744,32745,32746,32747,32748,32749,32750, # WGS84 UTM 41S-50S # 32751,32752,32753,32754,32755,32756,32757,32758,32759,32760 # WGS84 UTM 51S-60S -# file formats supported by WCS (uncomment to set non-default values) +# file formats supported by WCS (uncomment to set non-default values) supported_formats=image/tiff,image/jp2,application/x-netcdf,application/x-hdf,image/png # the maximum size of output coverages @@ -165,18 +165,18 @@ cache_dir=/tmp [services.ows.wcst11] -#this flag enables/disable mutiple actions per WCSt request -# NOTE: it's much safer to keep this feature disabled -allow_multiple_actions=False +#this flag enables/disable mutiple actions per WCSt request +# NOTE: it's much safer to keep this feature disabled +allow_multiple_actions=False # list enabled actions {Add,Delete,UpdateAll,UpdateMetadata,UpdateDataPart} # set Add,Delete for the autotest configuration s #allowed_actions=Add,Delete -# temporary storage +# temporary storage path_wcst_temp=/var/eoxserver/autotest/autotest/wcst_temp -# permanent data storage +# permanent data storage path_wcst_perm=/var/eoxserver/autotest/autotest/wcst_perm [processing.gdal.reftools] diff --git a/autotest/autotest/conf/formats.conf b/autotest/autotest/conf/formats.conf index cbdfe3de7..99db15186 100644 --- a/autotest/autotest/conf/formats.conf +++ b/autotest/autotest/conf/formats.conf @@ -1,16 +1,16 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2012 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all @@ -23,14 +23,14 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This is the user provided list of supported file formats extending/overriding # the EOxServer's default list of supported file formats. # -# This configuration file is optional and it should not cause any harm -# to keep this file empty or omit it completely. +# This configuration file is optional and it should not cause any harm +# to keep this file empty or omit it completely. # # Line format: # @@ -40,7 +40,7 @@ # # We recommend to use MIME types as the unique identifiers in the first column. # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ image/gif,GDAL/GIF,.gif image/jp2,GDAL/JPEG2000,.jp2 # JasPer driver - left to assure functionality with GDAL having no OpenJpeg driver diff --git a/autotest/autotest/expected/WCS11DescribeCoverageDatasetTestCase.xml b/autotest/autotest/expected/WCS11DescribeCoverageDatasetTestCase.xml index 8a16179a5..d9d182f92 100644 --- a/autotest/autotest/expected/WCS11DescribeCoverageDatasetTestCase.xml +++ b/autotest/autotest/expected/WCS11DescribeCoverageDatasetTestCase.xml @@ -15,8 +15,8 @@ 46.268645 28.29481 - 11.331755 32.19025 - 28.29481 46.268645 + 11.331755 32.190250 + 28.294810 46.268645 urn:ogc:def:crs:EPSG::4326 diff --git a/autotest/autotest/expected/WCS11DescribeCoverageMosaicTestCase.xml b/autotest/autotest/expected/WCS11DescribeCoverageMosaicTestCase.xml index 429e4f96b..8e657fd10 100644 --- a/autotest/autotest/expected/WCS11DescribeCoverageMosaicTestCase.xml +++ b/autotest/autotest/expected/WCS11DescribeCoverageMosaicTestCase.xml @@ -15,7 +15,7 @@ 46.268645 28.263455 - -3.75 32.19025 + -3.750000 32.190250 28.263455 46.268645 diff --git a/autotest/autotest/expected/WCS11GetCapabilitiesCQLTestCase.xml b/autotest/autotest/expected/WCS11GetCapabilitiesCQLTestCase.xml index 40386617c..8720ae513 100644 --- a/autotest/autotest/expected/WCS11GetCapabilitiesCQLTestCase.xml +++ b/autotest/autotest/expected/WCS11GetCapabilitiesCQLTestCase.xml @@ -149,8 +149,8 @@ Copyright (C) European Space Agency - ESA mosaic_MER_FRS_1PNPDE20060822_092058_000001972050_00308_23408_0077_RGB_reduced - 8.47845 32.19025 - 25.41015 46.268645 + 8.478450 32.190250 + 25.410150 46.268645 urn:ogc:def:crs:EPSG::4326 urn:ogc:def:crs:EPSG::3857 diff --git a/autotest/autotest/expected/WCS11GetCapabilitiesEmptyTestCase.xml b/autotest/autotest/expected/WCS11GetCapabilitiesEmptyTestCase.xml index 8ac8d4f1f..ecc348533 100644 --- a/autotest/autotest/expected/WCS11GetCapabilitiesEmptyTestCase.xml +++ b/autotest/autotest/expected/WCS11GetCapabilitiesEmptyTestCase.xml @@ -172,8 +172,8 @@ Copyright (C) European Space Agency - ESA MER_FRS_1PNPDE20060816_090929_000001972050_00222_23322_0058_uint16_reduced_compressed - 11.36106586 32.2014463 - 28.28384572 46.2520256 + 11.361066 32.201446 + 28.283846 46.252026 urn:ogc:def:crs:EPSG::4326 urn:ogc:def:crs:EPSG::3857 @@ -189,8 +189,8 @@ Copyright (C) European Space Agency - ESA mosaic_MER_FRS_1PNPDE20060816_090929_000001972050_00222_23322_0058_RGB_reduced - 11.331755 32.19025 - 28.29481 46.268645 + 11.331755 32.190250 + 28.294810 46.268645 urn:ogc:def:crs:EPSG::4326 urn:ogc:def:crs:EPSG::3857 @@ -206,7 +206,7 @@ Copyright (C) European Space Agency - ESA mosaic_MER_FRS_1P_reduced_RGB - -3.75 32.19025 + -3.750000 32.190250 28.263455 46.268645 urn:ogc:def:crs:EPSG::4326 diff --git a/autotest/autotest/expected/WCS11GetCapabilitiesValidTestCase.xml b/autotest/autotest/expected/WCS11GetCapabilitiesValidTestCase.xml index 8ac8d4f1f..ecc348533 100644 --- a/autotest/autotest/expected/WCS11GetCapabilitiesValidTestCase.xml +++ b/autotest/autotest/expected/WCS11GetCapabilitiesValidTestCase.xml @@ -172,8 +172,8 @@ Copyright (C) European Space Agency - ESA MER_FRS_1PNPDE20060816_090929_000001972050_00222_23322_0058_uint16_reduced_compressed - 11.36106586 32.2014463 - 28.28384572 46.2520256 + 11.361066 32.201446 + 28.283846 46.252026 urn:ogc:def:crs:EPSG::4326 urn:ogc:def:crs:EPSG::3857 @@ -189,8 +189,8 @@ Copyright (C) European Space Agency - ESA mosaic_MER_FRS_1PNPDE20060816_090929_000001972050_00222_23322_0058_RGB_reduced - 11.331755 32.19025 - 28.29481 46.268645 + 11.331755 32.190250 + 28.294810 46.268645 urn:ogc:def:crs:EPSG::4326 urn:ogc:def:crs:EPSG::3857 @@ -206,7 +206,7 @@ Copyright (C) European Space Agency - ESA mosaic_MER_FRS_1P_reduced_RGB - -3.75 32.19025 + -3.750000 32.190250 28.263455 46.268645 urn:ogc:def:crs:EPSG::4326 diff --git a/autotest/autotest/expected/WCS11PostDescribeCoverageDatasetTestCase.xml b/autotest/autotest/expected/WCS11PostDescribeCoverageDatasetTestCase.xml index 8a16179a5..d9d182f92 100644 --- a/autotest/autotest/expected/WCS11PostDescribeCoverageDatasetTestCase.xml +++ b/autotest/autotest/expected/WCS11PostDescribeCoverageDatasetTestCase.xml @@ -15,8 +15,8 @@ 46.268645 28.29481 - 11.331755 32.19025 - 28.29481 46.268645 + 11.331755 32.190250 + 28.294810 46.268645 urn:ogc:def:crs:EPSG::4326 diff --git a/autotest/autotest/expected/WCS11PostDescribeCoverageMosaicTestCase.xml b/autotest/autotest/expected/WCS11PostDescribeCoverageMosaicTestCase.xml index 429e4f96b..8e657fd10 100644 --- a/autotest/autotest/expected/WCS11PostDescribeCoverageMosaicTestCase.xml +++ b/autotest/autotest/expected/WCS11PostDescribeCoverageMosaicTestCase.xml @@ -15,7 +15,7 @@ 46.268645 28.263455 - -3.75 32.19025 + -3.750000 32.190250 28.263455 46.268645 diff --git a/autotest/autotest/expected/WCS11PostGetCapabilitiesValidTestCase.xml b/autotest/autotest/expected/WCS11PostGetCapabilitiesValidTestCase.xml index 8ac8d4f1f..ecc348533 100644 --- a/autotest/autotest/expected/WCS11PostGetCapabilitiesValidTestCase.xml +++ b/autotest/autotest/expected/WCS11PostGetCapabilitiesValidTestCase.xml @@ -172,8 +172,8 @@ Copyright (C) European Space Agency - ESA MER_FRS_1PNPDE20060816_090929_000001972050_00222_23322_0058_uint16_reduced_compressed - 11.36106586 32.2014463 - 28.28384572 46.2520256 + 11.361066 32.201446 + 28.283846 46.252026 urn:ogc:def:crs:EPSG::4326 urn:ogc:def:crs:EPSG::3857 @@ -189,8 +189,8 @@ Copyright (C) European Space Agency - ESA mosaic_MER_FRS_1PNPDE20060816_090929_000001972050_00222_23322_0058_RGB_reduced - 11.331755 32.19025 - 28.29481 46.268645 + 11.331755 32.190250 + 28.294810 46.268645 urn:ogc:def:crs:EPSG::4326 urn:ogc:def:crs:EPSG::3857 @@ -206,7 +206,7 @@ Copyright (C) European Space Agency - ESA mosaic_MER_FRS_1P_reduced_RGB - -3.75 32.19025 + -3.750000 32.190250 28.263455 46.268645 urn:ogc:def:crs:EPSG::4326 diff --git a/autotest/autotest/expected/WCS20DescribeEOCoverageSetInvalidTemporalSubsetFaultTestCase.xml b/autotest/autotest/expected/WCS20DescribeEOCoverageSetInvalidTemporalSubsetFaultTestCase.xml index 73fdbc79b..0a2595dc6 100644 --- a/autotest/autotest/expected/WCS20DescribeEOCoverageSetInvalidTemporalSubsetFaultTestCase.xml +++ b/autotest/autotest/expected/WCS20DescribeEOCoverageSetInvalidTemporalSubsetFaultTestCase.xml @@ -1,6 +1,6 @@ - - Could not parse '2006-31-31' to a temporal value. Error was: month must be in 1..12: 2006-31-31 + + Could not parse '2006-31-31' to a temporal value diff --git a/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFCompressionInvalidTestCase.xml b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFCompressionInvalidTestCase.xml new file mode 100644 index 000000000..7e1f0caba --- /dev/null +++ b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFCompressionInvalidTestCase.xml @@ -0,0 +1,6 @@ + + + + Unexpected value 'notValid'. Expected one of: 'None', 'PackBits', 'Huffman', 'LZW', 'JPEG', 'Deflate'. + + diff --git a/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFCompressionNotSupportedTestCase.xml b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFCompressionNotSupportedTestCase.xml new file mode 100644 index 000000000..4aa4416c0 --- /dev/null +++ b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFCompressionNotSupportedTestCase.xml @@ -0,0 +1,6 @@ + + + + geotiff:jpeg_quality requires compression method 'JPEG'. + + diff --git a/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFInterleavingInvalidTestCase.xml b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFInterleavingInvalidTestCase.xml new file mode 100644 index 000000000..43ea9a5f6 --- /dev/null +++ b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFInterleavingInvalidTestCase.xml @@ -0,0 +1,6 @@ + + + + Unexpected value 'invalid'. Expected one of: 'Pixel', 'Band'. + + diff --git a/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFJPEGHighTestCase.tif b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFJPEGHighTestCase.tif index 0df388eb7..d5f3bca52 100644 Binary files a/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFJPEGHighTestCase.tif and b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFJPEGHighTestCase.tif differ diff --git a/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFJPEGLowTestCase.tif b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFJPEGLowTestCase.tif index 0df388eb7..59fca699e 100644 Binary files a/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFJPEGLowTestCase.tif and b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFJPEGLowTestCase.tif differ diff --git a/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFJpegQualityInvalidTestCase.xml b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFJpegQualityInvalidTestCase.xml new file mode 100644 index 000000000..e35b72136 --- /dev/null +++ b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFJpegQualityInvalidTestCase.xml @@ -0,0 +1,6 @@ + + + + geotiff:jpeg_quality should be an integer between 1 and 100 + + diff --git a/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFPredictorInvalidTestCase.xml b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFPredictorInvalidTestCase.xml new file mode 100644 index 000000000..b87d65ffa --- /dev/null +++ b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFPredictorInvalidTestCase.xml @@ -0,0 +1,6 @@ + + + + Unexpected value 'invalid'. Expected one of: 'None', 'Horizontal', 'FloatingPoint'. + + diff --git a/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFPredictorNotSupportedTestCase.xml b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFPredictorNotSupportedTestCase.xml new file mode 100644 index 000000000..ad4922ba0 --- /dev/null +++ b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFPredictorNotSupportedTestCase.xml @@ -0,0 +1,6 @@ + + + + geotiff:predictor requires compression method 'LZW' or 'Deflate'. + + diff --git a/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFTilingInvalidTestCase.xml b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFTilingInvalidTestCase.xml new file mode 100644 index 000000000..8d45406b6 --- /dev/null +++ b/autotest/autotest/expected/WCS20GetCoverageDatasetGeoTIFFTilingInvalidTestCase.xml @@ -0,0 +1,6 @@ + + + + geotiff:tiling requires geotiff:tilewidth and geotiff:tileheight to be set. + + diff --git a/autotest/autotest/expected/WMS13GetMapCrossesDatelineDatasetTestCase.jpg b/autotest/autotest/expected/WMS13GetMapCrossesDatelineDatasetTestCase.jpg index 25a93e20e..6c41a5f37 100644 Binary files a/autotest/autotest/expected/WMS13GetMapCrossesDatelineDatasetTestCase.jpg and b/autotest/autotest/expected/WMS13GetMapCrossesDatelineDatasetTestCase.jpg differ diff --git a/autotest/autotest/expected/WMS13GetMapNoServiceParameterTestCase.tif b/autotest/autotest/expected/WMS13GetMapNoServiceParameterTestCase.tif index d5254bc2f..c4b384919 100644 Binary files a/autotest/autotest/expected/WMS13GetMapNoServiceParameterTestCase.tif and b/autotest/autotest/expected/WMS13GetMapNoServiceParameterTestCase.tif differ diff --git a/autotest/autotest/expected/WMS13GetMapReferenceableGridTestCase.jpg b/autotest/autotest/expected/WMS13GetMapReferenceableGridTestCase.jpg index fe539a45b..4293da817 100644 Binary files a/autotest/autotest/expected/WMS13GetMapReferenceableGridTestCase.jpg and b/autotest/autotest/expected/WMS13GetMapReferenceableGridTestCase.jpg differ diff --git a/autotest/autotest/templates/admin/base_site.html b/autotest/autotest/templates/admin/base_site.html index d24e193de..9f3794538 100644 --- a/autotest/autotest/templates/admin/base_site.html +++ b/autotest/autotest/templates/admin/base_site.html @@ -1,11 +1,11 @@ {% extends "admin/base.html" %} {% load i18n %} diff --git a/autotest/autotest/wsgi.py b/autotest/autotest/wsgi.py index ff2950cd1..09fe1ecf2 100644 --- a/autotest/autotest/wsgi.py +++ b/autotest/autotest/wsgi.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2012 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ WSGI config for EOxServer's autotest instance. @@ -48,9 +48,9 @@ if path not in sys.path: sys.path.append(path) -# NOTE: The Apache mod_wsgi, by default, shares the enviroment variables +# NOTE: The Apache mod_wsgi, by default, shares the enviroment variables # between different WSGI apps which leads to conflicts between -# multiple EOxServer instance. Therefore we cannot rely on the +# multiple EOxServer instance. Therefore we cannot rely on the # DJANGO_SETTINGS_MODULE enviromental variable we must always set it # to the proper value. #os.environ.setdefault("DJANGO_SETTINGS_MODULE", "autotest.settings") diff --git a/autotest/autotest_coverages/tests/synchronization.py b/autotest/autotest_coverages/tests/synchronization.py index 2180576de..f0f516299 100644 --- a/autotest/autotest_coverages/tests/synchronization.py +++ b/autotest/autotest_coverages/tests/synchronization.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from os.path import join diff --git a/autotest/autotest_services/base.py b/autotest/autotest_services/base.py index 358b7d42a..76a4a47ff 100644 --- a/autotest/autotest_services/base.py +++ b/autotest/autotest_services/base.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause @@ -6,7 +6,7 @@ # Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import re import os.path @@ -37,23 +37,21 @@ from zipfile import ZipFile, ZipInfo from tarfile import TarFile, TarInfo from base64 import b64decode + +from io import BytesIO +import cgi +from unittest import SkipTest, skipIf +import glob + import numpy as np try: from scipy.stats import linregress HAVE_SCIPY = True except ImportError: HAVE_SCIPY = False -try: - from cStringIO import StringIO as BytesIO -except ImportError: - from io import BytesIO -import cgi -from unittest import SkipTest, skipIf -import glob from django.test import Client, TransactionTestCase from django.conf import settings -from django.utils.six import assertCountEqual, binary_type, b from eoxserver.core.config import get_eoxserver_config from eoxserver.core.util import multiparttools as mp @@ -83,9 +81,9 @@ "^text/xml|application/(?:[a-z]+\+)?xml$", re.IGNORECASE ) -#=============================================================================== +# ============================================================================== # Helper functions -#=============================================================================== +# ============================================================================== def extent_from_ds(ds): @@ -106,11 +104,14 @@ def resolution_from_ds(ds): def _getMime(s): return s.partition(';')[0].strip().lower() -#=============================================================================== + +# ============================================================================== # Common classes -#=============================================================================== +# ============================================================================== + + +REQUEST_CACHE: dict[str, object] = {} -REQUEST_CACHE = {} @tag('ows') class OWSTestCase(TransactionTestCase): @@ -126,6 +127,8 @@ class OWSTestCase(TransactionTestCase): # ] fixtures = BASE_FIXTURES + expect_success = False + def setUp(self): super(OWSTestCase, self).setUp() @@ -174,7 +177,7 @@ def check_disabled(self): config = get_eoxserver_config() try: disabled_tests = config.get("testing", "disabled_tests").split(",") - except: + except Exception: disabled_tests = () name = type(self).__name__ if name in disabled_tests: @@ -186,7 +189,7 @@ def isRequestConfigEnabled(self, config_key, default=False): config = get_eoxserver_config() try: value = config.get("testing", config_key) - except: + except Exception: value = None if value is None: @@ -259,7 +262,7 @@ def _testXMLComparison(self, suffix="xml", response=None): # check that the expected XML response exists if not expected_paths: - if isinstance(response, binary_type): + if isinstance(response, bytes): response = response.decode() with open(response_path, 'w') as f: f.write(response) @@ -279,7 +282,7 @@ def _testXMLComparison(self, suffix="xml", response=None): fails.append(e) else: with open(response_path, 'w') as f: - if isinstance(response, binary_type): + if isinstance(response, bytes): response = response.decode() f.write(response) reasons = ', '.join([ @@ -316,7 +319,7 @@ def _testBinaryComparison(self, file_type, data=None): # read the expected response, either binary or as string try: - if isinstance(actual_response, binary_type): + if isinstance(actual_response, bytes): open_type = 'rb' else: open_type = 'r' @@ -334,7 +337,7 @@ def _testBinaryComparison(self, file_type, data=None): ) # save the contents of the file - if isinstance(actual_response, binary_type): + if isinstance(actual_response, bytes): open_type = 'wb' else: open_type = 'w' @@ -418,7 +421,7 @@ def setUp(self): _, self.tmppath = tempfile.mkstemp("." + self.getFileExtension("raster")) data = self.getResponseData() - if isinstance(data, binary_type): + if isinstance(data, bytes): mode = 'wb' else: mode = 'w' @@ -453,15 +456,17 @@ def tearDown(self): class StatisticsMixIn(object): expected_minimum_correlation = 0.95 + def testBinaryComparisonRaster(self): try: super(StatisticsMixIn, self).testBinaryComparisonRaster() - except: + except Exception: self.skipTest('compare the band size, count, and statistics') + @tag('stastics') @skipIf(not HAVE_SCIPY, "scipy modoule is not installed") def testBandStatistics(self): - for band in range( self.res_ds.RasterCount ): + for band in range(self.res_ds.RasterCount): band += 1 if band: exp_band = self.exp_ds.GetRasterBand(band) @@ -469,7 +474,10 @@ def testBandStatistics(self): array1 = np.array(exp_band.ReadAsArray()).flatten() array2 = np.array(res_band.ReadAsArray()).flatten() regress_result = linregress(array1, array2) - self.assertGreaterEqual(regress_result.rvalue, self.expected_minimum_correlation) + self.assertGreaterEqual( + regress_result.rvalue, + self.expected_minimum_correlation + ) class WCSBinaryComparison(StatisticsMixIn, GDALDatasetTestCase): @@ -490,13 +498,13 @@ class RectifiedGridCoverageTestCase(WCSBinaryComparison, GDALDatasetTestCase): @tag('extent') def testExtent(self): exp_resolution = resolution_from_ds(self.exp_ds) - epsilon = exp_resolution[0]/10 + epsilon = exp_resolution[0] / 10 res_extent = extent_from_ds(self.res_ds) exp_extent = extent_from_ds(self.exp_ds) if not max([ - abs(res_extent[i] - exp_extent[i]) for i in range(0, 4) - ]) < epsilon: + abs(res_extent[i] - exp_extent[i]) for i in range(0, 4) + ]) < epsilon: self.fail("Extent does not match %s != %s" % ( res_extent, exp_extent )) @@ -506,10 +514,10 @@ def testResolution(self): res_resolution = resolution_from_ds(self.res_ds) exp_resolution = resolution_from_ds(self.exp_ds) self.assertAlmostEqual( - res_resolution[0], exp_resolution[0], delta=exp_resolution[0]/10 + res_resolution[0], exp_resolution[0], delta=exp_resolution[0] / 10 ) self.assertAlmostEqual( - res_resolution[1], exp_resolution[1], delta=exp_resolution[1]/10 + res_resolution[1], exp_resolution[1], delta=exp_resolution[1] / 10 ) @tag('band-count') @@ -536,7 +544,7 @@ def testGCPProjection(self): self.fail("Expected Dataset has no GCP Projection defined") exp_srs = osr.SpatialReference(exp_proj) - self.assert_(res_srs.IsSame(exp_srs)) + self.assertTrue(res_srs.IsSame(exp_srs)) class XMLNoValTestCase(OWSTestCase): @@ -573,7 +581,8 @@ def testValidate(self, XMLData=None): locations = schema_locations.split() if schema_locations else [] # get schema locations - schema_def = etree.Element("schema", attrib={ + schema_def = etree.Element( + "schema", attrib={ "elementFormDefault": "qualified", "version": "1.0.0", }, nsmap={ @@ -584,7 +593,8 @@ def testValidate(self, XMLData=None): for ns, location in zip(locations[::2], locations[1::2]): if location == "../owsCoverages.xsd": location = "http://schemas.opengis.net/wcs/1.1/wcsAll.xsd" - etree.SubElement(schema_def, "import", attrib={ + etree.SubElement( + schema_def, "import", attrib={ "namespace": ns, "schemaLocation": location } @@ -592,7 +602,7 @@ def testValidate(self, XMLData=None): # TODO: ugly workaround. But otherwise, the doc is not # recognized as schema - schema = etree.XMLSchema(etree.XML(etree.tostring(schema_def))) + # schema = etree.XMLSchema(etree.XML(etree.tostring(schema_def))) try: # schema.assertValid(doc) @@ -614,7 +624,8 @@ def testSchematron(self): errors = [] doc = etree.XML(self.getXMLData()) - schematron_def = etree.Element("schema", attrib={ + schematron_def = etree.Element( + "schema", attrib={ "queryBinding": "xslt2", }, nsmap={ None: "http://purl.oclc.org/dsdl/schematron" @@ -662,7 +673,7 @@ def getExceptionCodeLocation(self): def testStatus(self): logger.info("Checking HTTP Status ...") - #pylint: disable=E1103 + # pylint: disable=E1103 self.assertEqual(self.response.status_code, self.getExpectedHTTPStatus()) @tag('exception-code') @@ -731,7 +742,7 @@ def setUp(self): self.isSetUp = False super(MultipartTestCase, self).setUp() - #self._setUpMultiparts() + # self._setUpMultiparts() def _mangleXML(self, cbuffer): """ remove variable parts of selected XML elements text and attributes @@ -788,7 +799,7 @@ def _unpackMultipartContent(self, response): else: content = response.content headers = { - b(key): b(value) + key.encode(): value.encode() for key, value in response.items() } for headers, data in mp.iterate(content, headers=headers): @@ -848,9 +859,9 @@ class ReferenceableGridCoverageMultipartTestCase( ): pass -#=============================================================================== +# ============================================================================== # WCS-T -#=============================================================================== +# ============================================================================== class WCSTransactionTestCase(XMLTestCase): @@ -953,7 +964,7 @@ def getRequest(self): requestAsync = """http://NOTUSED""" requestEnd = """""" - params = requestBegin + self.ID + requestMid1 + self.getDataFullPath(self.ADDtiffFile) + requestMid2 + params = requestBegin + self.ID + requestMid1 + self.getDataFullPath(self.ADDtiffFile) + requestMid2 if self.ADDmetaFile is not None: params += requestMid3 + self.getDataFullPath(self.ADDmetaFile) + requestMid4 params += requestMid5 @@ -963,7 +974,7 @@ def getRequest(self): return (params, "xml") def getDataFullPath(self , path_to): - return os.path.abspath( os.path.join( self.getDataFileDir() , path_to) ) + return os.path.abspath(os.path.join(self.getDataFileDir(), path_to)) def testXMLComparison(self): # the TimeStamp and RequestId elements are set during ingestion and @@ -982,35 +993,35 @@ def testResponseIdComparisonAdd(self): same """ logger.debug("IDCompare testResponseIdComparison for ID: %s" % self.ID) - self._testResponseIdComparison( self.ID , self.getXMLData() ) + self._testResponseIdComparison(self.ID, self.getXMLData()) def testStatusDescribeCoverage(self): """ Tests that the inserted coverage is available in a DescribeCoverage request """ - #pylint: disable=E1103 + # pylint: disable=E1103 self.assertEqual(self.responseDescribeCoverage.status_code, 200) def testValidateDescribeCoverage(self): self.testValidate(self.responseDescribeCoverage.content) def testXMLComparisonDescribeCoverage(self): - #self._testBinaryComparison("TransactionDescribeCoverage", self.responseDescribeCoverage.content) - self._testXMLComparison( "TransactionDescribeCoverage" , self.responseDescribeCoverage.content ) + # self._testBinaryComparison("TransactionDescribeCoverage", self.responseDescribeCoverage.content) + self._testXMLComparison("TransactionDescribeCoverage", self.responseDescribeCoverage.content) def testStatusGetCoverage(self): """ Validate the inserted coverage via a GetCoverage request """ - #pylint: disable=E1103 + # pylint: disable=E1103 self.assertEqual(self.responseGetCoverage.status_code, 200) def testStatusDeleteCoverage(self): """ Test to delete the previously inserted coaverage """ - #pylint: disable=E1103 + # pylint: disable=E1103 self.assertEqual(self.responseDeleteCoverage.status_code, 200) def testValidateDeleteCoverage(self): @@ -1020,8 +1031,8 @@ def testXMLComparisonDeleteCoverage(self): tree = etree.fromstring(self.responseDeleteCoverage.content) for node in tree.findall("{http://www.opengis.net/wcs/1.1/wcst}RequestId"): node.text = "identifier" - #self._testBinaryComparison("TransactionDeleteCoverage", etree.tostring(tree, encoding="ISO-8859-1")) - self._testXMLComparison( "TransactionDeleteCoverage" , etree.tostring(tree, encoding="ISO-8859-1")) + # self._testBinaryComparison("TransactionDeleteCoverage", etree.tostring(tree, encoding="ISO-8859-1")) + self._testXMLComparison("TransactionDeleteCoverage", etree.tostring(tree, encoding="ISO-8859-1")) def testResponseIdComparisonDelete(self): """ @@ -1029,32 +1040,33 @@ def testResponseIdComparisonDelete(self): same """ logger.debug("IDCompare testResponseIdComparison for ID: %s" % self.ID) - self._testResponseIdComparison( self.ID , self.responseDeleteCoverage.content ) + self._testResponseIdComparison(self.ID, self.responseDeleteCoverage.content) def testStatusDescribeCoverageDeleted(self): """ Tests that the deletec coverage is not longer available in a DescribeCoverage request """ - #pylint: disable=E1103 + # pylint: disable=E1103 self.assertEqual(self.responseDescribeCoverageDeleted.status_code, 404) def testValidateDescribeCoverageDeleted(self): self.testValidate(self.responseDescribeCoverageDeleted.content) def testXMLComparisonDescribeCoverageDeleted(self): - #self._testBinaryComparison("TransactionDescribeCoverageDeleted", self.responseDescribeCoverageDeleted.content) - self._testXMLComparison( "TransactionDescribeCoverageDeleted" , self.responseDescribeCoverageDeleted.content ) + # self._testBinaryComparison("TransactionDescribeCoverageDeleted", self.responseDescribeCoverageDeleted.content) + self._testXMLComparison("TransactionDescribeCoverageDeleted", self.responseDescribeCoverageDeleted.content) - def _testResponseIdComparison(self , id , rcontent ): + def _testResponseIdComparison(self, id, rcontent): """ Tests that the in the XML request and response is the same """ logger.debug("_testResponseIdComparison for ID: %s" % id) - tree = etree.fromstring( rcontent ) + tree = etree.fromstring(rcontent) for node in tree.findall("{http://www.opengis.net/ows/1.1}Identifier"): - self.assertEqual( node.text, id ) + self.assertEqual(node.text, id) + class WCSTransactionRectifiedGridCoverageTestCase( RectifiedGridCoverageMultipartTestCase, @@ -1066,15 +1078,17 @@ class WCSTransactionRectifiedGridCoverageTestCase( # Overwrite _setUpMultiparts() to return the GetCoverage response to be used # in MultipartTestCase tests def _setUpMultiparts(self): - if self.isSetUp: return + if self.isSetUp: + return - self._unpackMultipartContent( self.responseGetCoverage ) + self._unpackMultipartContent(self.responseGetCoverage) self.isSetUp = True def getXMLData(self): return self.response.content + class WCSTransactionReferenceableGridCoverageTestCase( ReferenceableGridCoverageMultipartTestCase, WCSTransactionTestCase @@ -1085,18 +1099,20 @@ class WCSTransactionReferenceableGridCoverageTestCase( # Overwrite _setUpMultiparts() to return the GetCoverage response to be used # in MultipartTestCase tests def _setUpMultiparts(self): - if self.isSetUp: return + if self.isSetUp: + return - self._unpackMultipartContent( self.responseGetCoverage ) + self._unpackMultipartContent(self.responseGetCoverage) self.isSetUp = True def getXMLData(self): return self.response.content -#=============================================================================== +# ============================================================================== # WCS 2.0 -#=============================================================================== +# ============================================================================== + class WCS20DescribeEOCoverageSetSubsettingTestCase(XMLTestCase): def getExpectedCoverageIds(self): @@ -1120,6 +1136,7 @@ def testCoverageIds(self): for coverage_id in result_coverage_ids: self.assertTrue(result_coverage_ids.count(coverage_id) == 1, "CoverageID %s is not unique." % coverage_id) + class WCS20DescribeEOCoverageSetPagingTestCase(XMLTestCase): def getExpectedCoverageCount(self): return 0 @@ -1162,6 +1179,7 @@ def testSections(self): sections = [section.tag for section in sections] self.assertCountEqual(sections, self.getExpectedSections()) + class WCS20GetCoverageMultipartTestCase(MultipartTestCase): @tag('xml-comparison') def testXMLComparison(self): @@ -1178,18 +1196,21 @@ def testXMLComparison(self): super(WCS20GetCoverageMultipartTestCase, self).testXMLComparison() + class WCS20GetCoverageRectifiedGridCoverageMultipartTestCase( WCS20GetCoverageMultipartTestCase, RectifiedGridCoverageTestCase ): pass + class WCS20GetCoverageReferenceableGridCoverageMultipartTestCase( WCS20GetCoverageMultipartTestCase, ReferenceableGridCoverageTestCase ): pass + class RasdamanTestCaseMixIn(object): #fixtures = BASE_FIXTURES + ["testing_rasdaman_coverages.json"] @@ -1208,6 +1229,7 @@ def setUp(self): super(RasdamanTestCaseMixIn, self).setUp() + class WPS10XMLComparison(XMLTestCase): def getFileExtension(self, part=None): if part == "xml": @@ -1221,24 +1243,22 @@ def parseFileName(src) : with open(src, 'rb') as fid : return fid.read() except Exception as e : - raise XMLParseError ("Failed to parse the \"%s\" file! %s" % ( src , str(e) )) - - def parse( self, src) : - return self.parseFileName(src) + raise XMLParseError("Failed to parse the \"%s\" file! %s" % ( src , str(e) )) + def parse(self, src) : + return self.parseFileName(src) def testXMLComparison(self): - - expected_path= os.path.join( + expected_path = os.path.join( self.getExpectedFileDir(), self.getExpectedFileName('xml') ) - expectedString= self.parse(expected_path) + expectedString = self.parse(expected_path) expected_doc = etree.fromstring(expectedString) # replace the encoded data so it compare other nodes in the xml files response_doc = etree.fromstring(self.prepareXMLData(self.getXMLData())) expected_elems = expected_doc.xpath('//wps:ComplexData', namespaces={'wps': 'http://www.opengis.net/wps/1.0.0'}) - response_elems = response_doc.xpath('//wps:ComplexData', namespaces= {'wps': 'http://www.opengis.net/wps/1.0.0'}) + response_elems = response_doc.xpath('//wps:ComplexData', namespaces={'wps': 'http://www.opengis.net/wps/1.0.0'}) for expected_elem, response_elem in zip(expected_elems, response_elems): parent = response_elem.getparent() @@ -1249,20 +1269,18 @@ def testXMLComparison(self): super(WPS10XMLComparison, self).testXMLComparison() - def testBinaryComparisonRaster(self): - response_path = os.path.join( self.getResponseFileDir(), self.getResponseFileName("raster") ) - expected_path= os.path.join( + expected_path = os.path.join( self.getExpectedFileDir(), self.getExpectedFileName("raster") ) # creates a response image that contains the encoded text of the response xml file - doc = etree.fromstring( self.prepareXMLData(self.getXMLData())) + doc = etree.fromstring(self.prepareXMLData(self.getXMLData())) try: - encodedText = doc.xpath('//wps:ComplexData', namespaces= {'wps': 'http://www.opengis.net/wps/1.0.0'})[0].text + encodedText = doc.xpath('//wps:ComplexData', namespaces={'wps': 'http://www.opengis.net/wps/1.0.0'})[0].text except IndexError: self.fail('No complex data found in the XML tree') @@ -1291,6 +1309,7 @@ def testBinaryComparisonRaster(self): # compare the band count self.assertEqual(self.res_ds.RasterCount, self.exp_ds.RasterCount) + class WPS10BinaryComparison(GDALDatasetTestCase): def testBinaryComparisonRaster(self): self.skipTest('Only need to compare the band size and band count') @@ -1324,12 +1343,14 @@ def getResponseData(self): self.responseData.seek(0) return self.responseData + @tag('archive') class WCSGetEOCoverageArchiveTestCase(StreamingContentTestCase): """ Base class for test cases that expects archive output. """ - expectedContentType:str = None + expectedContentType: str + def getArchiveMembers(self): """returning archive FileInfo of files contained in the request archive @@ -1360,7 +1381,7 @@ def getArchiveMembers(self): def testHeader(self): self.assertEqual(self.getResponseHeader("Content-Type"), self.expectedContentType) - def fileExistsInArchive(self, f:str): + def fileExistsInArchive(self, f: str): """Returns if filepath is present in the archive Args: f (str): filename to search @@ -1375,8 +1396,8 @@ def fileExistsInArchive(self, f:str): class WCS20GetEOCoverageSetPagingTestCase(WCSGetEOCoverageArchiveTestCase): - files_should_exist:list = [] - files_should_not_exist:list = [] + files_should_exist: list = [] + files_should_not_exist: list = [] def testCoveragesPresent(self): """ diff --git a/autotest/autotest_services/processes/test00_identity_literal.py b/autotest/autotest_services/processes/test00_identity_literal.py index 072d7eb59..62374f264 100644 --- a/autotest/autotest_services/processes/test00_identity_literal.py +++ b/autotest/autotest_services/processes/test00_identity_literal.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, implements from eoxserver.services.ows.wps.interfaces import ProcessInterface diff --git a/autotest/autotest_services/processes/test01_identity_bbox.py b/autotest/autotest_services/processes/test01_identity_bbox.py index 480faf5dd..a73b14b0b 100644 --- a/autotest/autotest_services/processes/test01_identity_bbox.py +++ b/autotest/autotest_services/processes/test01_identity_bbox.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, implements from eoxserver.services.ows.wps.interfaces import ProcessInterface diff --git a/autotest/autotest_services/processes/test02_identity_complex.py b/autotest/autotest_services/processes/test02_identity_complex.py index 906d5c9ee..d42d3a47f 100644 --- a/autotest/autotest_services/processes/test02_identity_complex.py +++ b/autotest/autotest_services/processes/test02_identity_complex.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import json try: diff --git a/autotest/autotest_services/processes/test03_binary_complex.py b/autotest/autotest_services/processes/test03_binary_complex.py index aebf213d0..3f8164af3 100644 --- a/autotest/autotest_services/processes/test03_binary_complex.py +++ b/autotest/autotest_services/processes/test03_binary_complex.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import uuid import os.path @@ -42,7 +42,7 @@ except NameError: # Python 3, xrange is now named range xrange = range - + class TestProcess03(Component): """ Test process generating binary complex data output. """ implements(ProcessInterface) diff --git a/autotest/autotest_services/processes/test04_datetime_tzaware_input.py b/autotest/autotest_services/processes/test04_datetime_tzaware_input.py index 2bb6fda3d..939700639 100644 --- a/autotest/autotest_services/processes/test04_datetime_tzaware_input.py +++ b/autotest/autotest_services/processes/test04_datetime_tzaware_input.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2016 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, implements from eoxserver.services.ows.wps.interfaces import ProcessInterface diff --git a/autotest/autotest_services/processes/test05_datetime_tzaware_output.py b/autotest/autotest_services/processes/test05_datetime_tzaware_output.py index d438070fe..d8afa6510 100644 --- a/autotest/autotest_services/processes/test05_datetime_tzaware_output.py +++ b/autotest/autotest_services/processes/test05_datetime_tzaware_output.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2016 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, implements from eoxserver.services.ows.wps.interfaces import ProcessInterface diff --git a/autotest/autotest_services/processes/test06_minimal_process.py b/autotest/autotest_services/processes/test06_minimal_process.py index 52c76791d..ecf344456 100644 --- a/autotest/autotest_services/processes/test06_minimal_process.py +++ b/autotest/autotest_services/processes/test06_minimal_process.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2016 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # pylint: disable=missing-docstring, too-few-public-methods from eoxserver.core import Component, implements diff --git a/autotest/autotest_services/processes/test07_request_parameter.py b/autotest/autotest_services/processes/test07_request_parameter.py index ce6fbe991..ea3737771 100644 --- a/autotest/autotest_services/processes/test07_request_parameter.py +++ b/autotest/autotest_services/processes/test07_request_parameter.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2016 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # pylint: disable=missing-docstring, too-few-public-methods from eoxserver.core import Component, implements diff --git a/autotest/autotest_services/tests/opensearch/test_v11.py b/autotest/autotest_services/tests/opensearch/test_v11.py index d896275ed..fa38dc539 100644 --- a/autotest/autotest_services/tests/opensearch/test_v11.py +++ b/autotest/autotest_services/tests/opensearch/test_v11.py @@ -1,12 +1,7 @@ import json from django.test import TestCase, Client, tag -try: - from django.core.urlresolvers import reverse -except ImportError: - from django.urls import reverse - -from django.utils.six import assertCountEqual +from django.urls import reverse from eoxserver.core.util.xmltools import etree, parse from eoxserver.contrib import gdal, ogr diff --git a/autotest/autotest_services/tests/wcs/test_v10.py b/autotest/autotest_services/tests/wcs/test_v10.py index fe5175df4..99886bead 100644 --- a/autotest/autotest_services/tests/wcs/test_v10.py +++ b/autotest/autotest_services/tests/wcs/test_v10.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,15 +23,15 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.testing.utils import tag from autotest_services import base as testbase -#=============================================================================== +# ============================================================================== # WCS 1.0 -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs10') class WCS10GetCapabilitiesValidTestCase(testbase.XMLTestCase): diff --git a/autotest/autotest_services/tests/wcs/test_v11.py b/autotest/autotest_services/tests/wcs/test_v11.py index 297039539..70c53660a 100644 --- a/autotest/autotest_services/tests/wcs/test_v11.py +++ b/autotest/autotest_services/tests/wcs/test_v11.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.testing.utils import tag @@ -31,9 +31,9 @@ from . import base as wcsbase -#=============================================================================== +# ============================================================================== # WCS 1.1 -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs11') class WCS11GetCapabilitiesValidTestCase(testbase.XMLTestCase): @@ -106,9 +106,9 @@ def getRequest(self): params = "service=WCS&version=1.1.2&request=GetCoverage&identifier=mosaic_MER_FRS_1P_reduced_RGB&boundingbox=35,10,42,20,urn:ogc:def:crs:EPSG::4326&format=image/tiff&GridCS=urn:ogc:def:crs:OGC::imageCRS&GridBaseCRS=urn:ogc:def:crs:OGC::imageCRS&GridType=urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs&GridOrigin=40,10&GridOffsets=-0.06,0.06" return (params, "kvp") -#=============================================================================== +# ============================================================================== # WCS 1.1: Exceptions -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs11') class WCS11DescribeCoverageNoSuchCoverageFaultTestCase(testbase.ExceptionTestCase): @@ -177,9 +177,9 @@ def getRequest(self): def getExpectedExceptionCode(self): return "InvalidParameterValue" -#=============================================================================== +# ============================================================================== # WCS 1.1 WCS Transaction tests -#=============================================================================== +# ============================================================================== ''' class WCS11TransactionRectifiedDatasetTestCase(testbase.WCSTransactionRectifiedGridCoverageTestCase): """ This test case shall test the synchronous inserting of a new @@ -212,9 +212,9 @@ class WCS11TransactionReferenceableDatasetTestCase(testbase.WCSTransactionRefere ADDtiffFile = "asar/ASA_WSM_1PNDPA20050331_075939_000000552036_00035_16121_0775.tiff" ''' -#=============================================================================== +# ============================================================================== # WCS 1.1 - POST -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs11') class WCS11PostGetCapabilitiesValidTestCase(testbase.XMLTestCase): diff --git a/autotest/autotest_services/tests/wcs/test_v20.py b/autotest/autotest_services/tests/wcs/test_v20.py index f6c136f7c..0d9bae0a0 100644 --- a/autotest/autotest_services/tests/wcs/test_v20.py +++ b/autotest/autotest_services/tests/wcs/test_v20.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import sys from unittest import skipIf @@ -38,9 +38,9 @@ GDAL_VERSION = int(GDAL_VERSION[0]), int(GDAL_VERSION[1:3]), int(GDAL_VERSION[3:5]) IS_PY2 = (sys.version_info.major == 2) -#=============================================================================== +# ============================================================================== # WCS 2.0 Get Capabilities -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20GetCapabilitiesValidTestCase(testbase.XMLTestCase, testbase.SchematronTestMixIn): @@ -163,9 +163,9 @@ def getRequest(self): params = "service=WCS&version=2.0.1&request=GetCapabilities&cql=identifier='mosaic_MER_FRS_1PNPDE20060822_092058_000001972050_00308_23408_0077_RGB_reduced'" return (params, "kvp") -#=============================================================================== +# ============================================================================== # WCS 2.0 DescribeCoverage -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20DescribeCoverageDatasetTestCase(testbase.XMLTestCase): @@ -217,9 +217,9 @@ def getRequest(self): def getExpectedExceptionCode(self): return "MissingParameterValue" -#=============================================================================== +# ============================================================================== # WCS 2.0 DescribeEOCoverageSet -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20DescribeEOCoverageSetDatasetTestCase(testbase.XMLTestCase): @@ -454,9 +454,9 @@ def getExpectedHTTPStatus(self): def getExpectedExceptionCode(self): return "InvalidAxisLabel" -#=============================================================================== +# ============================================================================== # WCS 2.0: Paging testcases -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20DescribeEOCoverageSetDatasetPagingCountTestCase(testbase.WCS20DescribeEOCoverageSetPagingTestCase): @@ -470,9 +470,9 @@ def getRequest(self): params = "service=WCS&version=2.0.0&request=DescribeEOCoverageSet&eoId=MER_FRS_1P_reduced&count=2" return (params, "kvp") -#=============================================================================== +# ============================================================================== # WCS 2.0: Section test cases -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20DescribeEOCoverageSetSectionsAllTestCase(testbase.WCS20DescribeEOCoverageSetSectionsTestCase): @@ -593,9 +593,9 @@ def getExpectedCoverageIds(self): "mosaic_MER_FRS_1P_reduced_RGB" ] -#=============================================================================== +# ============================================================================== # WCS 2.0: Exceptions -#=============================================================================== +# ============================================================================== # after WCS 2.0.1 implementation does not lead to an error anymore #class WCS20GetCoverageFormatMissingFaultTestCase(testbase.ExceptionTestCase): @@ -636,9 +636,9 @@ def getRequest(self): def getExpectedExceptionCode(self): return "InvalidParameterValue" -#=============================================================================== +# ============================================================================== # WCS 2.0: Simple requests -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20GetCoverageMosaicTestCase(testbase.RectifiedGridCoverageTestCase, testbase.WCSBinaryComparison): @@ -652,9 +652,9 @@ def getRequest(self): params = "service=wcs&version=2.0.0&request=GetCoverage&CoverageId=MER_FRS_1PNPDE20060822_092058_000001972050_00308_23408_0077_uint16_reduced_compressed&format=image/tiff" return (params, "kvp") -#============================================================================== +# ============================================================================= # WCS 2.0: Formats -#============================================================================== +# ============================================================================= # WCS 2.0.1 introduced the native format, i.e., default format in case of missing format specification @tag('wcs', 'wcs20') @@ -708,9 +708,9 @@ def getRequest(self): params = "service=wcs&version=2.0.0&request=GetCoverage&CoverageId=mosaic_MER_FRS_1PNPDE20060816_090929_000001972050_00222_23322_0058_RGB_reduced_JPEG2000&format=image/tiff" return (params, "kvp") -#=============================================================================== +# ============================================================================== # WCS 2.0: Multipart requests -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20GetCoverageMultipartMosaicTestCase(wcsbase.WCS20GetCoverageMixIn, testbase.WCS20GetCoverageRectifiedGridCoverageMultipartTestCase, testbase.WCSBinaryComparison): @@ -733,9 +733,9 @@ def getRequest(self): # def getExpectedExceptionCode(self): # return "InvalidParameterValue" -#=============================================================================== +# ============================================================================== # WCS 2.0: Subset requests -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20GetCoverageSubsetDatasetTestCase(wcsbase.WCS20GetCoverageMixIn, testbase.RectifiedGridCoverageTestCase, testbase.WCSBinaryComparison): @@ -779,9 +779,9 @@ def getExpectedExceptionCode(self): def getExpectedHTTPStatus(self): return 404 -#=============================================================================== +# ============================================================================== # WCS 2.0: OutputCRS -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20GetCoverageOutputCRSDatasetTestCase(wcsbase.WCS20GetCoverageMixIn, testbase.WCS20GetCoverageRectifiedGridCoverageMultipartTestCase, testbase.WCSBinaryComparison): @@ -807,9 +807,9 @@ def getExpectedExceptionCode(self): def getExpectedHTTPStatus(self): return 404 -#=============================================================================== +# ============================================================================== # WCS 2.0: Size -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20GetCoverageSizeDatasetTestCase(testbase.RectifiedGridCoverageTestCase, testbase.WCSBinaryComparison): @@ -853,9 +853,9 @@ def getExpectedHTTPStatus(self): def getExpectedExceptionCode(self): return "InvalidScaleFactor" -#=============================================================================== +# ============================================================================== # WCS 2.0: Resolution -#=============================================================================== +# ============================================================================== # TODO: not supported anymore (WCS 2.0 Scaling Extension) @@ -887,9 +887,9 @@ def getExpectedExceptionCode(self): # def getExpectedExceptionCode(self): # return "InvalidParameterValue" -#=============================================================================== +# ============================================================================== # WCS 2.0: Rangesubset -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20GetCoverageRangeSubsetIntervalDatasetTestCase(testbase.RectifiedGridCoverageTestCase, testbase.WCSBinaryComparison): @@ -934,9 +934,9 @@ def getRequest(self): # params = "service=wcs&version=2.0.1&request=GetCoverage&CoverageId=MER_FRS_1PNPDE20060822_092058_000001972050_00308_23408_0077_uint16_reduced_compressed&format=image/tiff&subset=x(100,200)&subset=y(200,300)&size=y(100)&resolution=x(0.1)&outputcrs=http://www.opengis.net/def/crs/EPSG/0/3035&rangesubset=MERIS_radiance_01_uint16:MERIS_radiance_03_uint16&mediatype=multipart/related" # return (params, "kvp") -#=============================================================================== +# ============================================================================== # WCS 2.0: Polygon Mask -#=============================================================================== +# ============================================================================== # TODO: Enable these tests once the feature is implemented in MapServer @@ -964,9 +964,9 @@ def getRequest(self): # """ # return (params, "xml") -#=============================================================================== +# ============================================================================== # WCS 2.0: Interpolation -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20GetCoverageDatasetInterpolationNearestTestCase(testbase.RectifiedGridCoverageTestCase, testbase.WCSBinaryComparison): @@ -998,9 +998,9 @@ def getExpectedExceptionCode(self): def getExpectedHTTPStatus(self): return 404 -#=============================================================================== +# ============================================================================== # WCS 2.0 Rasdaman test cases -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20GetCoverageRasdamanMultipartDatasetTestCase(wcsbase.WCS20GetCoverageMixIn, testbase.RasdamanTestCaseMixIn, testbase.WCS20GetCoverageRectifiedGridCoverageMultipartTestCase, testbase.WCSBinaryComparison): @@ -1057,9 +1057,9 @@ def getRequest(self): return (params, "kvp") -#=============================================================================== +# ============================================================================== # WCS 2.0: GetCov with EPSG:3035 input images -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20DescribeCoverageReprojectedDatasetTestCase(testbase.XMLTestCase): @@ -1097,9 +1097,9 @@ def getRequest(self): params = "service=wcs&version=2.0.1&request=GetCoverage&CoverageId=MER_FRS_1PNPDE20060816_090929_000001972050_00222_23322_0058_uint16_reduced_compressed_reprojected&format=image/tiff&mediatype=multipart/related&outputcrs=http://www.opengis.net/def/crs/EPSG/0/3857" return (params, "kvp") -#=============================================================================== +# ============================================================================== # WCS 2.0 Referenceable Grid Coverages -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20DescribeCoverageReferenceableDatasetTestCase(testbase.XMLTestCase): @@ -1148,9 +1148,9 @@ def getExpectedHTTPStatus(self): def getExpectedExceptionCode(self): return "InvalidParameterValue" -#=============================================================================== +# ============================================================================== # WCS 2.0.1 Corrigendum test cases -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20CorrigendumGetCapabilitiesEmptyTestCase(testbase.XMLTestCase): @@ -1189,9 +1189,9 @@ def getRequest(self): return (params, "kvp") -#=============================================================================== +# ============================================================================== # WCS 2.0 - POST -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20PostGetCapabilitiesValidTestCase(testbase.XMLTestCase): @@ -1455,15 +1455,18 @@ def getRequest(self): params = "service=wcs&version=2.0.0&request=GetCoverage&CoverageId=MER_FRS_1PNPDE20060822_092058_000001972050_00308_23408_0077_uint16_reduced_compressed&format=image/tiff&geotiff:compression=PackBits" return (params, "kvp") -@tag('wcs', 'wcs20') -class WCS20GetCoverageDatasetGeoTIFFHuffmanTestCase(wcsbase.GeoTIFFMixIn, testbase.RectifiedGridCoverageTestCase, testbase.WCSBinaryComparison): - expected_compression = "CCITTRLE" - def testBandStatistics(self): - self.skipTest('temporary hold the test to invistigate the issue') - def getRequest(self): - params = "service=wcs&version=2.0.0&request=GetCoverage&CoverageId=MER_FRS_1PNPDE20060822_092058_000001972050_00308_23408_0077_uint16_reduced_compressed&format=image/tiff&geotiff:compression=Huffman" - return (params, "kvp") +# Deactivated because Huffman only allows 1 bit outputs +# @tag('wcs', 'wcs20') +# class WCS20GetCoverageDatasetGeoTIFFHuffmanTestCase(wcsbase.GeoTIFFMixIn, testbase.RectifiedGridCoverageTestCase, testbase.WCSBinaryComparison): +# expected_compression = "CCITTRLE" + +# def testBandStatistics(self): +# self.skipTest('temporary hold the test to invistigate the issue') + +# def getRequest(self): +# params = "service=wcs&version=2.0.0&request=GetCoverage&CoverageId=MER_FRS_1PNPDE20060822_092058_000001972050_00308_23408_0077_uint16_reduced_compressed&format=image/tiff&geotiff:compression=Huffman" +# return (params, "kvp") @tag('wcs', 'wcs20') class WCS20GetCoverageDatasetGeoTIFFLZWTestCase(wcsbase.GeoTIFFMixIn, testbase.RectifiedGridCoverageTestCase, testbase.WCSBinaryComparison): @@ -1473,6 +1476,8 @@ def getRequest(self): params = "service=wcs&version=2.0.0&request=GetCoverage&CoverageId=MER_FRS_1PNPDE20060822_092058_000001972050_00308_23408_0077_uint16_reduced_compressed&format=image/tiff&geotiff:compression=LZW" return (params, "kvp") + +# GDAL only supports <= 10 bands for JPEG compression with 8bits depth @tag('wcs', 'wcs20') class WCS20GetCoverageDatasetGeoTIFFJPEGLowTestCase(wcsbase.GeoTIFFMixIn, testbase.RectifiedGridCoverageTestCase, testbase.WCSBinaryComparison): expected_compression = "JPEG" @@ -1480,7 +1485,7 @@ class WCS20GetCoverageDatasetGeoTIFFJPEGLowTestCase(wcsbase.GeoTIFFMixIn, testba def testBandStatistics(self): self.skipTest('temporary hold the test to invistigate the issue') def getRequest(self): - params = "service=wcs&version=2.0.0&request=GetCoverage&CoverageId=MER_FRS_1PNPDE20060822_092058_000001972050_00308_23408_0077_uint16_reduced_compressed&format=image/tiff&geotiff:compression=JPEG&geotiff:jpeg_quality=50" + params = "service=wcs&version=2.0.0&request=GetCoverage&CoverageId=mosaic_MER_FRS_1PNPDE20060822_092058_000001972050_00308_23408_0077_RGB_reduced&format=image/tiff&geotiff:compression=JPEG&geotiff:jpeg_quality=50" return (params, "kvp") @tag('wcs', 'wcs20') @@ -1490,7 +1495,7 @@ class WCS20GetCoverageDatasetGeoTIFFJPEGHighTestCase(wcsbase.GeoTIFFMixIn, testb def testBandStatistics(self): self.skipTest('temporary hold the test to invistigate the issue') def getRequest(self): - params = "service=wcs&version=2.0.0&request=GetCoverage&CoverageId=MER_FRS_1PNPDE20060822_092058_000001972050_00308_23408_0077_uint16_reduced_compressed&format=image/tiff&geotiff:compression=JPEG&geotiff:jpeg_quality=90" + params = "service=wcs&version=2.0.0&request=GetCoverage&CoverageId=mosaic_MER_FRS_1PNPDE20060822_092058_000001972050_00308_23408_0077_RGB_reduced&format=image/tiff&geotiff:compression=JPEG&geotiff:jpeg_quality=90" return (params, "kvp") @tag('wcs', 'wcs20') @@ -1517,13 +1522,16 @@ def getRequest(self): params = "service=wcs&version=2.0.0&request=GetCoverage&CoverageId=MER_FRS_1PNPDE20060822_092058_000001972050_00308_23408_0077_uint16_reduced_compressed&format=image/tiff&geotiff:tiling=true&geotiff:tilewidth=16&geotiff:tileheight=16" return (params, "kvp") + @tag('wcs', 'wcs20') class WCS20GetCoverageDatasetGeoTIFFPostTestCase(wcsbase.GeoTIFFMixIn, testbase.RectifiedGridCoverageTestCase, testbase.WCSBinaryComparison): expected_tiling = (32, 64) expected_interleave = "BAND" expected_compression = "DEFLATE" + def testBandStatistics(self): self.skipTest('temporary hold the test to invistigate the issue') + def getRequest(self): params = """ Deflate - FloatingPoint + None Band true 32 @@ -1543,6 +1551,7 @@ def getRequest(self): """ return (params, "xml") + @tag('wcs', 'wcs20') class WCS20GetCoverageDatasetGeoTIFFCompressionNotSupportedTestCase(testbase.ExceptionTestCase): @@ -1556,6 +1565,7 @@ def getExpectedHTTPStatus(self): def getExpectedExceptionCode(self): return "CompressionNotSupported" + @tag('wcs', 'wcs20') class WCS20GetCoverageDatasetGeoTIFFCompressionInvalidTestCase(testbase.ExceptionTestCase): @@ -1718,9 +1728,9 @@ def testContentTypeIsHtml(self): self.assertEqual(content_type, "text/html") -#=============================================================================== +# ============================================================================== # WCS GetEOCoverageSet 2.0.1: Paging testcases -#=============================================================================== +# ============================================================================== @tag('wcs', 'wcs20') class WCS20GetEOCoverageSetDatasetPagingTestCase(testbase.WCS20GetEOCoverageSetPagingTestCase): diff --git a/autotest/autotest_services/tests/wms/base.py b/autotest/autotest_services/tests/wms/base.py index 468a196d9..e5d73b782 100644 --- a/autotest/autotest_services/tests/wms/base.py +++ b/autotest/autotest_services/tests/wms/base.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from unittest import SkipTest, skipIf import numpy as np diff --git a/autotest/autotest_services/tests/wms/test_v10.py b/autotest/autotest_services/tests/wms/test_v10.py index f9a9dedfa..fe7050ae5 100644 --- a/autotest/autotest_services/tests/wms/test_v10.py +++ b/autotest/autotest_services/tests/wms/test_v10.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from autotest_services import base as testbase from . import base as wmsbase diff --git a/autotest/autotest_services/tests/wms/test_v11.py b/autotest/autotest_services/tests/wms/test_v11.py index 759383e68..2130948ea 100644 --- a/autotest/autotest_services/tests/wms/test_v11.py +++ b/autotest/autotest_services/tests/wms/test_v11.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,15 +23,15 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from autotest_services import base as testbase from . import base as wmsbase -#=============================================================================== +# ============================================================================== # WMS -#=============================================================================== +# ============================================================================== class WMS11GetCapabilitiesValidTestCase(testbase.OWSTestCase): """This test shall retrieve a valid WMS 1.1 GetCapabilities response""" diff --git a/autotest/autotest_services/tests/wms/test_v13.py b/autotest/autotest_services/tests/wms/test_v13.py index 1344dc47f..a5cde00ee 100644 --- a/autotest/autotest_services/tests/wms/test_v13.py +++ b/autotest/autotest_services/tests/wms/test_v13.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from unittest import skip from autotest_services import base as testbase from . import base as wmsbase @@ -204,9 +204,9 @@ class WMS13GetMapCollectionTimeIntervalBorderTestCase(wmsbase.WMS13GetMapTestCas bbox = (-3.75, 32.158895, 28.326165, 46.3) time = "2006-08-01T00:00:00Z/2006-08-16T09:09:29Z" -#=============================================================================== +# ============================================================================== # Outlines -#=============================================================================== +# ============================================================================== class WMS13GetMapCollectionOutlinesTestCase(wmsbase.WMS13GetMapTestCase): layers = ("MER_FRS_1P_reduced__outlines",) @@ -230,9 +230,9 @@ class WMS13GetMapCollectionOutlinesTimeIntervalTestCase(wmsbase.WMS13GetMapTestC bbox = (-3.75, 32.158895, 28.326165, 46.3) time = "2006-08-16T09:09:29Z/2006-08-16T09:15:46Z" -#=============================================================================== +# ============================================================================== # Bands -#=============================================================================== +# ============================================================================== class WMS13GetMapDatasetOneBandTestCase(wmsbase.WMS13GetMapTestCase): """ Test a GetMap request with a dataset containing 15 bands. """ @@ -250,9 +250,9 @@ class WMS13GetMapDatasetThreeBandsTestCase(wmsbase.WMS13GetMapTestCase): width = 1000 height = 1000 -#=============================================================================== +# ============================================================================== # Reprojected -#=============================================================================== +# ============================================================================== class WMS13GetMapReprojectedDatasetTestCase(wmsbase.WMS13GetMapTestCase): """ Test a GetMap request with a reprojected dataset. """ @@ -261,9 +261,9 @@ class WMS13GetMapReprojectedDatasetTestCase(wmsbase.WMS13GetMapTestCase): layers = ("MER_FRS_1PNPDE20060816_090929_000001972050_00222_23322_0058_uint16_reduced_compressed_reprojected",) bbox = (8.487755775451660, 32.195316643454134, 25.407486727461219, 46.249103546142578) -#=============================================================================== +# ============================================================================== # Dateline crossing -#=============================================================================== +# ============================================================================== class WMS13GetMapCrossesDatelineDatasetTestCase(wmsbase.WMS13GetMapTestCase): """ Test a GetMap request with a reprojected dataset. """ @@ -273,9 +273,9 @@ class WMS13GetMapCrossesDatelineDatasetTestCase(wmsbase.WMS13GetMapTestCase): bbox = (-180, -90, 180, 90) width = 200 -#=============================================================================== +# ============================================================================== # Masked -#=============================================================================== +# ============================================================================== MASK_FIXTURES = [ "range_types.json", "meris_range_type.json", "meris_products_rgb.json" @@ -295,9 +295,9 @@ class WMS13GetMapCollectionMaskedTestCase(wmsbase.WMS13GetMapTestCase): layers = ("MER_FRS_1P_reduced_products_RGB__masked_clouds",) bbox = (11, 32, 28, 46) -#=============================================================================== +# ============================================================================== # Cloud Mask -#=============================================================================== +# ============================================================================== class WMS13GetMapProductCloudMaskTestCase(wmsbase.WMS13GetMapTestCase): """ Test a GetMap request for cloudmask of a dataset. """ @@ -315,9 +315,9 @@ class WMS13GetMapCollectionCloudMaskTestCase(wmsbase.WMS13GetMapTestCase): styles = ("magenta",) bbox = (11, 32, 28, 46) -#=============================================================================== +# ============================================================================== # Masked Outlines -#=============================================================================== +# ============================================================================== class WMS13GetMapProductMaskedOutlinesTestCase(wmsbase.WMS13GetMapTestCase): """ Test a GetMap request with the masked outlines layer for a dataset. """ @@ -373,9 +373,9 @@ class WMS13GetMapCollectionHeatmapTestCase(wmsbase.WMS13GetMapTestCase): frmt = "image/png" -#=============================================================================== +# ============================================================================== # Feature Info -#=============================================================================== +# ============================================================================== class WMS13GetFeatureInfoTestCase(testbase.HTMLTestCase): """ Test a GetFeatureInfo on an outline layer. """ @@ -416,9 +416,9 @@ def getRequest(self): params = "SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&LAYERS=MER_FRS_1P_reduced_RGB_outlines&QUERY_LAYERS=MER_FRS_1P_reduced_RGB_outlines&STYLES=&BBOX=32.158895,-3.75,46.3,28.326165&FEATURE_COUNT=10&HEIGHT=100&WIDTH=200&FORMAT=image%2Fpng&INFO_FORMAT=application/xml&CRS=EPSG:4326&I=100&J=50"; return (params, "kvp") -#=============================================================================== +# ============================================================================== # Legend Graphic -#=============================================================================== +# ============================================================================== class WMS13GetLegendGraphicTestCase(wmsbase.WMS13GetLegendTestCase): """ Test a GetLegendGraphic request for a dataset with an associated style. """ diff --git a/autotest/autotest_services/tests/wps/base.py b/autotest/autotest_services/tests/wps/base.py index b043eb999..039a1b085 100644 --- a/autotest/autotest_services/tests/wps/base.py +++ b/autotest/autotest_services/tests/wps/base.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # pylint: disable=invalid-name, missing-docstring, too-few-public-methods from lxml import etree diff --git a/autotest/autotest_services/tests/wps/test_v10.py b/autotest/autotest_services/tests/wps/test_v10.py index 9052a4500..837ccb3d9 100644 --- a/autotest/autotest_services/tests/wps/test_v10.py +++ b/autotest/autotest_services/tests/wps/test_v10.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ #pylint: disable=missing-docstring,line-too-long,too-many-ancestors from autotest_services import base as testbase @@ -46,9 +46,9 @@ ] XML_CONTENT_TYPE = "application/xml; charset=utf-8" -#=============================================================================== +# ============================================================================== # WCS 1.0 GetCapabilities -#=============================================================================== +# ============================================================================== class WPS10GetCapabilitiesValidTestCase(ContentTypeCheckMixIn, WPS10CapabilitiesMixIn, testbase.XMLTestCase): allowedProcesses = ALLOWED_PROCESSES @@ -70,9 +70,9 @@ def getRequest(self): return (params, "xml") -#=============================================================================== +# ============================================================================== # WCS 1.0 DescribeProcess -#=============================================================================== +# ============================================================================== class WPS10DescribeProcessValidTestCase(ContentTypeCheckMixIn, testbase.XMLTestCase): @@ -129,9 +129,9 @@ def testValidate(self, XMLData=None): #TODO: Error - invalid process identifier -#=============================================================================== +# ============================================================================== # WCS 1.0 Execute - Minimal Process -#=============================================================================== +# ============================================================================== class WPS10ExecuteTC06MinimalValidProcess(ContentTypeCheckMixIn, WPS10ExecuteMixIn, testbase.XMLTestCase): expectedContentType = XML_CONTENT_TYPE @@ -151,9 +151,9 @@ def getRequest(self): params = "service=WPS&version=1.0.0&request=execute&identifier=Test06MinimalAllowedProcess&lineage=true" return (params, "kvp") -#=============================================================================== +# ============================================================================== # WCS 1.0 Execute - Literal Data Tests -#=============================================================================== +# ============================================================================== class WPS10ExecuteTestCase(ContentTypeCheckMixIn, WPS10ExecuteMixIn, testbase.XMLTestCase): expectedContentType = XML_CONTENT_TYPE @@ -290,9 +290,9 @@ def getRequest(self): #TODO: Error - invalid input (value type) #TODO: Error - invalid input (out of the allowed range) -#=============================================================================== +# ============================================================================== # WCS 1.0 Execute - Bounding Box Data Tests -#=============================================================================== +# ============================================================================== class WPS10ExecuteBoundingBoxTestCase(ContentTypeCheckMixIn, WPS10ExecuteMixIn, testbase.XMLTestCase): expectedContentType = XML_CONTENT_TYPE @@ -364,9 +364,9 @@ def getRequest(self): #TODO: Error - invalid input CRS #TODO: Error - invalid output CRS -#=============================================================================== +# ============================================================================== # WCS 1.0 Execute - Complex Data Tests (text-based payload) -#=============================================================================== +# ============================================================================== class WPS10ExecuteComplexDataTextTestCase(ContentTypeCheckMixIn, WPS10ExecuteMixIn, testbase.XMLTestCase): expectedContentType = XML_CONTENT_TYPE @@ -565,9 +565,9 @@ def getRequest(self): params = "service=WPS&version=1.0.0&request=Execute&identifier=TC02:identity:complex&DataInputs=TC02:input00=%3Ctest%3AtestXML+xmlns%3Atest%3D%22http%3A%2F%2Fxml.eox.at%2Ftest%22%3EP%C5%99%C3%ADli%C5%A1%20%C5%BElu%C5%A5ou%C4%8Dk%C3%BD%20k%C5%AF%C5%88%20%C3%BAp%C4%9Bl%20%C4%8F%C3%A1belsk%C3%A9%20%C3%B3dy.%3C%2Ftest%3AtestXML%3E@mimeType=text%2Fxml&RawDataOutput=TC02:output00@mimeType=text%2Fxml" return (params, "kvp") -#=============================================================================== +# ============================================================================== # WCS 1.0 Execute - Complex Data Tests (binary payload) -#=============================================================================== +# ============================================================================== class WPS10ExecuteComplexDataPNGBase64FileTestCase(ContentTypeCheckMixIn, WPS10ExecuteMixIn, testbase.XMLTestCase): expectedContentType = XML_CONTENT_TYPE @@ -690,9 +690,9 @@ def getRequest(self): """ return (params, "xml") -#=============================================================================== +# ============================================================================== # request parameter input test -#=============================================================================== +# ============================================================================== class WPS10RequestParameterProcessDescriptionTestCase(ContentTypeCheckMixIn, testbase.XMLTestCase): expectedContentType = XML_CONTENT_TYPE diff --git a/autotest/autotest_services/tests/wps/test_v10_data_types.py b/autotest/autotest_services/tests/wps/test_v10_data_types.py index 15efa1aa9..9903380f7 100644 --- a/autotest/autotest_services/tests/wps/test_v10_data_types.py +++ b/autotest/autotest_services/tests/wps/test_v10_data_types.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2016 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ #pylint: disable=missing-docstring,line-too-long,too-many-ancestors from autotest_services import base as testbase @@ -33,9 +33,9 @@ XML_CONTENT_TYPE = "application/xml; charset=utf-8" -#=============================================================================== +# ============================================================================== # advanced data types - time-zone aware input -#=============================================================================== +# ============================================================================== class WPS10TZAwareDatetimeInputProcessDescriptionTestCase(ContentTypeCheckMixIn, testbase.XMLTestCase): expectedContentType = XML_CONTENT_TYPE @@ -64,9 +64,9 @@ def getRequest(self): params = "service=WPS&version=1.0.0&request=Execute&identifier=TC04:identity:literal:datetime&DataInputs=TC04:datetime=2016-08-04T09:26:04Z&lineage=true" return (params, "kvp") -#=============================================================================== +# ============================================================================== # advanced data types - time-zone aware input -#=============================================================================== +# ============================================================================== class WPS10TZAwareDatetimeOutputProcessDescriptionTestCase(ContentTypeCheckMixIn, testbase.XMLTestCase): expectedContentType = XML_CONTENT_TYPE diff --git a/autotest/scripts/native.py b/autotest/scripts/native.py index 25526a25f..3ad4e68e5 100644 --- a/autotest/scripts/native.py +++ b/autotest/scripts/native.py @@ -1,18 +1,18 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # $Id$ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import os.path @@ -37,13 +37,13 @@ class EOxSNativeEncoder(EOxSXMLEncoder): def encodePolygon(self, polygon): pos_list = " ".join(["%f %f" % (point[0], point[1]) for point in polygon[0]]) - + return self._makeElement( "", "Polygon", [ ("", "Exterior", pos_list) ] ) - + def encodeEOMetadata(self, eo_id, eo_metadata): return self._makeElement( "", "Metadata", [ @@ -55,7 +55,7 @@ def encodeEOMetadata(self, eo_id, eo_metadata): ]) ] ) - + def encodeCRMetadata(self, eo_id, begin_time, end_time, pos_list): return self._makeElement( "", "Metadata", [ @@ -75,12 +75,12 @@ def generateMetadataFilesFromRecords(eo_id, target_dir): wcseo_object = EOxSRectifiedDatasetSeriesRecord.objects.get(eo_id=eo_id) except: wcseo_object = EOxSRectifiedStitchedMosaicRecord.objects.get(eo_id=eo_id) - + encoder = EOxSNativeEncoder() - + for dataset in wcseo_object.rect_datasets.all(): md_el = encoder.encodeEOMetadata(dataset.eo_id, dataset.eo_metadata) - + md_filename = "%s.%s" % (os.path.splitext(os.path.basename(dataset.file.path))[0], "xml") f = open(os.path.join(target_dir, md_filename), 'w') f.write(md_el.toxml()) @@ -98,21 +98,21 @@ def generateMetadataFilesFromCR(src_dir, target_dir, eo_id_prefix, eo_id_suffix) g = open(cr_filename) cr = g.read() g.close() - + decoder = EOxSXMLDecoder(cr, GSC_SCHEMA) - + eo_id = "%s%s%s" % (eo_id_prefix, os.path.splitext(os.path.basename(cr_filename))[0], eo_id_suffix) begin_time = decoder.getValue("begintime") end_time = decoder.getValue("endtime") - + positions = decoder.getValue("poslist") new_positions = [positions[i + 1 - 2 * (i % 2)] for i in range(0, len(positions))] pos_list = " ".join([str(f) for f in new_positions]) - + encoder = EOxSNativeEncoder() - + md_el = encoder.encodeCRMetadata(eo_id, begin_time, end_time, pos_list) - + md_filename = "%s.%s" % (eo_id, "xml") f = open(os.path.join(target_dir, md_filename), 'w') f.write(md_el.toxml()) diff --git a/autotest/scripts/resample.py b/autotest/scripts/resample.py index 25820c0e1..4aba7b712 100644 --- a/autotest/scripts/resample.py +++ b/autotest/scripts/resample.py @@ -1,18 +1,18 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # $Id$ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import os, os.path from shutil import copy2 @@ -44,26 +44,26 @@ def _roundint(f): def resample(srid, origin, offsets, raw_imagery_path, output_path, image_pattern): data_path = os.path.join(settings.PROJECT_DIR, "examples", "data") - + filenames = os.listdir(os.path.join(data_path, raw_imagery_path)) imgs = fnfilter(filenames, image_pattern) - + for img in imgs: src_path = os.path.join(data_path, raw_imagery_path, img) src = gdal.Open(src_path) - + src_grid = getGridFromFile(src_path) src_minx, src_miny, src_maxx, src_maxy = src_grid.getExtent2D() - + src_x_min = _roundint(math.floor((src_minx - origin[0]) / offsets[0][0])) src_y_min = _roundint(math.floor((src_maxy - origin[1]) / offsets[1][1])) src_x_max = _roundint(math.ceil((src_maxx - origin[0]) / offsets[0][0])) src_y_max = _roundint(math.ceil((src_miny - origin[1]) / offsets[1][1])) - + x_size = src_x_max - src_x_min + 1 y_size = src_y_max - src_y_min + 1 - + dst_path = os.path.join(data_path, output_path, "mosaic_%s" % img) driver = gdal.GetDriverByName('GTiff') dst = driver.Create(dst_path, x_size, y_size, 3) @@ -71,10 +71,10 @@ def resample(srid, origin, offsets, raw_imagery_path, output_path, image_pattern origin[1] + float(src_y_min) * offsets[1][1], 0.0, offsets[1][1]] dst.SetGeoTransform(gt) dst.SetProjection(src.GetProjection()) - + gdal.ReprojectImage(src, dst) -def resampleImage2009(): +def resampleImage2009(): mosaic_grid = EOxSRectifiedGrid( srid = 3035, low = (0, 0), @@ -82,7 +82,7 @@ def resampleImage2009(): origin = (4208500.0, 2948000.0), offsets = ((500.0, 0.0), (0.0, -500.0)), ) - + resample( mosaic_grid.srid, mosaic_grid.origin, mosaic_grid.offsets, "image2009", "image2009_mosaic_resampled", "*.tiff" @@ -92,7 +92,7 @@ def resampleMERIS(): srid = 4326 origin = (-3.75,46.3) offsets = ((0.0031355,0.0),(0.0,-0.0031355)) - + resample(srid, origin, offsets, "meris/MER_FRS_1P_RGB", "meris/mosaic_MER_FRS_1P_RGB", "*.tif") def resampleMERISreduced(): diff --git a/debian/control b/debian/control index c3d5c1b7f..8072c3bd3 100644 --- a/debian/control +++ b/debian/control @@ -19,7 +19,7 @@ Package: python3-eoxserver Architecture: any Section: web Depends: ${shlibs:Depends}, - ${misc:Depends}, + ${misc:Depends}, python3-lxml, python3-libxml2, python3, @@ -27,12 +27,11 @@ Depends: ${shlibs:Depends}, python3-ply, python3-django-model-utils, python3-zipstream, - python3-dateutil, python3-gdal, python3-pycql, python3-django Description: This package contains the EOxServer library . - EOxServer is a Python 3 application and framework for presenting + EOxServer is a Python 3 application and framework for presenting Earth Observation (EO) data and metadata. diff --git a/docker-compose.yml b/docker-compose.yml index fe37da317..f5fb876d6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: "3.6" services: database: - image: mdillon/postgis:10 + image: postgis/postgis:17-3.5 volumes: - database-data:/var/lib/postgresql/data environment: diff --git a/eoxserver/backends/cache.py b/eoxserver/backends/cache.py index ea9e00479..e37c97c13 100644 --- a/eoxserver/backends/cache.py +++ b/eoxserver/backends/cache.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import os import os.path diff --git a/eoxserver/backends/component.py b/eoxserver/backends/component.py index 106d17104..94b262ced 100644 --- a/eoxserver/backends/component.py +++ b/eoxserver/backends/component.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import itertools diff --git a/eoxserver/backends/config.py b/eoxserver/backends/config.py index 4a06843f1..08ccf99fb 100644 --- a/eoxserver/backends/config.py +++ b/eoxserver/backends/config.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core.decoders import config diff --git a/eoxserver/backends/interfaces.py b/eoxserver/backends/interfaces.py index af097b1ba..46c5c083d 100644 --- a/eoxserver/backends/interfaces.py +++ b/eoxserver/backends/interfaces.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class AbstractStorageInterface(object): diff --git a/eoxserver/backends/keystone/storage_auth.py b/eoxserver/backends/keystone/storage_auth.py index ccd7890d1..dcb6c9548 100644 --- a/eoxserver/backends/keystone/storage_auth.py +++ b/eoxserver/backends/keystone/storage_auth.py @@ -29,6 +29,7 @@ import logging import hashlib import json +from urllib import parse from django.core.cache import caches, InvalidCacheBackendError from django.utils import timezone @@ -36,7 +37,6 @@ from keystoneclient.v2_0 import client as ksclient_v2 from keystoneclient.v3 import client as ksclient_v3 from swiftclient.exceptions import ClientException -from django.utils.six.moves.urllib import parse from eoxserver.core.util.timetools import parse_iso8601 from eoxserver.backends.storage_auths import BaseStorageAuthHandler diff --git a/eoxserver/backends/middleware.py b/eoxserver/backends/middleware.py index adeb05dce..872cc20c4 100644 --- a/eoxserver/backends/middleware.py +++ b/eoxserver/backends/middleware.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import logging diff --git a/eoxserver/backends/migrations/0005_alter_storage_id_alter_storageauth_id.py b/eoxserver/backends/migrations/0005_alter_storage_id_alter_storageauth_id.py new file mode 100644 index 000000000..3171f332e --- /dev/null +++ b/eoxserver/backends/migrations/0005_alter_storage_id_alter_storageauth_id.py @@ -0,0 +1,23 @@ +# Generated by Django 5.2 on 2025-04-18 15:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('backends', '0004_storage_streaming'), + ] + + operations = [ + migrations.AlterField( + model_name='storage', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='storageauth', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + ] diff --git a/eoxserver/backends/storages.py b/eoxserver/backends/storages.py index d07d22ac7..0d1000d4a 100644 --- a/eoxserver/backends/storages.py +++ b/eoxserver/backends/storages.py @@ -30,7 +30,7 @@ import tarfile import zipfile import fnmatch -from django.utils.six.moves.urllib import parse, request +from urllib import parse, request import ftplib import glob @@ -261,9 +261,9 @@ class FTPStorageHandler(BaseStorageHandler): def __init__(self, url, streaming): self.url = url - self.parsed_url = urlparse(url) + self.parsed_url = parse.urlparse(url) self.ftp = None - self.streaming=streaming + self.streaming = streaming def __enter__(self): self.ftp = ftplib.FTP() @@ -303,7 +303,7 @@ def get_vsi_path(self, location): @classmethod def test(cls, locator): try: - return urlparse(locator).scheme.lower() == 'ftp' + return parse.urlparse(locator).scheme.lower() == 'ftp' except: return False diff --git a/eoxserver/backends/testbase.py b/eoxserver/backends/testbase.py index ee4756407..a0d4c58a7 100644 --- a/eoxserver/backends/testbase.py +++ b/eoxserver/backends/testbase.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import logging from unittest import SkipTest diff --git a/eoxserver/backends/tests.py b/eoxserver/backends/tests.py index fa9f99560..e6fb023c3 100644 --- a/eoxserver/backends/tests.py +++ b/eoxserver/backends/tests.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import os.path from glob import glob diff --git a/eoxserver/contrib/__init__.py b/eoxserver/contrib/__init__.py index fd4d4fcad..e4d7a8015 100644 --- a/eoxserver/contrib/__init__.py +++ b/eoxserver/contrib/__init__.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause @@ -6,7 +6,7 @@ # Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """\ diff --git a/eoxserver/contrib/gdal.py b/eoxserver/contrib/gdal.py index 7946ae340..320b30f2f 100644 --- a/eoxserver/contrib/gdal.py +++ b/eoxserver/contrib/gdal.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause @@ -6,7 +6,7 @@ # Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """\ This module imports and initializes GDAL; i.e enables exceptions and registers diff --git a/eoxserver/contrib/gdal_array.py b/eoxserver/contrib/gdal_array.py index d2f6e3abd..3e585837b 100644 --- a/eoxserver/contrib/gdal_array.py +++ b/eoxserver/contrib/gdal_array.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause @@ -6,7 +6,7 @@ # Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import os diff --git a/eoxserver/contrib/mapserver.py b/eoxserver/contrib/mapserver.py index 37e0d6b02..aeea57b7e 100644 --- a/eoxserver/contrib/mapserver.py +++ b/eoxserver/contrib/mapserver.py @@ -84,7 +84,7 @@ def __getitem__(self, key): def __setitem__(self, key, value): self.setMetaData(key, value) - def setMetaData(self, key_or_params, value=None, namespace=None): + def set_metadata(self, key_or_params, value=None, namespace=None): """ Convenvience method to allow setting multiple metadata values with one call and optionally setting a 'namespace' for each entry. """ @@ -122,7 +122,7 @@ def dispatch(map_, request): try: with os.fdopen(fd) as f: map_.save(filename) - logger.debug(f.read()) + # logger.debug(f.read()) finally: os.remove(filename) @@ -257,7 +257,7 @@ def gdalconst_to_imagemode_string(const): return "FLOAT32" -def setMetaData(obj, key_or_params, value=None, namespace=None): +def set_metadata(metadata, key_or_params, value=None, namespace=None): """ Convenvience function to allow setting multiple metadata values with one call and optionally setting a 'namespace' for each entry. """ @@ -266,17 +266,14 @@ def setMetaData(obj, key_or_params, value=None, namespace=None): if namespace: key = "%s_%s" % (namespace, key) - obj.setMetaData(key, value) + metadata.set(key, value) else: if namespace: key = "%s_%s" % (namespace, key_or_params) else: key = key_or_params - obj.setMetaData(key, value) - -# alias -set_metadata = setMetaData + metadata.set(key, value) def set_env(map_obj, env, fail_on_override=False, return_old=False): diff --git a/eoxserver/contrib/ogr.py b/eoxserver/contrib/ogr.py index cee76245f..93c85c3dd 100644 --- a/eoxserver/contrib/ogr.py +++ b/eoxserver/contrib/ogr.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause @@ -6,7 +6,7 @@ # Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import os diff --git a/eoxserver/contrib/osr.py b/eoxserver/contrib/osr.py index 63f9b110c..fc39aab72 100644 --- a/eoxserver/contrib/osr.py +++ b/eoxserver/contrib/osr.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause @@ -6,7 +6,7 @@ # Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,10 +26,9 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import os -from django.utils.six import string_types if os.environ.get('READTHEDOCS', None) != 'True': @@ -52,12 +51,12 @@ def __init__(self, raw=None, format=None): if raw is not None: format = format.upper() if format is not None else None if format == "WKT" or ( - isinstance(raw, string_types) and (raw.startswith('PROJCS') or raw.startswith('GEOGCS')) + isinstance(raw, str) and (raw.startswith('PROJCS') or raw.startswith('GEOGCS')) ): sr.ImportFromWkt(raw) elif isinstance(raw, int) or format == "EPSG": sr.ImportFromEPSG(int(raw)) - elif isinstance(raw, string_types) and raw.startswith('EPSG:'): + elif isinstance(raw, str) and raw.startswith('EPSG:'): sr.ImportFromEPSG(int(raw.partition(':')[2])) else: sr.SetFromUserInput(raw) diff --git a/eoxserver/contrib/vrt.py b/eoxserver/contrib/vrt.py index 450028a3d..af66e177c 100644 --- a/eoxserver/contrib/vrt.py +++ b/eoxserver/contrib/vrt.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,11 +23,10 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import subprocess import math -from django.utils.six import string_types from eoxserver.contrib import gdal, vsi, osr @@ -147,7 +146,7 @@ def add_simple_source(self, band_index, src, src_band, ` specifying the target area to contribute """ - if isinstance(src, string_types): + if isinstance(src, str): pass else: @@ -217,7 +216,7 @@ def add_simple_source(self, band_index, src, src_band, ` specifying the target area to contribute """ - if isinstance(src, string_types): + if isinstance(src, str): pass else: diff --git a/eoxserver/core/__init__.py b/eoxserver/core/__init__.py index e8c9780df..051dcb38e 100644 --- a/eoxserver/core/__init__.py +++ b/eoxserver/core/__init__.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """\ The eoxserver.core package provides functionality for the initialization and diff --git a/eoxserver/core/commands/__init__.py b/eoxserver/core/commands/__init__.py index cf09c7b57..6eacd4d00 100644 --- a/eoxserver/core/commands/__init__.py +++ b/eoxserver/core/commands/__init__.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,4 +25,4 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- \ No newline at end of file +# ------------------------------------------------------------------------------ \ No newline at end of file diff --git a/eoxserver/core/commands/create_instance.py b/eoxserver/core/commands/create_instance.py index 3c504a53f..e6f78f006 100644 --- a/eoxserver/core/commands/create_instance.py +++ b/eoxserver/core/commands/create_instance.py @@ -1,12 +1,12 @@ #!/usr/bin/env python -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ Create a new EOxServer instance. This instance will create a root directory diff --git a/eoxserver/core/config.py b/eoxserver/core/config.py index 6037b8ea4..8f0fe61b3 100644 --- a/eoxserver/core/config.py +++ b/eoxserver/core/config.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,28 +24,23 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ This module provides an implementation of a system configuration that relies on different configuration files. """ - -import imp -from os.path import join, getmtime +from os.path import join, getmtime, dirname from sys import prefix import threading import logging from time import time - -try: - from ConfigParser import RawConfigParser -except ImportError: - from configparser import RawConfigParser - +from configparser import RawConfigParser from django.conf import settings +import eoxserver + config_lock = threading.RLock() logger = logging.getLogger(__name__) @@ -71,9 +66,8 @@ def reload_eoxserver_config(): :class:`ConfigParser.RawConfigParser`. """ global _cached_config, _last_access_time - _, eoxs_path, _ = imp.find_module("eoxserver") paths = [ - join(eoxs_path, "conf", "default.conf"), + join(dirname(eoxserver.__file__), "conf", "default.conf"), join(prefix, "eoxserver/conf/default.conf"), get_instance_config_path() ] diff --git a/eoxserver/core/decoders/__init__.py b/eoxserver/core/decoders/__init__.py index d361af0fe..727a5863e 100644 --- a/eoxserver/core/decoders/__init__.py +++ b/eoxserver/core/decoders/__init__.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,12 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- - - -import sys - -from django.utils.six import reraise +# ------------------------------------------------------------------------------ ZERO_OR_ONE = "?" @@ -163,8 +158,7 @@ def __get__(self, decoder, decoder_class=None): # swallow exception continue - exc_info = sys.exc_info() - reraise(exc_info[0], exc_info[1], exc_info[2]) + raise return result diff --git a/eoxserver/core/decoders/base.py b/eoxserver/core/decoders/base.py index df0dccc14..f43daf292 100644 --- a/eoxserver/core/decoders/base.py +++ b/eoxserver/core/decoders/base.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ This module provides base functionality for any other decoder class. """ diff --git a/eoxserver/core/decoders/config.py b/eoxserver/core/decoders/config.py index 631f27fc0..32a1b28ad 100644 --- a/eoxserver/core/decoders/config.py +++ b/eoxserver/core/decoders/config.py @@ -32,12 +32,7 @@ from typing import Union import sys -try: - from ConfigParser import NoOptionError, NoSectionError -except ImportError: - from configparser import NoOptionError, NoSectionError - -from django.utils.six import with_metaclass +from configparser import NoOptionError, NoSectionError def section(name): @@ -126,7 +121,7 @@ def __init__(cls, name, bases, dct): super(ReaderMetaclass, cls).__init__(name, bases, dct) -class Reader(with_metaclass(ReaderMetaclass, object)): +class Reader(metaclass=ReaderMetaclass): """ Base class for config readers. :param config: an instance of :class:`ConfigParser.RawConfigParser` diff --git a/eoxserver/core/decoders/kvp.py b/eoxserver/core/decoders/kvp.py index c0d31925b..e6405b64d 100644 --- a/eoxserver/core/decoders/kvp.py +++ b/eoxserver/core/decoders/kvp.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,14 +23,14 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ This module contains facilities to help decoding KVP strings. """ +from urllib.parse import parse_qs + from django.http import QueryDict -from django.utils.six import string_types, add_metaclass -from django.utils.six.moves.urllib.parse import parse_qs from eoxserver.core.decoders.base import BaseParameter @@ -109,8 +109,7 @@ def __init__(cls, name, bases, dct): super(DecoderMetaclass, cls).__init__(name, bases, dct) -@add_metaclass(DecoderMetaclass) -class Decoder(object): +class Decoder(metaclass=DecoderMetaclass): """ Base class for KVP decoders. :param params: an instance of either :class:`dict`, @@ -149,7 +148,7 @@ def __init__(self, params): for key, values in params.lists(): query_dict[key.lower()] = values - elif isinstance(params, string_types): + elif isinstance(params, str): tmp = parse_qs(params) for key, values in tmp.items(): query_dict[key.lower()] = values diff --git a/eoxserver/core/decoders/xml.py b/eoxserver/core/decoders/xml.py index 4eaebfe0d..ca4938d27 100644 --- a/eoxserver/core/decoders/xml.py +++ b/eoxserver/core/decoders/xml.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,14 +23,14 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ This module contains facilities to help decoding XML structures. """ from lxml import etree + from eoxserver.core.decoders.base import BaseParameter -from django.utils.six import string_types class Parameter(BaseParameter): @@ -61,11 +61,11 @@ def __init__(self, selector, type=None, num=1, default=None, def select(self, decoder): # prepare the XPath selector if necessary - if isinstance(self.selector, string_types): + if isinstance(self.selector, str): namespaces = self.namespaces or decoder.namespaces self.selector = etree.XPath(self.selector, namespaces=namespaces) results = self.selector(decoder._tree) - if isinstance(results, (string_types + (float, int))): + if isinstance(results, (str, float, int)): results = [results] return results @@ -117,10 +117,10 @@ class ExampleDecoder(xml.Decoder): namespaces = {} # must be overriden if the XPath expressions use namespaces def __init__(self, tree): - if isinstance(tree, string_types) or isinstance(tree, bytes): + if isinstance(tree, str) or isinstance(tree, bytes): try: tree = etree.fromstring(tree) - + except etree.XMLSyntaxError as exc: # NOTE: lxml.etree.XMLSyntaxError is incorretly identified as # an OWS exception by the exception handler leading diff --git a/eoxserver/core/instance.py b/eoxserver/core/instance.py index ee5e1999f..a36ee5590 100644 --- a/eoxserver/core/instance.py +++ b/eoxserver/core/instance.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2016 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from os.path import join, isfile, dirname, abspath diff --git a/eoxserver/core/management.py b/eoxserver/core/management.py index f7717438d..e22409128 100644 --- a/eoxserver/core/management.py +++ b/eoxserver/core/management.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import os import sys diff --git a/eoxserver/core/models.py b/eoxserver/core/models.py index 7b70220ef..feb7be123 100644 --- a/eoxserver/core/models.py +++ b/eoxserver/core/models.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Stephan Meissl # Stephan Krause # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from django.contrib.gis.db import models diff --git a/eoxserver/core/tests.py b/eoxserver/core/tests.py index 35a53dc0a..bc13133bd 100644 --- a/eoxserver/core/tests.py +++ b/eoxserver/core/tests.py @@ -1,11 +1,11 @@ #!/usr/bin/env python -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import logging diff --git a/eoxserver/core/util/geotools.py b/eoxserver/core/util/geotools.py index cfa4462c3..a48158659 100644 --- a/eoxserver/core/util/geotools.py +++ b/eoxserver/core/util/geotools.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,4 +24,4 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ diff --git a/eoxserver/core/util/importtools.py b/eoxserver/core/util/importtools.py index 9e8a6441b..cbc18a616 100644 --- a/eoxserver/core/util/importtools.py +++ b/eoxserver/core/util/importtools.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ This module contains utilities to easily import hierarchies of packages and modules. @@ -33,16 +33,7 @@ import traceback import pkgutil -try: - # Python >= 3.1 - from importlib import import_module -except: - try: - # Django versions >= 1.9 - from django.utils.module_loading import import_module - except ImportError: - # Django versions < 1.9 - from django.utils.importlib import import_module +from importlib import import_module logger = logging.getLogger(__name__) @@ -114,14 +105,14 @@ def import_string(dotted_path): """ try: module_path, class_name = dotted_path.rsplit('.', 1) - except ValueError as err: + except ValueError: raise ImportError("%s doesn't look like a module path" % dotted_path) module = import_module(module_path) try: return getattr(module, class_name) - except AttributeError as err: + except AttributeError: raise ImportError('Module "%s" does not define a "%s" attribute/class' % ( module_path, class_name) ) diff --git a/eoxserver/core/util/iteratortools.py b/eoxserver/core/util/iteratortools.py index efa2a6abe..40a478dcd 100644 --- a/eoxserver/core/util/iteratortools.py +++ b/eoxserver/core/util/iteratortools.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,28 +23,23 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ This module is an extension of the :mod:`iteratortools` module and provides additional helpers. """ -try: - from itertools import izip -except ImportError: - izip = zip - from itertools import tee def pairwise(iterable): "s -> (s0,s1), (s2,s3), (s4, s5), ..." a = iter(iterable) - return izip(a, a) + return zip(a, a) def pairwise_iterative(iterable): "s -> (s0,s1), (s1,s2), (s2, s3), ..." a, b = tee(iterable) next(b, None) - return izip(a, b) + return zip(a, b) diff --git a/eoxserver/core/util/multiparttools.py b/eoxserver/core/util/multiparttools.py index 8e64e5ce2..4d55afd1e 100644 --- a/eoxserver/core/util/multiparttools.py +++ b/eoxserver/core/util/multiparttools.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ This module contains implementation of MIME multipart packing and unpacking @@ -33,240 +33,6 @@ is that the functions of this module do not manipulate the input data buffers and especially avoid any unnecessary data copying. """ -from django.utils.six import b - -def capitalize(header_name): - """ Capitalize header field name. Eg., 'content-type' is capilalized to - 'Content-Type'. - - .. deprecated:: 0.4 - """ - return "-".join([f.capitalize() for f in header_name.split("-")]) - -# local alias to prevent conflict with local variable -__capitalize = capitalize - - -def getMimeType(content_type): - """ Extract MIME-type from Content-Type string and convert it to - lower-case. - - .. deprecated:: 0.4 - """ - return content_type.partition(";")[0].strip().lower() - - -def getMultipartBoundary(content_type): - """ Extract boundary string from mutipart Content-Type string. - - .. deprecated:: 0.4 - """ - - for opt in content_type.split(";")[1:]: - key, _, val = opt.partition("=") - if key.strip().lower() == "boundary": - return val.strip() - - raise ValueError( - "failed to extract the mutipart boundary string! content-type: %s" - % content_type - ) - - -def mpPack(parts, boundary): - """ -Low-level memory-friendly MIME multipart packing. - -Note: The data payload is passed untouched and no transport encoding -of the payload is performed. - -Inputs: - - - parts - list of part-tuples, each tuple shall have two elements - the header list and (string) payload. The header itsels should be - a sequence of key-value pairs (tuples). - - - boundary - boundary string - -Ouput: - - - list of strings (which can be directly passsed as a Django response content) - -.. deprecated:: 0.4 - """ - - # empty multipart package - pack = ["--%s" % boundary] - - for header, data in parts: - - # pack header - for key, value in header: - pack.append("\r\n%s: %s" % (key, value)) - - # terminate header - pack.append("\r\n\r\n") - - # append data - pack.append(data) - - # terminate partition - pack.append("\r\n--%s" % boundary) - - #terminate package - pack.append("--") - - # return package - return pack - - -def mpUnpack(cbuffer, boundary, capitalize=False): - """ -Low-level memory-friendly MIME multipart unpacking. - -Note: The payload of the multipart package data is neither modified nor copied. -No decoding of the transport encoded payload is performed. - -Note: The subroutine does not unpack any nested mutipart content. - -Inputs: - - - ``cbuffer`` - character buffer (string) containing the - the header list and (string) payload. The header itsels should be - a sequence of key-value pairs (tuples). - - - ``boundary`` - boundary string - - - ``capitalize`` - by default the header keys are converted to lower-case - (e.g., 'content-type'). - To capitalize the names (e.g., 'Content-Type') set this option to true. - -Output: - - - list of parts - each part is a tuple of the header dictionary, - payload ``cbuffer`` offset and payload size. - -.. deprecated:: 0.4 - """ - - def findBorder(offset=0): - - delim = "--%s" % boundary if offset == 0 else "\n--%s" % boundary - - # boundary offset (end of last data) - idx0 = cbuffer.find(delim, offset) - - if idx0 < 0: - raise ValueError("Boundary cannot be found!") - - # header offset - idx1 = idx0 + len(delim) - - # nescessary check to be able to safely check two following characters - if len(cbuffer[idx1:]) < 2: - raise ValueError("Buffer too short!") - - # check the leading CR character - if idx0 > 0 and cbuffer[idx0-1] == "\r": - idx0 -= 1 - - # check the terminating sequence - if cbuffer[idx1:(idx1+2)] == "--": - return idx0, idx1+2, -1 - - # look-up double endl-line (data offset) - tmp = idx1 - - while True: - - tmp = 1 + cbuffer.find("\n", tmp) - - if tmp < 1: - raise ValueError( - "Cannot find payload's a double new-line separator!" - ) - - # is it followed by new line? - - elif cbuffer[tmp:(tmp+2)] == "\r\n": - idx2 = tmp + 2 - break - - elif cbuffer[tmp:(tmp+1)] == "\n": - idx2 = tmp + 1 - break - - # otherwise continue to lookup - continue - - # adjust the data offset (separator must be followed by new-line) - if cbuffer[idx1:(idx1+2)] == "\r\n": - idx1 += 2 - elif cbuffer[idx1:(idx1+1)] == "\n": - idx1 += 1 - else: - raise ValueError("Boundary is not followed by a new-line!") - - return idx0, idx1, idx2 - - #-------------------------------------------------------------------------- - # auxiliary nested functions formating header names - - # capitalize header name - def unpackCC(v): - key, _, val = v.partition(b(":"":")) - return __capitalize(key.strip()), val.strip() - - # header name all lower - def unpackLC(v): - key, _, val = v.partition(b(":")) - return key.strip().lower(), val.strip() - - # filter function rejecting entries with blank keys - def noblank(tup): - (k, v) = tup - return bool(k) - - #-------------------------------------------------------------------------- - - # get the offsets - # off = (,
,) - # negative means terminating boundary - - try: - - off = findBorder() - offsets = [off] - - while off[1] < off[2]: - off = findBorder(off[2]) - offsets.append(off) - - except ValueError as e: - raise Exception( - "The buffer is not a valid MIME multi-part message! Reason: %s" - % e.message - ) - - # process the parts - parts = [] - for of0, of1 in zip(offsets[:-1], offsets[1:]): - - # get the http header with line ending - tmp = cbuffer[of0[1]:of0[2]].replace("\r\n", "\n")[:-2].split("\n") - - # unpack header - header = dict( - filter(noblank, - map((unpackLC, unpackCC)[capitalize], tmp) - ) - ) - - # get the header and payload offset and size - parts.append((header, of0[2], of1[0]-of0[2])) - - return parts - CRLF = b"\r\n" CRLFCRLF = b"\r\n\r\n" diff --git a/eoxserver/core/util/perftools.py b/eoxserver/core/util/perftools.py index a87f4d3b4..9c441bad8 100644 --- a/eoxserver/core/util/perftools.py +++ b/eoxserver/core/util/perftools.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import time import logging diff --git a/eoxserver/core/util/rect.py b/eoxserver/core/util/rect.py index 23b069fac..0e3b45df5 100644 --- a/eoxserver/core/util/rect.py +++ b/eoxserver/core/util/rect.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ This module contains definition of the auxiliary 2D bounding box class. """ diff --git a/eoxserver/core/util/timetools.py b/eoxserver/core/util/timetools.py index 7cfd0ab6e..35a41ba88 100644 --- a/eoxserver/core/util/timetools.py +++ b/eoxserver/core/util/timetools.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,20 +24,12 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import re -from datetime import datetime, timedelta +from datetime import date, datetime, timedelta, timezone -from django.utils.timezone import utc, make_aware, is_aware -#from django.utils.dateparse import parse_datetime, parse_date - -try: - from dateutil.parser import parse - HAVE_DATEUTIL = True -except ImportError: - from django.utils.dateparse import parse_datetime, parse_date - HAVE_DATEUTIL = False +from django.utils.timezone import make_aware, is_aware def isoformat(dt): @@ -54,41 +46,36 @@ def isoformat(dt): return dt.isoformat("T") -def parse_iso8601(value, tzinfo=None): - """ Parses an ISO 8601 date or datetime string to a python date or datetime. +def parse_iso8601(value: str, tzinfo=None): + """ Parses an ISO 8601 date or datetime string to a python datetime. Raises a `ValueError` if a conversion was not possible. The returned datetime is always considered time-zone aware and defaulting to the given timezone `tzinfo` or UTC Zulu if none was specified. - If the optional module :mod:`dateutil` is installed, it is used in - preference over the :mod:`dateparse ` functions. - :param value: the string value to be parsed :param tzinfo: an optional tzinfo object that is used when the input string is not timezone aware :returns: a :class:`datetime.datetime` """ - tzinfo = tzinfo or utc - parsers = (parse,) if HAVE_DATEUTIL else (parse_datetime, parse_date) - for parser in parsers: + tzinfo = tzinfo or timezone.utc + + try: + if value.endswith("Z"): + value = value[:-1] + tzinfo = timezone.utc # force Zulu here + result = datetime.fromisoformat(value) + except ValueError: try: - temporal = parser(value) - except Exception as e: - raise ValueError( - "Could not parse '%s' to a temporal value. " - "Error was: %s" % (value, e) - ) - if temporal: - # convert to datetime if necessary - if not isinstance(temporal, datetime): - temporal = datetime.combine(temporal, datetime.min.time()) - - # use UTC, if the datetime is not already time-zone aware - if not is_aware(temporal): - temporal = make_aware(temporal, tzinfo) - - return temporal + result = datetime.combine(date.fromisoformat(value), datetime.min.time()) + except ValueError: + result = None + + if result is not None: + # use UTC, if the datetime is not already time-zone aware + if not is_aware(result): + result = make_aware(result, tzinfo) + return result raise ValueError("Could not parse '%s' to a temporal value" % value) diff --git a/eoxserver/core/util/xmltools.py b/eoxserver/core/util/xmltools.py index d872ea06a..284e622a4 100644 --- a/eoxserver/core/util/xmltools.py +++ b/eoxserver/core/util/xmltools.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,41 +24,22 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ This module contains utils for XML encoding, decoding and printing. """ -from django.utils.six import string_types + import logging -try: - from lxml import etree -except ImportError: - try: - # Python 2.5 - import xml.etree.cElementTree as etree - except ImportError: - try: - # Python 2.5 - import xml.etree.ElementTree as etree - except ImportError: - try: - # normal cElementTree install - import cElementTree as etree - except ImportError: - try: - # normal ElementTree install - import elementtree.ElementTree as etree - except ImportError: - pass # could not get etree +from lxml import etree logger = logging.getLogger(__name__) -#----------------------------------------------------------------------- +# ---------------------------------------------------------------------- # lxml.etree helpers -#----------------------------------------------------------------------- +# ---------------------------------------------------------------------- class NameSpace(object): @@ -91,7 +72,7 @@ def schema_location(self): def __eq__(self, other): if isinstance(other, NameSpace): return self.uri == other.uri - elif isinstance(other, string_types): + elif isinstance(other, str): return self.uri == other raise TypeError @@ -166,6 +147,7 @@ def add_cdata(element, cdata): element.text = cdata + try: typemap = { etree.CDATA: add_cdata diff --git a/eoxserver/core/views.py b/eoxserver/core/views.py index 29c63a08c..64d153d9e 100644 --- a/eoxserver/core/views.py +++ b/eoxserver/core/views.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from django.shortcuts import render_to_response diff --git a/eoxserver/instance_template/project_name/conf/eoxserver.conf b/eoxserver/instance_template/project_name/conf/eoxserver.conf index 1790ff473..252a73137 100644 --- a/eoxserver/instance_template/project_name/conf/eoxserver.conf +++ b/eoxserver/instance_template/project_name/conf/eoxserver.conf @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,11 +25,11 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -#----------------------------------------------------------------------- +# ---------------------------------------------------------------------- # New style configuration -#----------------------------------------------------------------------- +# ---------------------------------------------------------------------- [core.system] diff --git a/eoxserver/instance_template/project_name/conf/formats.conf b/eoxserver/instance_template/project_name/conf/formats.conf index 7665696af..99db15186 100644 --- a/eoxserver/instance_template/project_name/conf/formats.conf +++ b/eoxserver/instance_template/project_name/conf/formats.conf @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2012 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,14 +23,14 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # This is the user provided list of supported file formats extending/overriding # the EOxServer's default list of supported file formats. # -# This configuration file is optional and it should not cause any harm -# to keep this file empty or omit it completely. +# This configuration file is optional and it should not cause any harm +# to keep this file empty or omit it completely. # # Line format: # @@ -40,7 +40,7 @@ # # We recommend to use MIME types as the unique identifiers in the first column. # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ image/gif,GDAL/GIF,.gif image/jp2,GDAL/JPEG2000,.jp2 # JasPer driver - left to assure functionality with GDAL having no OpenJpeg driver diff --git a/eoxserver/instance_template/project_name/settings.py b/eoxserver/instance_template/project_name/settings.py index 5c0471151..263a9571d 100644 --- a/eoxserver/instance_template/project_name/settings.py +++ b/eoxserver/instance_template/project_name/settings.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ Django settings for EOxServer's {{ project_name }} instance. diff --git a/eoxserver/instance_template/project_name/templates/admin/base_site.html b/eoxserver/instance_template/project_name/templates/admin/base_site.html index d24e193de..9f3794538 100644 --- a/eoxserver/instance_template/project_name/templates/admin/base_site.html +++ b/eoxserver/instance_template/project_name/templates/admin/base_site.html @@ -1,11 +1,11 @@ {% extends "admin/base.html" %} {% load i18n %} diff --git a/eoxserver/instance_template/project_name/wsgi.py b/eoxserver/instance_template/project_name/wsgi.py index 31b18b68c..4048a84b7 100644 --- a/eoxserver/instance_template/project_name/wsgi.py +++ b/eoxserver/instance_template/project_name/wsgi.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2012 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ WSGI config for EOxServer's {{ project_name }} instance. diff --git a/eoxserver/processing/gdal/reftools.py b/eoxserver/processing/gdal/reftools.py index bac6062e0..e62a27bca 100644 --- a/eoxserver/processing/gdal/reftools.py +++ b/eoxserver/processing/gdal/reftools.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,16 +24,12 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import ctypes as C from ctypes.util import find_library import logging -try: - from itertools import chain, izip -except ImportError : - from itertools import chain - izip = zip +from itertools import chain import math @@ -41,22 +37,15 @@ from eoxserver.core.util.rect import Rect from eoxserver.core.util.xmltools import parse, etree from eoxserver.contrib import vsi -from django.utils.six import string_types, b -try: - # Python 2 - xrange -except NameError: - # Python 3, xrange is now named range - xrange = range -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # approximation transformer's threshold in pixel units # 0.125 is the default value used by CLI gdalwarp tool APPROX_ERR_TOL = 0.125 -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # GDAL transfomer methods METHOD_GCP = 1 @@ -69,7 +58,7 @@ METHOD_TPS_LSQ: "METHOD_TPS_LSQ" } -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ logger = logging.getLogger(__name__) @@ -113,6 +102,7 @@ class WARP_OPTIONS(C.Structure): ("dfCutlineBlendDist", C.c_double), ] + _libgdal = C.LibraryLoader(C.CDLL).LoadLibrary(find_library("gdal")) @@ -127,8 +117,9 @@ class GCP(C.Structure): ("dfGCPZ", C.c_double), ] + GDALGetGCPs = _libgdal.GDALGetGCPs -GDALGetGCPs.restype = C.c_void_p # actually array of GCPs, but more info not required +GDALGetGCPs.restype = C.c_void_p # actually array of GCPs, but more info not required GDALGetGCPs.argtypes = [C.c_void_p] @@ -449,26 +440,26 @@ def get_footprint_wkt(ds, method=METHOD_GCP, order=0): success = (C.c_int * num_points)() - for i in xrange(1, x_e + 1): + for i in range(1, x_e + 1): x[i] = float(i * x_size / x_e) y[i] = 0.0 x[x_e + 1] = x_size - for i in xrange(1, y_e + 1): + for i in range(1, y_e + 1): x[x_e + 1 + i] = float(x_size) y[x_e + 1 + i] = float(i * y_size / y_e) x[x_e + y_e + 2] = x_size y[x_e + y_e + 2] = y_size - for i in xrange(1, x_e + 1): + for i in range(1, x_e + 1): x[x_e + y_e + 2 + i] = float(x_size - i * x_size / x_e) y[x_e + y_e + 2 + i] = y_size y[x_e * 2 + y_e + 3] = y_size - for i in xrange(1, y_e + 1): + for i in range(1, y_e + 1): x[x_e * 2 + y_e + 3 + i] = 0.0 y[x_e * 2 + y_e + 3 + i] = float(y_size - i * y_size / y_e) @@ -477,7 +468,7 @@ def get_footprint_wkt(ds, method=METHOD_GCP, order=0): return "POLYGON((%s))" % ( ",".join( "%f %f" % (coord_x, coord_y) - for coord_x, coord_y in chain(izip(x, y), ((x[0], y[0]),)) + for coord_x, coord_y in chain(zip(x, y), ((x[0], y[0]),)) ) ) @@ -563,28 +554,28 @@ def rect_from_subset(path_or_ds, srid, minx, miny, maxx, maxy, x[0] = minx y[0] = miny - for i in xrange(1, num_x + 1): + for i in range(1, num_x + 1): x[i] = minx + i * x_step y[i] = miny x[num_x + 1] = maxx y[num_x + 1] = miny - for i in xrange(1, num_y + 1): + for i in range(1, num_y + 1): x[num_x + 1 + i] = maxx y[num_x + 1 + i] = miny + i * y_step x[num_x + num_y + 2] = maxx y[num_x + num_y + 2] = maxy - for i in xrange(1, num_x + 1): + for i in range(1, num_x + 1): x[num_x + num_y + 2 + i] = maxx - i * x_step y[num_x + num_y + 2 + i] = maxy x[num_x * 2 + num_y + 3] = minx y[num_x * 2 + num_y + 3] = maxy - for i in xrange(1, num_y + 1): + for i in range(1, num_y + 1): x[num_x * 2 + num_y + 3 + i] = minx y[num_x * 2 + num_y + 3 + i] = maxy - i * y_step @@ -704,11 +695,11 @@ def create_rectified_vrt(path_or_ds, vrt_path, srid_or_wkt=None, # vrt_ds = GDALCreateWarpedVRT(ptr, x_size, y_size, geotransform, options) if isinstance(wkt, str): - wkt = b(wkt) + wkt = wkt.encode() vrt_ds = GDALAutoCreateWarpedVRT(ptr, None, wkt, resample, max_error, None) # GDALSetProjection(vrt_ds, wkt) if isinstance(vrt_path, str): - vrt_path = b(vrt_path) + vrt_path = vrt_path.encode() GDALSetDescription(vrt_ds, vrt_path) GDALClose(vrt_ds) @@ -881,7 +872,7 @@ def reproject_image(src_ds, src_wkt, dst_ds, dst_wkt, def _open_ds(path_or_ds): - if isinstance(path_or_ds, string_types): + if isinstance(path_or_ds, str): gdal.AllRegister() return gdal.OpenShared(str(path_or_ds)) return path_or_ds diff --git a/eoxserver/processing/gdal/vrt.py b/eoxserver/processing/gdal/vrt.py index 9cfcfb54b..8a54ba028 100644 --- a/eoxserver/processing/gdal/vrt.py +++ b/eoxserver/processing/gdal/vrt.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.contrib import gdal diff --git a/eoxserver/processing/preprocessing/__init__.py b/eoxserver/processing/preprocessing/__init__.py index e9fb3444a..02235e1ee 100644 --- a/eoxserver/processing/preprocessing/__init__.py +++ b/eoxserver/processing/preprocessing/__init__.py @@ -1,11 +1,11 @@ #!/usr/bin/env python -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from os.path import splitext try: @@ -87,9 +87,9 @@ def _posListToString(self, ring): # enum for bandmode RGB, RGBA, ORIG_BANDS = range(3) -#=============================================================================== +# ============================================================================== # Pre-Processors -#=============================================================================== +# ============================================================================== class PreProcessor(object): @@ -323,7 +323,7 @@ def _generate_footprint_wkt(self, ds): geometry.TransformTo(dst_sr.sr) except RuntimeError: geometry.Transform(osr.CoordinateTransformation(sr.sr, dst_sr.sr)) - + gt = ds.GetGeoTransform() resolution = min(abs(gt[1]), abs(gt[5])) @@ -430,9 +430,9 @@ def get_post_optimizations(self, ds): self.overview_minsize) -#=============================================================================== +# ============================================================================== # PreProcess result -#=============================================================================== +# ============================================================================== class PreProcessResult(object): """ Result storage for preprocessed datasets. """ diff --git a/eoxserver/processing/preprocessing/exceptions.py b/eoxserver/processing/preprocessing/exceptions.py index 78e75c8e0..7adfdbedd 100644 --- a/eoxserver/processing/preprocessing/exceptions.py +++ b/eoxserver/processing/preprocessing/exceptions.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class PreprocessingException(Exception): diff --git a/eoxserver/processing/preprocessing/format.py b/eoxserver/processing/preprocessing/format.py index 590c92277..b52e8e2c3 100644 --- a/eoxserver/processing/preprocessing/format.py +++ b/eoxserver/processing/preprocessing/format.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2012 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,11 +24,13 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- -from django.utils.six import string_types +# ------------------------------------------------------------------------------ + + # global format selection registry _registry = {} + def get_format_selection(driver, *args, **kwargs): """ Format selection factory method. """ @@ -42,37 +44,33 @@ class FormatSelectionMetaclass(type): """ Metaclass for format selections """ def __init__(cls, name, bases, dct): - if isinstance(dct["driver_name"], string_types): + if isinstance(dct["driver_name"], str): _registry[dct["driver_name"]] = cls super(FormatSelectionMetaclass, cls).__init__(name, bases, dct) -#=============================================================================== +# ============================================================================== # Format selection -#=============================================================================== +# ============================================================================== class FormatSelection(object): """ Format selection with format specific options. """ __metaclass__ = FormatSelectionMetaclass - @property def driver_name(self): raise NotImplementedError - @property def extension(self): raise NotImplementedError - @property def creation_options(self): return [] - class GeoTIFFFormatSelection(FormatSelection): """ Format selection for GeoTIFF format. """ @@ -80,7 +78,6 @@ class GeoTIFFFormatSelection(FormatSelection): SUPPORTED_COMPRESSIONS = ("JPEG", "LZW", "PACKBITS", "DEFLATE", "CCITTRLE", "CCITTFAX3", "CCITTFAX4", "NONE") - def __init__(self, tiling=True, compression=None, jpeg_quality=None, zlevel=None, creation_options=None): self.final_options = {} @@ -110,11 +107,9 @@ def __init__(self, tiling=True, compression=None, if creation_options: self.final_options.update(dict(creation_options)) - driver_name = "GTiff" extension = ".tif" - @property def creation_options(self): return ["%s=%s" % (key, value) diff --git a/eoxserver/processing/preprocessing/georeference.py b/eoxserver/processing/preprocessing/georeference.py index df8ae9a1d..f10410896 100644 --- a/eoxserver/processing/preprocessing/georeference.py +++ b/eoxserver/processing/preprocessing/georeference.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2012 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import logging @@ -39,9 +39,9 @@ logger = logging.getLogger(__name__) -#=============================================================================== +# ============================================================================== # Geographic references -#=============================================================================== +# ============================================================================== class GeographicReference(object): pass diff --git a/eoxserver/processing/preprocessing/optimization.py b/eoxserver/processing/preprocessing/optimization.py index fb2934711..2529b895e 100644 --- a/eoxserver/processing/preprocessing/optimization.py +++ b/eoxserver/processing/preprocessing/optimization.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2012 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import logging import math @@ -38,13 +38,12 @@ from eoxserver.resources.coverages.crss import ( parseEPSGCode, fromShortCode, fromURL, fromURN, fromProj4Str ) -from django.utils.six import string_types logger = logging.getLogger(__name__) -#=============================================================================== +# ============================================================================== # Dataset Optimization steps -#=============================================================================== +# ============================================================================== class DatasetOptimization(object): @@ -65,7 +64,7 @@ class ReprojectionOptimization(DatasetOptimization): def __init__(self, crs_or_srid, temporary_directory=None): if isinstance(crs_or_srid, int): pass - elif isinstance(crs_or_srid, string_types): + elif isinstance(crs_or_srid, str): crs_or_srid = parseEPSGCode(crs_or_srid, (fromShortCode, fromURL, fromURN, fromProj4Str)) else: @@ -319,9 +318,9 @@ def __call__(self, ds): return ds -#=============================================================================== +# ============================================================================== # Post-create optimization steps -#=============================================================================== +# ============================================================================== class DatasetPostOptimization(object): """ Abstract base class for dataset post-creation optimization steps. These @@ -378,9 +377,9 @@ def __call__(self, ds): return ds -#=============================================================================== +# ============================================================================== # AlphaBand Optimization -#=============================================================================== +# ============================================================================== class AlphaBandOptimization(object): """ This optimization renders the footprint into the alpha channel of the @@ -416,13 +415,13 @@ def __call__(self, src_ds, footprint_wkt): gdal.RasterizeLayer(src_ds, [4], layer, burn_values=[get_limits(dt)[1]]) -#=============================================================================== +# ============================================================================== # Color To Alpha Optimization -#=============================================================================== +# ============================================================================== class ColorToAlphaOptimization(DatasetOptimization): """ - Pixel-wise optimization burns color_to_alpha pixels of RGB + Pixel-wise optimization burns color_to_alpha pixels of RGB into alpha channel as 0 (transparent) if all bands have pixel value = [color_to_alpha +- margin]. Default black is turned to transparent. Returns modified dataset. """ diff --git a/eoxserver/processing/preprocessing/util.py b/eoxserver/processing/preprocessing/util.py index 6edc794c4..ab1ab6870 100644 --- a/eoxserver/processing/preprocessing/util.py +++ b/eoxserver/processing/preprocessing/util.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2012 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from os.path import exists, join from uuid import uuid4 @@ -53,9 +53,9 @@ def get_limits(dt): return info.min, info.max -#=============================================================================== +# ============================================================================== # helper functions -#=============================================================================== +# ============================================================================== def create_mem_copy(ds, *args, **kwargs): """ Create a new In-Memory Dataset as copy from an existing dataset. """ diff --git a/eoxserver/render/browse/generate.py b/eoxserver/render/browse/generate.py index 73fb31135..522cda761 100644 --- a/eoxserver/render/browse/generate.py +++ b/eoxserver/render/browse/generate.py @@ -34,7 +34,6 @@ from functools import wraps import numpy as np -from django.utils.six import string_types from eoxserver.render.browse.util import warp_fields from eoxserver.render.browse.functions import get_function, get_buffer @@ -155,7 +154,7 @@ def extract_fields(band_expression): :return: a list of field names :rtype: list """ - if isinstance(band_expression, string_types): + if isinstance(band_expression, str): root_expr = parse_expression(band_expression) else: root_expr = band_expression diff --git a/eoxserver/render/coverage/objects.py b/eoxserver/render/coverage/objects.py index c6bf8a18f..e2e89b7b9 100644 --- a/eoxserver/render/coverage/objects.py +++ b/eoxserver/render/coverage/objects.py @@ -25,15 +25,10 @@ # THE SOFTWARE. # ------------------------------------------------------------------------------ -try: - from itertools import izip_longest -except ImportError: - from itertools import zip_longest as izip_longest - +from itertools import zip_longest from copy import deepcopy from typing import List, Optional, Union -from django.utils.six import string_types from eoxserver.core.util.timetools import parse_iso8601, parse_duration from eoxserver.contrib import gdal, osr from eoxserver.contrib.osr import SpatialReference @@ -150,7 +145,7 @@ def get_field(self, name): def subset(self, subsets): fields = [] for subset in subsets: - if isinstance(subset, string_types): + if isinstance(subset, str): fields.append(deepcopy(self.get_field(subset))) elif isinstance(subset, (list, tuple)): start_id, stop_id = subset @@ -338,7 +333,7 @@ def from_model(cls, grid_model): axes = [] - axes_iter = izip_longest(names, types, offsets) + axes_iter = zip_longest(names, types, offsets) for name, type_, offset in axes_iter: if is_ref: offset = None @@ -581,7 +576,7 @@ def extent(self): highs = [] if offsets[0] is not None: - axes = izip_longest(types, offsets, self.origin, self.size) + axes = zip_longest(types, offsets, self.origin, self.size) for type_, offset, origin, size in axes: a = origin b = origin + size * offset @@ -624,6 +619,7 @@ def get_location_for_field( for location in self.arraydata_locations: if index >= location.start_field and index <= location.end_field: return location + return None def get_band_index_for_field(self, field_or_identifier): field = self.lookup_field(field_or_identifier) @@ -778,7 +774,7 @@ def extent(self): lows = [] highs = [] - axes = izip_longest(types, offsets, self.origin, self.size) + axes = zip_longest(types, offsets, self.origin, self.size) for type_, offset, origin, size in axes: a = origin b = origin + size * offset diff --git a/eoxserver/render/mapserver/factories.py b/eoxserver/render/mapserver/factories.py index 4f1cc7967..042626a02 100644 --- a/eoxserver/render/mapserver/factories.py +++ b/eoxserver/render/mapserver/factories.py @@ -385,7 +385,7 @@ def make_browse_layer_generator(self, map_obj, browses, map_, if reset_info: sr = osr.SpatialReference(map_.crs) extent = map_.bbox - layer_obj.setMetaData( + layer_obj.metadata.set( "wms_extent", "%f %f %f %f" % extent ) @@ -393,8 +393,8 @@ def make_browse_layer_generator(self, map_obj, browses, map_, if sr.srid is not None: short_epsg = "EPSG:%d" % sr.srid - layer_obj.setMetaData("ows_srs", short_epsg) - layer_obj.setMetaData("wms_srs", short_epsg) + layer_obj.metadata.set("ows_srs", short_epsg) + layer_obj.metadata.set("wms_srs", short_epsg) layer_obj.setProjection(sr.proj) if browse.mode == BROWSE_MODE_GRAYSCALE: @@ -815,13 +815,13 @@ def _create_raster_layer_objs(map_obj, extent, sr, data, filename_generator, env layer_obj.offsite = ms.colorObj(0, 0, 0) if extent: - layer_obj.setMetaData("wms_extent", "%f %f %f %f" % extent) + layer_obj.metadata.set("wms_extent", "%f %f %f %f" % extent) layer_obj.setExtent(*extent) if sr.srid is not None: short_epsg = "EPSG:%d" % sr.srid - layer_obj.setMetaData("ows_srs", short_epsg) - layer_obj.setMetaData("wms_srs", short_epsg) + layer_obj.metadata.set("ows_srs", short_epsg) + layer_obj.metadata.set("wms_srs", short_epsg) layer_obj.setProjection(sr.proj) @@ -843,12 +843,12 @@ def _create_raster_layer_objs(map_obj, extent, sr, data, filename_generator, env if browse_mode != BROWSE_MODE_RGBA: wrapped_layer_obj.offsite = ms.colorObj(0, 0, 0) - wrapped_layer_obj.setMetaData("ows_srs", short_epsg) - wrapped_layer_obj.setMetaData("wms_srs", short_epsg) + wrapped_layer_obj.metadata.set("ows_srs", short_epsg) + wrapped_layer_obj.metadata.set("wms_srs", short_epsg) wrapped_layer_obj.setProjection(sr.proj) wrapped_layer_obj.setExtent(*wrapped_extent) - wrapped_layer_obj.setMetaData( + wrapped_layer_obj.metadata.set( "wms_extent", "%f %f %f %f" % wrapped_extent ) return [layer_obj, wrapped_layer_obj] @@ -865,8 +865,8 @@ def _create_polygon_layer(map_obj): srid = 4326 layer_obj.setProjection(crss.asProj4Str(srid)) - layer_obj.setMetaData("ows_srs", crss.asShortCode(srid)) - layer_obj.setMetaData("wms_srs", crss.asShortCode(srid)) + layer_obj.metadata.set("ows_srs", crss.asShortCode(srid)) + layer_obj.metadata.set("wms_srs", crss.asShortCode(srid)) layer_obj.dump = True diff --git a/eoxserver/resources/coverages/admin.py b/eoxserver/resources/coverages/admin.py index 008d0a1ba..9d906b36f 100644 --- a/eoxserver/resources/coverages/admin.py +++ b/eoxserver/resources/coverages/admin.py @@ -28,10 +28,8 @@ # ------------------------------------------------------------------------------ from django.contrib.gis import admin -try: - from django.core.urlresolvers import reverse, NoReverseMatch -except ImportError: - from django.urls import reverse, NoReverseMatch + +from django.urls import reverse, NoReverseMatch from django.utils.safestring import mark_safe from django.conf import settings from django.forms import ModelForm, TextInput @@ -46,7 +44,6 @@ class FieldTypeInline(admin.StackedInline): model = models.FieldType - filter_horizontal = ['nil_values'] extra = 0 def get_queryset(self, *args, **kwargs): @@ -169,7 +166,7 @@ class CollectionMetadataInline(admin.StackedInline): # Abstract admins # ============================================================================== -class EOObjectAdmin(admin.GeoModelAdmin): +class EOObjectAdmin(admin.GISModelAdmin): date_hierarchy = 'inserted' @property diff --git a/eoxserver/resources/coverages/crss.py b/eoxserver/resources/coverages/crss.py index 1d001ce81..74c01f9ab 100644 --- a/eoxserver/resources/coverages/crss.py +++ b/eoxserver/resources/coverages/crss.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,15 +23,15 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ This module provides CRS handling utilities. """ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -import re +import re import logging import math @@ -42,13 +42,13 @@ logger = logging.getLogger(__name__) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ #: Set (Python ``set`` type) of EPSG codes of CRS whose axes are displayed -#: in reversed order. -#: Source: GDAL 1.10.0, WKT/AXES definitions -EPSG_AXES_REVERSED = set([ - # GEOGRAPHIC COORDINATE SYSTEMS - # NOTE: Tested to be consistent with GDAL +#: in reversed order. +#: Source: GDAL 1.10.0, WKT/AXES definitions +EPSG_AXES_REVERSED = set([ + # GEOGRAPHIC COORDINATE SYSTEMS + # NOTE: Tested to be consistent with GDAL # OGRSpatialReference::EPSGTreatsAsNorthingEasting() 3819, 3821, 3824, 3889, 3906, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009, 4010, 4011, 4012, 4013, 4014, 4015, 4016, 4018, 4019, 4020, @@ -89,11 +89,11 @@ 4823, 4824, 4901, 4902, 4903, 4904, 5013, 5132, 5228, 5229, 5233, 5246, 5252, 5264, 5324, 5340, 5354, 5360, 5365, 5371, 5373, 5381, 5393, 5451, 5464, 5467, 5489, 5524, 5527, 5546, - # PROJECTED COORDINATE SYSTEMS + # PROJECTED COORDINATE SYSTEMS #TODO: verify with OGRSpatialReference::EPSGTreatsAsNorthingEasting() # (avaiable only in GDAL 1.10.0 C/C++ API but not in Python) # SOUTH,WEST pointing projected coordinate systems: - # NOTE: These are probably inconsistent with + # NOTE: These are probably inconsistent with # OGRSpatialReference::EPSGTreatsAsNorthingEasting() # as this fucntion check NORTH pointing coordinates only. 2065, 5513, @@ -204,7 +204,7 @@ 32661, 32761, ]) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # format functions @@ -234,7 +234,7 @@ def asProj4Str(epsg): """ convert EPSG code to *proj4* ``+init=epsg:`` notation """ return "+init=epsg:%d" % int(epsg) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # format parsers @@ -304,7 +304,7 @@ def parseEPSGCode(string, parsers): return None -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # public API __SUPPORTED_CRS_WMS = None @@ -340,7 +340,7 @@ def getSupportedCRS_WCS(format_function=asShortCode): # return formated list of EPSG codes return list(map(format_function, __SUPPORTED_CRS_WCS)) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ def hasSwappedAxes(epsg): @@ -433,7 +433,7 @@ def is_image_crs(string): return string in image_crss_ids -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ def _parseListOfCRS(raw_value): """ parse CRS configuartion """ @@ -455,7 +455,7 @@ def checkCode(v): # filter out invalid EPSG codes and covert them to integer return list(map(int, filter(checkCode, tmp.split(",")))) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class CRSsConfigReader(config.Reader): diff --git a/eoxserver/resources/coverages/formats.py b/eoxserver/resources/coverages/formats.py index 267c39b7b..2498033a9 100644 --- a/eoxserver/resources/coverages/formats.py +++ b/eoxserver/resources/coverages/formats.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,35 +23,29 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ This module contains format handling utilities. """ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import re import sys -import imp import logging import os.path from django.conf import settings +import eoxserver from eoxserver.contrib import gdal from eoxserver.core.config import get_eoxserver_config from eoxserver.core.decoders import config, typelist, strip -try: - # Python 2 - xrange -except NameError: - # Python 3, xrange is now named range - xrange = range logger = logging.getLogger(__name__) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class FormatRegistryException(Exception): @@ -125,7 +119,7 @@ class FormatRegistry(object): Configuration values are read from these files. """ - #--------------------------------------------------------------------------- + # -------------------------------------------------------------------------- def __init__(self, config): # get path to EOxServer installation @@ -211,8 +205,8 @@ def getSupportedFormatsWCS(self): Get list of formats to be announced as supported WCS formats. The the listed formats must be: - * defined in EOxServers configuration (section "services.ows.wcs", item "supported_formats") - * defined in the formats' configuration ("default_formats.conf" or "formats.conf") + * defined in EOxServers configuration (section "services.ows.wcs", item "supported_formats") + * defined in the formats' configuration ("default_formats.conf" or "formats.conf") * supported by the used GDAL installation """ return self.__wcs_supported_formats @@ -222,8 +216,8 @@ def getSupportedFormatsWMS(self): Get list of formats to be announced as supported WMS formats. The the listed formats must be: - * defined in EOxServers configuration (section "services.ows.wms", item "supported_formats") - * defined in the formats' configuration ("default_formats.conf" or "formats.conf") + * defined in EOxServers configuration (section "services.ows.wms", item "supported_formats") + * defined in the formats' configuration ("default_formats.conf" or "formats.conf") * supported by the used GDAL installation """ return self.__wms_supported_formats @@ -232,7 +226,7 @@ def mapSourceToNativeWCS20(self, format): """ Map source format to WCS 2.0 native format. Both the input and output shall be instances of :class:`Formats` class. - The input format can be obtained, e.g., by the `getFormatByDriver` or `getFormatByMIME` + The input format can be obtained, e.g., by the `getFormatByDriver` or `getFormatByMIME` method. To force the default native format use None as the source format. @@ -245,7 +239,7 @@ def mapSourceToNativeWCS20(self, format): 2. If the format resulting from step 1 is not a writable GDAL format or it is not among the supported WCS formats than it is replaced by the default native format (defined in EOxServers - configuration, section "services.ows.wcs20", item "default_native_format"). + configuration, section "services.ows.wcs20", item "default_native_format"). In case of writable GDAL format, the result of step 1 is returned. """ @@ -296,7 +290,7 @@ def __parse_config(self, config): tmp = reader.source_to_native_format_map tmp = list(map(lambda m: self.getFormatByMIME(m.strip()), list(tmp.split(',')))) - tmp = [(tmp[i], tmp[i + 1]) for i in xrange(0, (len(tmp) >> 1) << 1, 2)] + tmp = [(tmp[i], tmp[i + 1]) for i in range(0, (len(tmp) >> 1) << 1, 2)] tmp = list(filter(lambda p: list(p)[0] is not None and list(p)[1] is not None, tmp)) self.__wcs20_format_mapping = dict(tmp) @@ -347,7 +341,7 @@ def __parse_line(self, line, fname, lnum): # parse line try: - line = line.partition("#")[0].strip() # strip comments and white characters + line = line.partition("#")[0].strip() # strip comments and white characters if not line: return @@ -401,7 +395,7 @@ def __get_path_eoxs(self): """ try: - return imp.find_module("eoxserver")[1] + return os.path.dirname(eoxserver.__file__) except ImportError: raise FormatRegistryException( "Filed to find the 'eoxserver' module! Check your modules' path!" @@ -420,7 +414,7 @@ class FormatConfigReader(config.Reader): source_to_native_format_map = config.Option() -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # regular expression validators #: MIME-type regular expression validator (compiled reg.ex. pattern) @@ -443,7 +437,7 @@ def valMimeType(string): def valDriver(string): """ - Driver identifier reg.ex. validator. If pattern not matched 'None' is returned + Driver identifier reg.ex. validator. If pattern not matched 'None' is returned otherwise the input is returned. """ rv = string if _gerexValDriv.match(string) else None @@ -451,7 +445,7 @@ def valDriver(string): logger.warning("Invalid driver's identifier \"%s\"." % string) return rv -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # public API @@ -477,4 +471,4 @@ def getFormatRegistry(): return __FORMAT_REGISTRY -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ diff --git a/eoxserver/resources/coverages/management/commands/__init__.py b/eoxserver/resources/coverages/management/commands/__init__.py index 6da59b599..df142bde8 100644 --- a/eoxserver/resources/coverages/management/commands/__init__.py +++ b/eoxserver/resources/coverages/management/commands/__init__.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,14 +25,13 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import logging import traceback from optparse import OptionValueError import django -from django.db import transaction from django.core.management.base import CommandParser @@ -136,18 +135,11 @@ def print_traceback(self, e, kwargs): self.print_msg(traceback.format_exc()) -def create_parser(cmd, kwargs): - if django.VERSION[0] < 2: - return CommandParser(cmd, **kwargs) - else: - return CommandParser(**kwargs) - -class SubParserMixIn(object): - def add_subparser(self, parser, name, *args, **kwargs): +class SubParserMixIn: + def add_subparser(self, parser: CommandParser, name, *args, **kwargs): if not getattr(self, 'subparsers', None): self.subparsers = parser.add_subparsers( title="subcommands", - parser_class=lambda **kw: create_parser(self, kw) ) subparser = self.subparsers.add_parser(name, *args, **kwargs) subparser.set_defaults(subcommand=name) diff --git a/eoxserver/resources/coverages/metadata/component.py b/eoxserver/resources/coverages/metadata/component.py index 5c136cf0d..254a61976 100644 --- a/eoxserver/resources/coverages/metadata/component.py +++ b/eoxserver/resources/coverages/metadata/component.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.contrib.vsi import open as vsi_open diff --git a/eoxserver/resources/coverages/metadata/coverage_formats/dimap_general.py b/eoxserver/resources/coverages/metadata/coverage_formats/dimap_general.py index 425f235cb..bf42ff746 100644 --- a/eoxserver/resources/coverages/metadata/coverage_formats/dimap_general.py +++ b/eoxserver/resources/coverages/metadata/coverage_formats/dimap_general.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core.util.timetools import parse_iso8601 diff --git a/eoxserver/resources/coverages/metadata/coverage_formats/eoom.py b/eoxserver/resources/coverages/metadata/coverage_formats/eoom.py index d784d53f2..8ab96f9b1 100644 --- a/eoxserver/resources/coverages/metadata/coverage_formats/eoom.py +++ b/eoxserver/resources/coverages/metadata/coverage_formats/eoom.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from django.contrib.gis.geos import Polygon, MultiPolygon diff --git a/eoxserver/resources/coverages/metadata/coverage_formats/gdal_dataset.py b/eoxserver/resources/coverages/metadata/coverage_formats/gdal_dataset.py index 4724a436c..2db623137 100644 --- a/eoxserver/resources/coverages/metadata/coverage_formats/gdal_dataset.py +++ b/eoxserver/resources/coverages/metadata/coverage_formats/gdal_dataset.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from django.contrib.gis.geos import GEOSGeometry, Polygon, MultiPolygon diff --git a/eoxserver/resources/coverages/metadata/coverage_formats/gdal_dataset_envisat.py b/eoxserver/resources/coverages/metadata/coverage_formats/gdal_dataset_envisat.py index f4cb6c8f7..4f7b62973 100644 --- a/eoxserver/resources/coverages/metadata/coverage_formats/gdal_dataset_envisat.py +++ b/eoxserver/resources/coverages/metadata/coverage_formats/gdal_dataset_envisat.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import re @@ -79,8 +79,8 @@ def read_ds(self, ds): def parse_datetime(timestamp): """ Datetime parsing function for special Envisat datetime format. """ - - + + match = re.match( r"(\d{2})-([A-Z]{3})-(\d{4}) (\d{2}):(\d{2}):(\d{2}).*", timestamp ) @@ -90,5 +90,5 @@ def parse_datetime(timestamp): hour = int(match.group(4)) minute = int(match.group(5)) second = int(match.group(6)) - + return datetime(year, month, day, hour, minute, second, tzinfo=utc) diff --git a/eoxserver/resources/coverages/metadata/coverage_formats/inspire.py b/eoxserver/resources/coverages/metadata/coverage_formats/inspire.py index df9e8c47a..248dd5557 100644 --- a/eoxserver/resources/coverages/metadata/coverage_formats/inspire.py +++ b/eoxserver/resources/coverages/metadata/coverage_formats/inspire.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from django.contrib.gis.geos import Polygon, MultiPolygon diff --git a/eoxserver/resources/coverages/metadata/coverage_formats/landsat8_l1.py b/eoxserver/resources/coverages/metadata/coverage_formats/landsat8_l1.py index 25d25a1aa..bea818ab5 100644 --- a/eoxserver/resources/coverages/metadata/coverage_formats/landsat8_l1.py +++ b/eoxserver/resources/coverages/metadata/coverage_formats/landsat8_l1.py @@ -1,4 +1,4 @@ -#------# ------------------------------------------------------------------------------ +# -----# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler diff --git a/eoxserver/resources/coverages/metadata/coverage_formats/native.py b/eoxserver/resources/coverages/metadata/coverage_formats/native.py index dd02d8b5a..6bf47f57b 100644 --- a/eoxserver/resources/coverages/metadata/coverage_formats/native.py +++ b/eoxserver/resources/coverages/metadata/coverage_formats/native.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from lxml import etree diff --git a/eoxserver/resources/coverages/metadata/coverage_formats/native_config.py b/eoxserver/resources/coverages/metadata/coverage_formats/native_config.py index 52b4391a4..3cf11c877 100644 --- a/eoxserver/resources/coverages/metadata/coverage_formats/native_config.py +++ b/eoxserver/resources/coverages/metadata/coverage_formats/native_config.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,24 +23,18 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import os.path -try: - from cStringIO import StringIO -except ImportError: - from io import StringIO -try: - from ConfigParser import RawConfigParser -except ImportError: - from configparser import RawConfigParser +from io import StringIO +from configparser import RawConfigParser from eoxserver.core.decoders import config -from django.utils.six import string_types + class NativeConfigFormatReader(object): def open_reader(self, obj): - if isinstance(obj, string_types): + if isinstance(obj, str): try: parser = RawConfigParser() if os.path.exists(obj): diff --git a/eoxserver/resources/coverages/metadata/interfaces.py b/eoxserver/resources/coverages/metadata/interfaces.py index 24413ed68..0fa8e1c31 100644 --- a/eoxserver/resources/coverages/metadata/interfaces.py +++ b/eoxserver/resources/coverages/metadata/interfaces.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class MetadataReaderInterface(object): @@ -31,14 +31,14 @@ class MetadataReaderInterface(object): """ def test(self, obj): - """ Return a boolean value, whether or not metadata can be extracted + """ Return a boolean value, whether or not metadata can be extracted from the given object. """ pass def format(self, obj): - """ Returns a format specifier for the given object. Can be ignored, + """ Returns a format specifier for the given object. Can be ignored, when the reader only supports one format. """ pass @@ -54,8 +54,8 @@ def read(self, obj): - begin_time (a python datetime.datetime) - end_time (a python datetime.datetime) - The argument obj is of an arbitrary type, the reader needs to - determine whether or not the type is supported and an exception + The argument obj is of an arbitrary type, the reader needs to + determine whether or not the type is supported and an exception shall be raised if not. """ pass @@ -91,14 +91,14 @@ class GDALDatasetMetadataReaderInterface(object): """ def test_ds(self, obj): - """ Return a boolean value, whether or not metadata can be extracted + """ Return a boolean value, whether or not metadata can be extracted from the given object. """ pass def format(self, obj): - """ Returns a format specifier for the given object. Can be ignored, + """ Returns a format specifier for the given object. Can be ignored, when the reader only supports one format. """ pass diff --git a/eoxserver/resources/coverages/metadata/product_formats/gsc.py b/eoxserver/resources/coverages/metadata/product_formats/gsc.py index a1794c37e..d50406905 100644 --- a/eoxserver/resources/coverages/metadata/product_formats/gsc.py +++ b/eoxserver/resources/coverages/metadata/product_formats/gsc.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2019 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core.util.xmltools import parse from eoxserver.core.decoders import xml, to_dict, InvalidParameterException @@ -39,12 +39,12 @@ class GSCFormatExtendedDecoder(xml.Decoder): identifier = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:metaDataProperty/gsc:EarthObservationMetaData/eop:identifier/text()", type=str, num="?") parent_identifier = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:metaDataProperty/gsc:EarthObservationMetaData/eop:parentIdentifier/text()", type=str, num="?") production_status = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:metaDataProperty/gsc:EarthObservationMetaData/eop:status/text()", type=str, num="?") - acquisition_type = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:metaDataProperty/gsc:EarthObservationMetaData/eop:acquisitionType/text()", type=str, num="?") + acquisition_type = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:metaDataProperty/gsc:EarthObservationMetaData/eop:acquisitionType/text()", type=str, num="?") orbit_number = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:using/eop:EarthObservationEquipment/eop:acquisitionParameters/opt:Acquisition/eop:orbitNumber/text()", type=int, num="?") orbit_direction = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:using/eop:EarthObservationEquipment/eop:acquisitionParameters/opt:Acquisition/eop:orbitDirection/text()", type=str, num="?") - + swath_identifier = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:using/eop:EarthObservationEquipment/eop:sensor/eop:Sensor/eop:swathIdentifier/text()", type=str, num="?") - + product_version = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:resultOf/eop:EarthObservationResult/eop:product/eop:ProductInformation/eop:version/text()", type=float, num="?") product_quality_status = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:resultOf/eop:EarthObservationMetaData/eop:productQualityStatus/text()", type=str, num="?") @@ -57,7 +57,7 @@ class GSCFormatExtendedDecoder(xml.Decoder): archiving_center = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:metaDataProperty/gsc:EarthObservationMetaData/eop:archivedIn/eop:ArchivingInformation/eop:archivingCenter/text()", type=str, num="?") processing_mode = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:metaDataProperty/gsc:EarthObservationMetaData/eop:processing/eop:ProcessingInformation/eop:processingMode/text()", type=str, num="?") # acquisition type metadata - + acquisition_station = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:metaDataProperty/gsc:EarthObservationMetaData/eop:downlinkedTo/eop:DownlinkInformation/eop:acquisitionStation/text()", type=str, num="?") acquisition_sub_type = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:metaDataProperty/gsc:EarthObservationMetaData/eop:acquisitionSubType/text()", type=str, num="?") start_time_from_ascending_node = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:using/eop:EarthObservationEquipment/eop:acquisitionParameters/eop:Acquisition/eop:startTimeFromAscendingNode/text()", type=str, num="?") @@ -78,9 +78,9 @@ class GSCFormatExtendedDecoder(xml.Decoder): # for OPT/ALT cloud_cover = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:resultOf/opt:EarthObservationResult/opt:cloudCoverPercentage/text()", type=float, num="?") snow_cover = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:resultOf/opt:EarthObservationResult/opt:snowCoverPercentage/text()", type=float, num="?") - + #TODO - # add track and frame + # add track and frame # add the following values: # availability_time = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/om:resultTime/gml:TimeInstant/ gml:timePosition/text()", type=str, num="?") # lowest_location = xml.Parameter("(gsc:sar_metadata|gsc:opt_metadata)/gml:using/lmb:Footprint/lmb:minimumAltitude/text()", type=float, num= "?") diff --git a/eoxserver/resources/coverages/metadata/product_formats/sentinel2.py b/eoxserver/resources/coverages/metadata/product_formats/sentinel2.py index f3a38455c..13a75f3c9 100644 --- a/eoxserver/resources/coverages/metadata/product_formats/sentinel2.py +++ b/eoxserver/resources/coverages/metadata/product_formats/sentinel2.py @@ -29,7 +29,6 @@ from lxml.etree import parse, fromstring from django.contrib.gis.geos import MultiPolygon, Polygon -from django.utils.six import iteritems from eoxserver.resources.coverages import crss @@ -154,7 +153,7 @@ def _read_mask(self, granule, mask_type): def parse_mask(mask_elem): - nsmap = {k: v for k, v in iteritems(mask_elem.nsmap) if k} + nsmap = {k: v for k, v in mask_elem.nsmap.items() if k} # name = mask_elem.xpath('gml:name/text()', namespaces=nsmap)[0] try: crs = mask_elem.xpath( diff --git a/eoxserver/resources/coverages/migrations/0014_rename_eoobject_begin_time_end_time_coverages_e_begin_t_3d6a5d_idx_and_more.py b/eoxserver/resources/coverages/migrations/0014_rename_eoobject_begin_time_end_time_coverages_e_begin_t_3d6a5d_idx_and_more.py new file mode 100644 index 000000000..dc5b79b6b --- /dev/null +++ b/eoxserver/resources/coverages/migrations/0014_rename_eoobject_begin_time_end_time_coverages_e_begin_t_3d6a5d_idx_and_more.py @@ -0,0 +1,178 @@ +# Generated by Django 5.2 on 2025-04-18 15:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('coverages', '0013_raster_style'), + ] + + operations = [ + migrations.RenameIndex( + model_name='eoobject', + new_name='coverages_e_begin_t_3d6a5d_idx', + old_fields=('begin_time', 'end_time'), + ), + migrations.AlterField( + model_name='acquisitionstation', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='acquisitionsubtype', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='allowedvaluerange', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='archivingcenter', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='arraydataitem', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='bandstatistics', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='browse', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='browsetype', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='collectionmetadata', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='collectiontype', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='coveragemetadata', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='coveragetype', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='eoobject', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='fieldtype', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='frame', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='grid', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='mask', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='masktype', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='metadataitem', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='nilvalue', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='orbitnumber', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='processingcenter', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='processingmode', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='processorname', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='productdataitem', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='productmetadata', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='productqualitydegredationtag', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='producttype', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='productversion', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='sensormode', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='swathidentifier', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='track', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + ] diff --git a/eoxserver/resources/coverages/migrations/0015_alter_bandstatistics_histogram.py b/eoxserver/resources/coverages/migrations/0015_alter_bandstatistics_histogram.py new file mode 100644 index 000000000..8d6b4caac --- /dev/null +++ b/eoxserver/resources/coverages/migrations/0015_alter_bandstatistics_histogram.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2 on 2025-04-18 15:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('coverages', '0014_rename_eoobject_begin_time_end_time_coverages_e_begin_t_3d6a5d_idx_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='bandstatistics', + name='histogram', + field=models.JSONField(blank=True, null=True), + ), + ] diff --git a/eoxserver/resources/coverages/models.py b/eoxserver/resources/coverages/models.py index 5f9fdd073..2b61f7e66 100644 --- a/eoxserver/resources/coverages/models.py +++ b/eoxserver/resources/coverages/models.py @@ -43,7 +43,6 @@ from django.db.models.functions import Cast from django.utils.timezone import now from model_utils.managers import InheritanceManager -from jsonfield import JSONField from eoxserver.backends import models as backends from eoxserver.core.util.timetools import isoformat @@ -380,7 +379,7 @@ def __str__(self): return self.identifier class Meta: - index_together = [['begin_time', 'end_time']] + indexes = [models.Index(fields=['begin_time', 'end_time'])] class Collection(EOObject): @@ -540,7 +539,7 @@ class BandStatistics(models.Model): maximum = models.FloatField(**optional) stddev = models.FloatField(**optional) valid_percent = models.FloatField(**optional) - histogram = JSONField(**optional) + histogram = models.JSONField(**optional) class Meta: unique_together = [('arraydata_item', 'band_index')] diff --git a/eoxserver/resources/coverages/registration/base.py b/eoxserver/resources/coverages/registration/base.py index 651010106..78372c3aa 100644 --- a/eoxserver/resources/coverages/registration/base.py +++ b/eoxserver/resources/coverages/registration/base.py @@ -30,7 +30,6 @@ from django.db.models import ForeignKey from django.contrib.gis.geos import Polygon from django.contrib.gis.gdal import SpatialReference, CoordTransform -from django.utils.six import string_types from eoxserver.backends.access import vsi_open from eoxserver.backends.util import resolve_storage @@ -427,7 +426,7 @@ def get_grid(definition): """ Get or create a grid according to our defintion """ grid = None - if isinstance(definition, string_types): + if isinstance(definition, str): try: grid = models.Grid.objects.get(name=definition) except models.Grid.DoesNotExist: diff --git a/eoxserver/resources/coverages/registration/component.py b/eoxserver/resources/coverages/registration/component.py index fd581371c..b3bca9492 100644 --- a/eoxserver/resources/coverages/registration/component.py +++ b/eoxserver/resources/coverages/registration/component.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, ExtensionPoint from eoxserver.resources.coverages.registration.interfaces import ( diff --git a/eoxserver/resources/coverages/registration/exceptions.py b/eoxserver/resources/coverages/registration/exceptions.py index f6ad33236..b26ca3b36 100644 --- a/eoxserver/resources/coverages/registration/exceptions.py +++ b/eoxserver/resources/coverages/registration/exceptions.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class RegistrationError(Exception): diff --git a/eoxserver/resources/coverages/registration/interfaces.py b/eoxserver/resources/coverages/registration/interfaces.py index 661c4d4b4..f1668713c 100644 --- a/eoxserver/resources/coverages/registration/interfaces.py +++ b/eoxserver/resources/coverages/registration/interfaces.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class RegistratorInterface(object): diff --git a/eoxserver/resources/coverages/registration/registrators/gdal.py b/eoxserver/resources/coverages/registration/registrators/gdal.py index 52258b0cd..221d37815 100644 --- a/eoxserver/resources/coverages/registration/registrators/gdal.py +++ b/eoxserver/resources/coverages/registration/registrators/gdal.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.backends.access import gdal_open from eoxserver.resources.coverages.metadata.coverage_formats import ( diff --git a/eoxserver/resources/coverages/synchronization.py b/eoxserver/resources/coverages/synchronization.py index 0d5505d8a..00bfea189 100644 --- a/eoxserver/resources/coverages/synchronization.py +++ b/eoxserver/resources/coverages/synchronization.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ This module provides functionality to synchronize the database models in one @@ -43,7 +43,6 @@ from eoxserver.resources.coverages.registration.component import ( RegistratorComponent ) -from django.utils.six import string_types logger = logging.getLogger(__name__) @@ -79,7 +78,7 @@ def synchronize(collection, recursive=False, force=False): """ # allow both model and identifier - if isinstance(collection, string_types): + if isinstance(collection, str): collection = models.Collection.objects.get(identifier=collection) collection = collection.cast() diff --git a/eoxserver/resources/coverages/tests.py b/eoxserver/resources/coverages/tests.py index 6b6a2be54..89be473a5 100644 --- a/eoxserver/resources/coverages/tests.py +++ b/eoxserver/resources/coverages/tests.py @@ -28,12 +28,9 @@ # ------------------------------------------------------------------------------- import sys -from datetime import datetime +from datetime import datetime, timezone -try: - from StringIO import StringIO -except ImportError: - from io import StringIO +from io import StringIO from textwrap import dedent from unittest import skipIf @@ -41,7 +38,6 @@ from django.test import TestCase from django.contrib.gis.geos import GEOSGeometry, Polygon, MultiPolygon from django.utils.dateparse import parse_datetime -from django.utils.timezone import utc from eoxserver.core import env from eoxserver.resources.coverages import models @@ -51,6 +47,8 @@ eoom, ) +utc = timezone.utc + def create(Class, **kwargs): obj = Class(**kwargs) diff --git a/eoxserver/resources/coverages/util.py b/eoxserver/resources/coverages/util.py index 6b50981d3..d7a7b9659 100644 --- a/eoxserver/resources/coverages/util.py +++ b/eoxserver/resources/coverages/util.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Stephan Meissl # Stephan Krause # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import operator @@ -35,7 +35,6 @@ from django.contrib.gis.geos import MultiPolygon, Polygon from django.utils.timezone import is_naive, make_aware, get_current_timezone from django.utils.dateparse import parse_datetime -from django.utils.six import string_types from eoxserver.contrib import gdal @@ -76,10 +75,10 @@ def collect_eo_metadata(qs, insert=None, exclude=None, bbox=False): ) # workaround for Django 1.4 bug: aggregate times are strings - if isinstance(begin_time, string_types): + if isinstance(begin_time, str): begin_time = parse_datetime(begin_time) - if isinstance(end_time, string_types): + if isinstance(end_time, str): end_time = parse_datetime(end_time) if begin_time and is_naive(begin_time): diff --git a/eoxserver/scripts/eoxserver-instance.py b/eoxserver/scripts/eoxserver-instance.py index 8545a3d74..2d50aaddb 100755 --- a/eoxserver/scripts/eoxserver-instance.py +++ b/eoxserver/scripts/eoxserver-instance.py @@ -1,10 +1,10 @@ #!/usr/bin/python3 -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2016 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ diff --git a/eoxserver/services/auth/base.py b/eoxserver/services/auth/base.py index 3347d519a..a833b98a8 100644 --- a/eoxserver/services/auth/base.py +++ b/eoxserver/services/auth/base.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """ This module contains basic classes and functions for the security layer (which @@ -44,9 +44,9 @@ logger = logging.getLogger(__name__) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Config reader -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class AuthConfigReader(config.Reader): section = "services.auth.base" @@ -59,9 +59,9 @@ class AuthConfigReader(config.Reader): pdp_type = config.Option() -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # PDP Base Class -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class BasePDP(object): """ @@ -108,9 +108,9 @@ def _decide(self, request): return (True, "") -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # utility functions -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class PDPComponent(Component): pdps = ExtensionPoint(PolicyDecisionPointInterface) diff --git a/eoxserver/services/auth/charonpdp.py b/eoxserver/services/auth/charonpdp.py index 543539bd7..04668e359 100644 --- a/eoxserver/services/auth/charonpdp.py +++ b/eoxserver/services/auth/charonpdp.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import logging import os @@ -34,14 +34,12 @@ import eoxserver from urllib.parse import urlparse -from django.utils.six import iteritems - from eoxserver.core import implements from eoxserver.core.config import get_eoxserver_config from eoxserver.services.ows.decoders import get_decoder from eoxserver.services.auth.base import BasePDP, AuthConfigReader from eoxserver.services.auth.interfaces import PolicyDecisionPointInterface - + logger = logging.getLogger(__name__) @@ -77,9 +75,9 @@ "{2}" -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # PDP implementation for the CHARON Authorization Service -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class CharonPDP(BasePDP): implements(PolicyDecisionPointInterface) @@ -121,7 +119,7 @@ def __init__(self, client=None): value = value.strip() self.attribMapping[key] = value logger.debug( - "Adding SAML attribute to dictionary: %s = %s" + "Adding SAML attribute to dictionary: %s = %s" % (key, value) ) except IOError : @@ -139,7 +137,7 @@ def _getAssertedAttributes(self, request): # adding the REMOTE_ADDR from HTTP header to subject attributes attributes['REMOTE_ADDR'] = httpHeader['REMOTE_ADDR'] - for key, value in iteritems(self.attribMapping): + for key, value in self.attribMapping.items(): if key in httpHeader: attributes[key] = httpHeader[value] logger.debug( @@ -183,9 +181,9 @@ def _decide(self, request): ) return result -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # SOAP client for the CHARON Policy Management and Authorization Service -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class AuthorisationClient(object): """ @@ -306,9 +304,9 @@ def _getFullRequest(self, userAttributes, resourceAttributes, action): self._getPartEnvironment()) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # AuthorisationClientException -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class AuthorisationClientException(Exception): """ Exception that is thrown by the AuthorisationClient in case of an error diff --git a/eoxserver/services/auth/dummypdp.py b/eoxserver/services/auth/dummypdp.py index f5ac34ce9..018ed3bda 100644 --- a/eoxserver/services/auth/dummypdp.py +++ b/eoxserver/services/auth/dummypdp.py @@ -3,11 +3,10 @@ import datetime import httplib import xml.dom.minidom -import eoxserver -from urlparse import urlparse -from django.utils.six import iteritems +from urllib.parse import urlparse +import eoxserver from eoxserver.core import implements from eoxserver.services.auth.base import BasePDP from eoxserver.services.auth.interfaces import PolicyDecisionPointInterface @@ -17,9 +16,9 @@ logger = logging.getLogger(__name__) validUser = { - 'uid': 'jdoe', - 'cn': 'Doe John', - 'sn': 'Doe', + 'uid': 'jdoe', + 'cn': 'Doe John', + 'sn': 'Doe', 'description': 'Authorized User' } @@ -42,7 +41,7 @@ def _decide(self, request): class DummyAuthzClient(object): def authorize(self, userAttributes, resourceAttributes, action): - for key, value in iteritems(validUser): + for key, value in validUser.items(): if key in userAttributes: if value != userAttributes[key]: return (False, 'Not Authorised') diff --git a/eoxserver/services/auth/exceptions.py b/eoxserver/services/auth/exceptions.py index 32560a9b1..03a8d1145 100644 --- a/eoxserver/services/auth/exceptions.py +++ b/eoxserver/services/auth/exceptions.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class AuthorisationException(Exception): diff --git a/eoxserver/services/auth/middleware.py b/eoxserver/services/auth/middleware.py index fd25e1e86..aa0384ea3 100644 --- a/eoxserver/services/auth/middleware.py +++ b/eoxserver/services/auth/middleware.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import functools diff --git a/eoxserver/services/exceptions.py b/eoxserver/services/exceptions.py index c2b4dca95..649bee9c5 100644 --- a/eoxserver/services/exceptions.py +++ b/eoxserver/services/exceptions.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class HTTPMethodNotAllowedError(Exception): diff --git a/eoxserver/services/filters.py b/eoxserver/services/filters.py index d16f2870c..259fc6db4 100644 --- a/eoxserver/services/filters.py +++ b/eoxserver/services/filters.py @@ -26,17 +26,9 @@ # ------------------------------------------------------------------------------ -try: - from operator import and_, or_, add, sub, mul, div -except ImportError: - from operator import and_, or_, add, sub, mul, truediv as div +from operator import and_, or_, add, sub, mul, truediv as div from datetime import datetime, timedelta - -try: - from collections import OrderedDict -except ImportError: - from django.utils.datastructures import SortedDict as OrderedDict -from django.utils.six import string_types +from collections import OrderedDict from django.db.models import Q, F, ForeignKey, Value from django.db.models.expressions import Expression @@ -126,7 +118,7 @@ def compare(lhs, rhs, op, mapping_choices=None): if mapping_choices and field_name in mapping_choices: try: - if isinstance(rhs, string_types): + if isinstance(rhs, str): rhs = mapping_choices[field_name][rhs] elif hasattr(rhs, 'value'): rhs = Value(mapping_choices[field_name][rhs.value]) @@ -179,7 +171,7 @@ def like(lhs, rhs, case=False, not_=False, mapping_choices=None): """ assert isinstance(lhs, F) - if isinstance(rhs, string_types): + if isinstance(rhs, str): pattern = rhs elif hasattr(rhs, 'value'): pattern = rhs.value @@ -270,7 +262,7 @@ def contains(lhs, items, not_=False, mapping_choices=None): if mapping_choices and lhs.name in mapping_choices: def map_value(item): try: - if isinstance(item, string_types): + if isinstance(item, str): item = mapping_choices[lhs.name][item] elif hasattr(item, 'value'): item = Value(mapping_choices[lhs.name][item.value]) diff --git a/eoxserver/services/gdal/wcs/referenceable_dataset_renderer.py b/eoxserver/services/gdal/wcs/referenceable_dataset_renderer.py index ba4ff4ed9..508148694 100644 --- a/eoxserver/services/gdal/wcs/referenceable_dataset_renderer.py +++ b/eoxserver/services/gdal/wcs/referenceable_dataset_renderer.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from os.path import abspath diff --git a/eoxserver/services/gml/v32/encoders.py b/eoxserver/services/gml/v32/encoders.py index 8bec1ad6f..b406b6568 100644 --- a/eoxserver/services/gml/v32/encoders.py +++ b/eoxserver/services/gml/v32/encoders.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from lxml.builder import ElementMaker diff --git a/eoxserver/services/management/commands/wms_options_list.py b/eoxserver/services/management/commands/wms_options_list.py index 8441c440a..6f4e548a6 100644 --- a/eoxserver/services/management/commands/wms_options_list.py +++ b/eoxserver/services/management/commands/wms_options_list.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2016 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,30 +23,27 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # pylint: disable=missing-docstring from sys import stdout import json from optparse import make_option -try: - # available in Python 2.7+ - from collections import OrderedDict -except ImportError: - from django.utils.datastructures import SortedDict as OrderedDict -from django.utils.six import string_types +from collections import OrderedDict + from django.core.management.base import BaseCommand, CommandError from eoxserver.resources.coverages.management.commands import CommandOutputMixIn from eoxserver.services.models import WMSRenderOptions + JSON_OPTIONS = { "indent": None, "separators": (', ', ': '), "sort_keys": False, } -class Command(CommandOutputMixIn, BaseCommand): +class Command(CommandOutputMixIn, BaseCommand): option_list = BaseCommand.option_list + ( make_option( '--json', dest='json_dump', action='store_true', default=False, @@ -107,7 +104,7 @@ def output_detailed(wms_opts): for wms_opt in wms_opts: yield "%s\n" % wms_opt.coverage.identifier for key, val in wms_opt_to_dict(wms_opt).items(): - if hasattr(val, '__len__') and not isinstance(val, string_types): + if hasattr(val, '__len__') and not isinstance(val, str): val = ",".join(str(v) for v in val) if key == "coverage_identifier": continue diff --git a/eoxserver/services/management/commands/wms_options_load.py b/eoxserver/services/management/commands/wms_options_load.py index c480c0eec..7521ebeb2 100644 --- a/eoxserver/services/management/commands/wms_options_load.py +++ b/eoxserver/services/management/commands/wms_options_load.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2016 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # pylint: disable=missing-docstring from sys import stdin @@ -31,7 +31,6 @@ import json from optparse import make_option from django.core.management.base import BaseCommand, CommandError -from django.utils.six import string_types from eoxserver.resources.coverages.management.commands import ( CommandOutputMixIn, nested_commit_on_success, ) @@ -147,7 +146,7 @@ def set_from_dict(wms_opt_obj, options): def _scales(scales): if scales is None: return None - if isinstance(scales, string_types): + if isinstance(scales, str): scales = scales.split(',') return ",".join(str(int(round(float(v)))) for v in scales) diff --git a/eoxserver/services/management/commands/wms_options_set.py b/eoxserver/services/management/commands/wms_options_set.py index b4c12bdf8..bbe7bf882 100644 --- a/eoxserver/services/management/commands/wms_options_set.py +++ b/eoxserver/services/management/commands/wms_options_set.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2016 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # pylint: disable=missing-docstring from optparse import make_option @@ -100,7 +100,7 @@ class Command(CommandOutputMixIn, BaseCommand): help = """ Set WMS options for a coverage. - + NOTE: Band indices are counted from 1. """ diff --git a/eoxserver/services/mapserver/connectors/multifile_connector.py b/eoxserver/services/mapserver/connectors/multifile_connector.py index e35959e71..8ac5034d7 100644 --- a/eoxserver/services/mapserver/connectors/multifile_connector.py +++ b/eoxserver/services/mapserver/connectors/multifile_connector.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from os.path import join from uuid import uuid4 @@ -70,7 +70,7 @@ def connect(self, coverage, data_items, layer, options): # if coverage.grid.is_referenceable: # vrt_builder.copy_gcps(gdal.OpenShared(data_items[0].path)) - # layer.setMetaData("eoxs_ref_data", path) + # layer.metadata.set("eoxs_ref_data", path) # layer.data = path @@ -95,10 +95,10 @@ def connect(self, coverage, data_items, layer, options): vrt_path = join("/vsimem", uuid4().hex) reftools.create_rectified_vrt(path, vrt_path) layer.data = vrt_path - layer.setMetaData("eoxs_ref_data", path) + layer.metadata.set("eoxs_ref_data", path) with vsi.open(vrt_path) as f: - print (f.read(100000)) + print(f.read(100000)) """ # TODO!! diff --git a/eoxserver/services/mapserver/connectors/polygonmask_connector.py b/eoxserver/services/mapserver/connectors/polygonmask_connector.py index c0259d391..9036641db 100644 --- a/eoxserver/services/mapserver/connectors/polygonmask_connector.py +++ b/eoxserver/services/mapserver/connectors/polygonmask_connector.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.contrib import ogr from eoxserver.contrib import mapserver as ms @@ -91,8 +91,8 @@ def connect(self, coverage, data_items, layer, options): # TODO: more than one mask_item? layer.setProjection("EPSG:4326") - layer.setMetaData("ows_srs", "EPSG:4326") - layer.setMetaData("wms_srs", "EPSG:4326") + layer.metadata.set("ows_srs", "EPSG:4326") + layer.metadata.set("wms_srs", "EPSG:4326") def disconnect(self, coverage, data_items, layer, options): pass diff --git a/eoxserver/services/mapserver/connectors/simple_connector.py b/eoxserver/services/mapserver/connectors/simple_connector.py index b07ee2fe0..1094c0fd8 100644 --- a/eoxserver/services/mapserver/connectors/simple_connector.py +++ b/eoxserver/services/mapserver/connectors/simple_connector.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from os.path import join from uuid import uuid4 @@ -49,7 +49,7 @@ def connect(self, coverage, data_items, layer, options): vrt_path = join("/vsimem", uuid4().hex) reftools.create_rectified_vrt(data, vrt_path) data = vrt_path - layer.setMetaData("eoxs_ref_data", data) + layer.metadata.set("eoxs_ref_data", data) if not layer.metadata.get("eoxs_wrap_dateline") == "true": layer.data = data diff --git a/eoxserver/services/mapserver/connectors/tileindex_connector.py b/eoxserver/services/mapserver/connectors/tileindex_connector.py index d1ea02d6a..a7357eb0b 100644 --- a/eoxserver/services/mapserver/connectors/tileindex_connector.py +++ b/eoxserver/services/mapserver/connectors/tileindex_connector.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.backends.access import get_vsi_path diff --git a/eoxserver/services/mapserver/interfaces.py b/eoxserver/services/mapserver/interfaces.py index c7b3ea169..3a8ed7c32 100644 --- a/eoxserver/services/mapserver/interfaces.py +++ b/eoxserver/services/mapserver/interfaces.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class ConnectorInterface(object): diff --git a/eoxserver/services/mapserver/wcs/base_renderer.py b/eoxserver/services/mapserver/wcs/base_renderer.py index 01c9bfb79..802f2c751 100644 --- a/eoxserver/services/mapserver/wcs/base_renderer.py +++ b/eoxserver/services/mapserver/wcs/base_renderer.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from django.db.models import Q @@ -55,12 +55,12 @@ def create_map(self): """ Helper function to create a WCS enabled MapServer mapObj. """ map_ = ms.mapObj() - map_.setMetaData("ows_enable_request", "*") - map_.setMetaData("ows_onlineresource", "*") + map_.web.metadata.set("ows_enable_request", "*") + map_.web.metadata.set("ows_onlineresource", "*") maxsize = WCSConfigReader(get_eoxserver_config()).maxsize if maxsize is not None: map_.maxsize = maxsize - map_.setMetaData("ows_updateSequence", + map_.web.metadata.set("ows_updateSequence", WCSConfigReader(get_eoxserver_config()).update_sequence ) return map_ @@ -103,7 +103,7 @@ def layer_for_coverage(self, coverage, native_format, version=None): layer.setExtent(*extent) - ms.setMetaData(layer, { + ms.set_metadata(layer.metadata, { "title": coverage_identifier, "enable_request": "*" }, namespace="ows") @@ -120,7 +120,7 @@ def layer_for_coverage(self, coverage, native_format, version=None): else: significant_figures = gdal.GDT_SIGNIFICANT_FIGURES[data_type] - ms.setMetaData(layer, { + ms.set_metadata(layer.metadata, { "label": coverage_identifier, "extent": "%.10g %.10g %.10g %.10g" % extent, "resolution": "%.10g %.10g" % resolution, @@ -138,11 +138,11 @@ def layer_for_coverage(self, coverage, native_format, version=None): }, namespace="wcs") if version is None or version.startswith("2.0"): - ms.setMetaData(layer, { + ms.set_metadata(layer.metadata, { "band_names": " ".join([band.identifier for band in bands]), }, namespace="wcs") else: - ms.setMetaData(layer, { + ms.set_metadata(layer.metadata, { "rangeset_axes": ",".join(band.identifier for band in bands), }, namespace="wcs") @@ -152,7 +152,7 @@ def layer_for_coverage(self, coverage, native_format, version=None): x.wcs10name for x in self.get_wcs_formats() if x.mimeType == native_format), native_format ) - ms.setMetaData(layer, { + ms.set_metadata(layer.metadata, { "native_format": native_format, "nativeformat": native_format }, namespace="wcs") @@ -166,11 +166,11 @@ def layer_for_coverage(self, coverage, native_format, version=None): all_crss.insert(0, native_crs) supported_crss = " ".join(all_crss) - layer.setMetaData("ows_srs", supported_crss) - layer.setMetaData("wcs_srs", supported_crss) + layer.metadata.set("ows_srs", supported_crss) + layer.metadata.set("wcs_srs", supported_crss) for band in bands: - ms.setMetaData(layer, { + ms.set_metadata(layer.metadata, { "band_description": band.description or '', "band_definition": band.definition or '', "band_uom": band.unit_of_measure or '', @@ -182,7 +182,7 @@ def layer_for_coverage(self, coverage, native_format, version=None): interval = gdal.GDT_NUMERIC_LIMITS[band.data_type] # For MS WCS 1.x interface - ms.setMetaData(layer, { + ms.set_metadata(layer.metadata, { "label": band.identifier, "interval": "%d %d" % interval }, namespace="wcs_%s" % band.identifier) @@ -192,7 +192,7 @@ def layer_for_coverage(self, coverage, native_format, version=None): [nv[0], nv[1]] for nv in bands[0].nil_values] ) if nilvalues: - ms.setMetaData(layer, { + ms.set_metadata(layer.metadata, { "nilvalues": " ".join(nilvalues), "nilvalues_reasons": " ".join(nilvalues_reasons) }, namespace="wcs") diff --git a/eoxserver/services/mapserver/wcs/capabilities_renderer.py b/eoxserver/services/mapserver/wcs/capabilities_renderer.py index 4af87e8ff..cc903fd42 100644 --- a/eoxserver/services/mapserver/wcs/capabilities_renderer.py +++ b/eoxserver/services/mapserver/wcs/capabilities_renderer.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,30 +23,24 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from lxml import etree -from eoxserver.core import Component, implements from eoxserver.core.config import get_eoxserver_config -from eoxserver.core.util.timetools import isoformat -from eoxserver.contrib.mapserver import create_request, Map, Layer +from eoxserver.contrib.mapserver import create_request, Map, Layer, set_metadata from eoxserver.resources.coverages import crss from eoxserver.render.coverage.objects import Coverage from eoxserver.services.mapserver.wcs.base_renderer import BaseRenderer from eoxserver.services.ows.common.config import CapabilitiesConfigReader -from eoxserver.services.ows.wcs.interfaces import ( - WCSCapabilitiesRendererInterface -) from eoxserver.services.ows.version import Version -from eoxserver.services.result import result_set_from_raw_data, get_content_type, ResultBuffer +from eoxserver.services.result import result_set_from_raw_data, ResultBuffer from eoxserver.services.urls import get_http_service_url class MapServerWCSCapabilitiesRenderer(BaseRenderer): """ WCS Capabilities renderer implementation using MapServer. """ - implements(WCSCapabilitiesRendererInterface) versions = (Version(1, 0), Version(1, 1)) @@ -59,7 +53,7 @@ def render(self, params): http_service_url = get_http_service_url(params.http_request) map_ = Map() - map_.setMetaData({ + set_metadata(map_.web.metadata, { "enable_request": "*", "onlineresource": http_service_url, "service_onlineresource": conf.onlineresource, @@ -105,7 +99,7 @@ def render(self, params): (extent[1] - extent[3]) / float(size[1])) layer.setExtent(*extent) - layer.setMetaData({ + set_metadata(layer.metadata, { "title": coverage.identifier, "label": coverage.identifier, "extent": "%.10g %.10g %.10g %.10g" % extent, diff --git a/eoxserver/services/mapserver/wcs/coverage_description_renderer.py b/eoxserver/services/mapserver/wcs/coverage_description_renderer.py index c245b2d8b..22867c993 100644 --- a/eoxserver/services/mapserver/wcs/coverage_description_renderer.py +++ b/eoxserver/services/mapserver/wcs/coverage_description_renderer.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from lxml import etree from eoxserver.contrib import mapserver as ms @@ -72,7 +72,7 @@ def render(self, params): request = ms.create_request(params) raw_result = ms.dispatch(map_, request) - + result = result_set_from_raw_data(raw_result) # load XML using lxml # find and exclude nodes if present @@ -84,7 +84,7 @@ def render(self, params): elem.getparent().remove(elem) xml_result_data = etree.tostring(xml_result, pretty_print=True, encoding='UTF-8', xml_declaration=True) - + result[0] = ResultBuffer(xml_result_data, result[0].content_type) - + return result diff --git a/eoxserver/services/mapserver/wcs/coverage_renderer.py b/eoxserver/services/mapserver/wcs/coverage_renderer.py index 6752aa30f..72669c854 100644 --- a/eoxserver/services/mapserver/wcs/coverage_renderer.py +++ b/eoxserver/services/mapserver/wcs/coverage_renderer.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,13 +23,12 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import logging from datetime import datetime -from django.utils.six.moves.urllib.parse import unquote -from django.utils.six import binary_type, b +from urllib.parse import unquote from lxml import etree from eoxserver.contrib import mapserver as ms @@ -197,7 +196,7 @@ def render(self, params): coverage._origin = origin coverage._size = size coverage._range_type = range_type - if isinstance(result_set[1].filename, binary_type): + if isinstance(result_set[1].filename, bytes): file_name = result_set[1].filename.decode() else: file_name = result_set[1].filename diff --git a/eoxserver/services/mapserver/wms/capabilities_renderer.py b/eoxserver/services/mapserver/wms/capabilities_renderer.py index b845e8fd6..a5e32e058 100644 --- a/eoxserver/services/mapserver/wms/capabilities_renderer.py +++ b/eoxserver/services/mapserver/wms/capabilities_renderer.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,15 +23,17 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from itertools import chain from eoxserver.core import Component, implements, ExtensionPoint from eoxserver.core.config import get_eoxserver_config from eoxserver.core.util.timetools import isoformat -from eoxserver.contrib.mapserver import create_request, Map, Layer, Class, Style -from eoxserver.resources.coverages import crss, models +from eoxserver.contrib.mapserver import ( + create_request, Map, Layer, Class, Style, set_metadata +) +from eoxserver.resources.coverages import crss from eoxserver.resources.coverages.formats import getFormatRegistry from eoxserver.services.ows.common.config import CapabilitiesConfigReader from eoxserver.services.ows.wms.interfaces import ( @@ -63,7 +65,7 @@ def render(self, collections, coverages, request_values, request): http_service_url = get_http_service_url(request) map_ = Map() - map_.setMetaData({ + set_metadata(map_.web.metadata, { "enable_request": "*", "onlineresource": http_service_url, "service_onlineresource": conf.onlineresource, @@ -89,7 +91,7 @@ def render(self, collections, coverages, request_values, request): "srs": " ".join(crss.getSupportedCRS_WCS(format_function=crss.asShortCode)), }, namespace="ows") map_.setProjection("EPSG:4326") - map_.setMetaData({ + set_metadata(map_.web.metadata, { "getmap_formatlist": ",".join([f.mimeType for f in self.get_wms_formats()]), "getfeatureinfo_formatlist": "text/html,application/vnd.ogc.gml,text/plain", }, namespace="wms") @@ -98,7 +100,7 @@ def render(self, collections, coverages, request_values, request): for collection in collections: group_name = None - + # calculate extent and timextent for every collection extent = collection.extent_wgs84 # save overall map extent @@ -118,11 +120,11 @@ def render(self, collections, coverages, request_values, request): ) if len(suffixes) > 1: - # create group layer, if there is more than one suffix for this + # create group layer, if there is more than one suffix for this # collection group_name = collection.identifier + "_group" group_layer = Layer(group_name) - group_layer.setMetaData({ + set_metadata(group_layer.metadata, { "title": group_name, "abstract": group_name, "extent": " ".join(map(str, extent)), @@ -133,7 +135,7 @@ def render(self, collections, coverages, request_values, request): # add default style default_class = Class("default") - default_style= Style("default") + default_style = Style("default") default_class.insertStyle(default_style) group_layer.insertClass(default_class) @@ -143,11 +145,11 @@ def render(self, collections, coverages, request_values, request): layer_name = collection.identifier + (suffix or "") layer = Layer(layer_name) if group_name: - layer.setMetaData({ + set_metadata(layer.metadata, { "layer_group": "/" + group_name }, namespace="wms") - layer.setMetaData({ + set_metadata(layer.metadata, { "title": layer_name, "abstract": layer_name, "extent": " ".join(map(str, extent)), @@ -163,7 +165,7 @@ def render(self, collections, coverages, request_values, request): layer_name = coverage.identifier layer = Layer(layer_name) - layer.setMetaData({ + set_metadata(layer.metadata, { "title": layer_name, "abstract": layer_name, "extent": " ".join(map(str, extent)), @@ -175,8 +177,8 @@ def render(self, collections, coverages, request_values, request): # set the map_extent to a reasonable default value # in case there is no coverage or collection - if map_extent is None : - map_extent = ( 0.0, 0.0, 1.0, 1.0 ) + if map_extent is None : + map_extent = (0.0, 0.0, 1.0, 1.0) map_minx, map_miny, map_maxx, map_maxy = map_extent map_.setExtent(map_minx, map_miny, map_maxx, map_maxy) @@ -194,9 +196,9 @@ def join_extents(self, e1=None, e2=None): e1_minx, e1_miny, e1_maxx, e1_maxy = e1 e2_minx, e2_miny, e2_maxx, e2_maxy = e2 return ( - min(e1_minx, e2_minx), - min(e1_miny, e2_miny), - max(e1_maxx, e2_maxx), + min(e1_minx, e2_minx), + min(e1_miny, e2_miny), + max(e1_maxx, e2_maxx), max(e1_maxy, e2_maxy) ) elif e1: diff --git a/eoxserver/services/mapserver/wms/feature_info_renderer.py b/eoxserver/services/mapserver/wms/feature_info_renderer.py index 997873d59..f7cc46cc6 100644 --- a/eoxserver/services/mapserver/wms/feature_info_renderer.py +++ b/eoxserver/services/mapserver/wms/feature_info_renderer.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import implements @@ -42,22 +42,22 @@ ) from eoxserver.services.urls import get_http_service_url + class MapServerWMSFeatureInfoRenderer(MapServerWMSBaseComponent): """ A WMS feature info renderer using MapServer. """ implements(WMSFeatureInfoRendererInterface) - def render(self, layer_groups, request_values, request, **options): config = CapabilitiesConfigReader(get_eoxserver_config()) http_service_url = get_http_service_url(request) map_ = ms.Map() - map_.setMetaData({ + ms.set_metadata(map_.web.metadata, { "enable_request": "*", "onlineresource": http_service_url, }, namespace="ows") - map_.setMetaData("wms_getfeatureinfo_formatlist", "text/html") + map_.web.metadata.set("wms_getfeatureinfo_formatlist", "text/html") map_.setProjection("EPSG:4326") session = self.setup_map(layer_groups, map_, options) @@ -70,7 +70,7 @@ def render(self, layer_groups, request_values, request, **options): use_eoom = True else: request_values.append(("info_format", frmt)) - + with session: request = ms.create_request(request_values) raw_result = map_.dispatch(request) @@ -94,7 +94,7 @@ def render(self, layer_groups, request_values, request, **options): lookup_table[identifier] for identifier in identifiers ] - # encode the coverages with the EO O&M + # encode the coverages with the EO O&M encoder = WCS20EOXMLEncoder() return [ diff --git a/eoxserver/services/mapserver/wms/layerfactories/base.py b/eoxserver/services/mapserver/wms/layerfactories/base.py index 7d085359f..2fe7c1ccf 100644 --- a/eoxserver/services/mapserver/wms/layerfactories/base.py +++ b/eoxserver/services/mapserver/wms/layerfactories/base.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011-2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import os.path @@ -42,7 +42,7 @@ extent_crosses_dateline, wrap_extent_around_dateline ) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class BaseStyleMixIn(object): @@ -123,8 +123,8 @@ def _create_polygon_layer(self, name): srid = 4326 layer.setProjection(crss.asProj4Str(srid)) - layer.setMetaData("ows_srs", crss.asShortCode(srid)) - layer.setMetaData("wms_srs", crss.asShortCode(srid)) + layer.metadata.set("ows_srs", crss.asShortCode(srid)) + layer.metadata.set("wms_srs", crss.asShortCode(srid)) layer.dump = True @@ -132,8 +132,8 @@ def _create_polygon_layer(self, name): layer.template = os.path.join(settings.PROJECT_DIR, "conf", "outline_template_dataset.html") layer.footer = os.path.join(settings.PROJECT_DIR, "conf", "outline_template_footer.html") - layer.setMetaData("gml_include_items", "all") - layer.setMetaData("wms_include_items", "all") + layer.metadata.set("gml_include_items", "all") + layer.metadata.set("wms_include_items", "all") layer.addProcessing("ITEMS=identifier") @@ -150,17 +150,17 @@ def _create_layer(self, coverage, name, extent=None, group=None, layer.name = name layer.type = ms.MS_LAYER_RASTER if extent: - layer.setMetaData("wms_extent", "%f %f %f %f" % extent) + layer.metadata.set("wms_extent", "%f %f %f %f" % extent) layer.setExtent(*extent) - #layer.setMetaData( + #layer.metadata.set( # "wms_enable_request", "getcapabilities getmap getfeatureinfo" #) if wrapped: # set the info for the connector to wrap this layer around the # dateline - layer.setMetaData("eoxs_wrap_dateline", "true") + layer.metadata.set("eoxs_wrap_dateline", "true") self._set_projection(layer, coverage.spatial_reference) if group: @@ -232,8 +232,8 @@ def set_render_options(self, layer, offsite=None, options=None): def _set_projection(self, layer, sr): if sr.srid is not None: short_epsg = "EPSG:%d" % sr.srid - layer.setMetaData("ows_srs", short_epsg) - layer.setMetaData("wms_srs", short_epsg) + layer.metadata.set("ows_srs", short_epsg) + layer.metadata.set("wms_srs", short_epsg) layer.setProjection(sr.proj) diff --git a/eoxserver/services/mapserver/wms/layerfactories/colorized_mask_layer_factory.py b/eoxserver/services/mapserver/wms/layerfactories/colorized_mask_layer_factory.py index d8a951fc9..5227e0a98 100644 --- a/eoxserver/services/mapserver/wms/layerfactories/colorized_mask_layer_factory.py +++ b/eoxserver/services/mapserver/wms/layerfactories/colorized_mask_layer_factory.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import logging diff --git a/eoxserver/services/mapserver/wms/layerfactories/coverage_bands_layer_factory.py b/eoxserver/services/mapserver/wms/layerfactories/coverage_bands_layer_factory.py index ed683c772..45a50f301 100644 --- a/eoxserver/services/mapserver/wms/layerfactories/coverage_bands_layer_factory.py +++ b/eoxserver/services/mapserver/wms/layerfactories/coverage_bands_layer_factory.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.contrib.mapserver import Layer @@ -40,8 +40,8 @@ class CoverageBandsLayerFactory(OffsiteColorMixIn, AbstractLayerFactory): def generate(self, eo_object, group_layer, suffix, options): name = eo_object.identifier + "_bands" layer = Layer(name) - layer.setMetaData("ows_title", name) - layer.setMetaData("wms_label", name) + layer.metadata.set("ows_title", name) + layer.metadata.set("wms_label", name) layer.addProcessing("CLOSE_CONNECTION=CLOSE") coverage = eo_object.cast() diff --git a/eoxserver/services/mapserver/wms/layerfactories/coverage_layer_factory.py b/eoxserver/services/mapserver/wms/layerfactories/coverage_layer_factory.py index 80c74f5d6..f54b52180 100644 --- a/eoxserver/services/mapserver/wms/layerfactories/coverage_layer_factory.py +++ b/eoxserver/services/mapserver/wms/layerfactories/coverage_layer_factory.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011-2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.services.mapserver.wms.layerfactories.base import ( diff --git a/eoxserver/services/mapserver/wms/layerfactories/coverage_mask_layer_factory.py b/eoxserver/services/mapserver/wms/layerfactories/coverage_mask_layer_factory.py index b99b325b2..18c342199 100644 --- a/eoxserver/services/mapserver/wms/layerfactories/coverage_mask_layer_factory.py +++ b/eoxserver/services/mapserver/wms/layerfactories/coverage_mask_layer_factory.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011-2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.contrib import mapserver as ms from eoxserver.resources.coverages import models @@ -56,7 +56,7 @@ def _create_mask_polygon_layer(name): mask_layer.name = name mask_layer.type = ms.MS_LAYER_POLYGON - mask_layer.setMetaData("eoxs_geometry_reversed", "true") + mask_layer.metadata.set("eoxs_geometry_reversed", "true") cls = ms.classObj(mask_layer) style = ms.styleObj(cls) diff --git a/eoxserver/services/mapserver/wms/layerfactories/coverage_masked_outlines_layer_factory.py b/eoxserver/services/mapserver/wms/layerfactories/coverage_masked_outlines_layer_factory.py index 2e37ca602..89bc2392a 100644 --- a/eoxserver/services/mapserver/wms/layerfactories/coverage_masked_outlines_layer_factory.py +++ b/eoxserver/services/mapserver/wms/layerfactories/coverage_masked_outlines_layer_factory.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.contrib import mapserver as ms @@ -49,7 +49,7 @@ def generate(self, eo_object, group_layer, suffix, options): ) coverage = eo_object.cast() - layer.setMetaData("eoxs_geometry_reversed", "true") + layer.metadata.set("eoxs_geometry_reversed", "true") mask_items = coverage.data_items.filter( semantic__startswith="polygonmask" diff --git a/eoxserver/services/mapserver/wms/layerfactories/coverage_outlines_layer_factory.py b/eoxserver/services/mapserver/wms/layerfactories/coverage_outlines_layer_factory.py index 6913b35fe..4643143b3 100644 --- a/eoxserver/services/mapserver/wms/layerfactories/coverage_outlines_layer_factory.py +++ b/eoxserver/services/mapserver/wms/layerfactories/coverage_outlines_layer_factory.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.contrib.mapserver import shapeObj diff --git a/eoxserver/services/mapserver/wms/legendgraphic_renderer.py b/eoxserver/services/mapserver/wms/legendgraphic_renderer.py index 6c83250b9..c6a0314f7 100644 --- a/eoxserver/services/mapserver/wms/legendgraphic_renderer.py +++ b/eoxserver/services/mapserver/wms/legendgraphic_renderer.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import implements diff --git a/eoxserver/services/mapserver/wms/map_renderer.py b/eoxserver/services/mapserver/wms/map_renderer.py index 9c5aa83aa..408de3fc5 100644 --- a/eoxserver/services/mapserver/wms/map_renderer.py +++ b/eoxserver/services/mapserver/wms/map_renderer.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import implements diff --git a/eoxserver/services/mapserver/wms/styleapplicators/sld.py b/eoxserver/services/mapserver/wms/styleapplicators/sld.py index 8628d51c2..cdda35aaf 100644 --- a/eoxserver/services/mapserver/wms/styleapplicators/sld.py +++ b/eoxserver/services/mapserver/wms/styleapplicators/sld.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import logging diff --git a/eoxserver/services/mapserver/wms/util.py b/eoxserver/services/mapserver/wms/util.py index 25ea6da4e..24277b16b 100644 --- a/eoxserver/services/mapserver/wms/util.py +++ b/eoxserver/services/mapserver/wms/util.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import logging @@ -55,7 +55,7 @@ class MapServerWMSBaseComponent(Component): def render(self, layer_groups, request_values, **options): map_ = ms.Map() - map_.setMetaData("ows_enable_request", "*") + map_.web.metadata.set("ows_enable_request", "*") map_.setProjection("EPSG:4326") map_.imagecolor.setRGB(0, 0, 0) @@ -64,8 +64,8 @@ def render(self, layer_groups, request_values, **options): crss_string = " ".join( map(lambda crs: "EPSG:%d" % crs, decoder.supported_crss_wms) ) - map_.setMetaData("ows_srs", crss_string) - map_.setMetaData("wms_srs", crss_string) + map_.web.metadata.set("ows_srs", crss_string) + map_.web.metadata.set("wms_srs", crss_string) self.check_parameters(map_, request_values) @@ -105,7 +105,6 @@ def get_layer_factory(self, suffix): if suffix in factory.suffixes: if result: pass # TODO - #raise Exception("Found") result = factory return result return result @@ -169,7 +168,7 @@ def setup_map(self, layer_selection, map_, options): connector = self.get_connector(data_items) if group_name: - layer.setMetaData("wms_layer_group", "/" + group_name) + layer.metadata.set("wms_layer_group", "/" + group_name) session.add(connector, coverage, data_items, layer) @@ -194,7 +193,7 @@ def setup_map(self, layer_selection, map_, options): def get_empty_layers(self, name): layer = ms.layerObj() layer.name = name - layer.setMetaData("wms_enable_request", "getmap") + layer.metadata.set("wms_enable_request", "getmap") return (layer,) diff --git a/eoxserver/services/migrations/0004_alter_servicevisibility_id.py b/eoxserver/services/migrations/0004_alter_servicevisibility_id.py new file mode 100644 index 000000000..2b3378c9d --- /dev/null +++ b/eoxserver/services/migrations/0004_alter_servicevisibility_id.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2 on 2025-04-18 15:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('services', '0003_service_name_choices'), + ] + + operations = [ + migrations.AlterField( + model_name='servicevisibility', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + ] diff --git a/eoxserver/services/models.py b/eoxserver/services/models.py index 4ed07f599..6add71079 100644 --- a/eoxserver/services/models.py +++ b/eoxserver/services/models.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from django.contrib.gis.db import models diff --git a/eoxserver/services/native/wcs/capabilities_renderer.py b/eoxserver/services/native/wcs/capabilities_renderer.py index 2ea18df1d..171d0f0c1 100644 --- a/eoxserver/services/native/wcs/capabilities_renderer.py +++ b/eoxserver/services/native/wcs/capabilities_renderer.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from django.conf import settings diff --git a/eoxserver/services/native/wcs/coverage_description_renderer.py b/eoxserver/services/native/wcs/coverage_description_renderer.py index f9a227da9..708a9ce7f 100644 --- a/eoxserver/services/native/wcs/coverage_description_renderer.py +++ b/eoxserver/services/native/wcs/coverage_description_renderer.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from django.conf import settings diff --git a/eoxserver/services/opensearch/extensions/eo.py b/eoxserver/services/opensearch/extensions/eo.py index b5b82d1c1..c4531c0d9 100644 --- a/eoxserver/services/opensearch/extensions/eo.py +++ b/eoxserver/services/opensearch/extensions/eo.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2017 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import re import functools diff --git a/eoxserver/services/opensearch/extensions/geo.py b/eoxserver/services/opensearch/extensions/geo.py index ba6666e6c..2d987c8db 100644 --- a/eoxserver/services/opensearch/extensions/geo.py +++ b/eoxserver/services/opensearch/extensions/geo.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2015 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from django.contrib.gis.geos import GEOSGeometry, Point, Polygon, MultiPolygon diff --git a/eoxserver/services/opensearch/extensions/time.py b/eoxserver/services/opensearch/extensions/time.py index e1b20949f..2d1c860d6 100644 --- a/eoxserver/services/opensearch/extensions/time.py +++ b/eoxserver/services/opensearch/extensions/time.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2015 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from django.db.models import Q diff --git a/eoxserver/services/ows/common/config.py b/eoxserver/services/ows/common/config.py index f37577910..3a1b77d5a 100644 --- a/eoxserver/services/ows/common/config.py +++ b/eoxserver/services/ows/common/config.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core.decoders import config, typelist, Choice diff --git a/eoxserver/services/ows/common/v11/encoders.py b/eoxserver/services/ows/common/v11/encoders.py index 7181efc5d..a4a665328 100644 --- a/eoxserver/services/ows/common/v11/encoders.py +++ b/eoxserver/services/ows/common/v11/encoders.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from lxml.builder import ElementMaker from lxml.etree import ProcessingInstruction, ElementTree diff --git a/eoxserver/services/ows/common/v20/encoders.py b/eoxserver/services/ows/common/v20/encoders.py index 3c7b5f439..e78bccedb 100644 --- a/eoxserver/services/ows/common/v20/encoders.py +++ b/eoxserver/services/ows/common/v20/encoders.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from django.conf import settings import traceback diff --git a/eoxserver/services/ows/common/v20/exceptionhandler.py b/eoxserver/services/ows/common/v20/exceptionhandler.py index 28717ee1e..f20f119b1 100644 --- a/eoxserver/services/ows/common/v20/exceptionhandler.py +++ b/eoxserver/services/ows/common/v20/exceptionhandler.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class OWS20ExceptionHandler(object): diff --git a/eoxserver/services/ows/component.py b/eoxserver/services/ows/component.py index ae306fbbf..b64a155f7 100644 --- a/eoxserver/services/ows/component.py +++ b/eoxserver/services/ows/component.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import logging @@ -31,7 +31,6 @@ from functools import partial from django.http import HttpResponse -from django.utils.six import string_types from eoxserver.core import Component, ExtensionPoint, env from eoxserver.services.ows.interfaces import * @@ -50,6 +49,7 @@ ALLOWED_HTTP_METHODS = ["GET", "POST", "OPTIONS"] + class OptionsRequestHandler(object): """ Dummy request handler class to respond to HTTP OPTIONS requests. """ @@ -112,7 +112,6 @@ def query_service_handler(self, request): decoder = get_decoder(request) - if request.method == "GET": handlers = self.get_service_handlers elif request.method == "POST": @@ -124,7 +123,7 @@ def query_service_handler(self, request): "The %s HTTP method is not allowed!" % request.method, ALLOWED_HTTP_METHODS ) - #handlers = self.service_handlers + # handlers = self.service_handlers version = decoder.version if version is None: @@ -284,7 +283,7 @@ def sort_handlers(handlers, ascending=True): def handler_supports_service(handler, service=None): """ Convenience method to check whether or not a handler supports a service. """ - if isinstance(handler.service, string_types): + if isinstance(handler.service, str): return handler.service.upper() == service else: return service in handler.service diff --git a/eoxserver/services/ows/decoders.py b/eoxserver/services/ows/decoders.py index 630eb6bf4..d60096dce 100644 --- a/eoxserver/services/ows/decoders.py +++ b/eoxserver/services/ows/decoders.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core.decoders import kvp, xml, upper, typelist diff --git a/eoxserver/services/ows/dispatch.py b/eoxserver/services/ows/dispatch.py index 8bce526b1..b5222d501 100644 --- a/eoxserver/services/ows/dispatch.py +++ b/eoxserver/services/ows/dispatch.py @@ -28,9 +28,7 @@ import logging from django.conf import settings -# from django.utils.module_loading import import_string from django.http import HttpResponse -from django.utils.six import string_types from eoxserver.services.ows.config import ( DEFAULT_EOXS_OWS_SERVICE_HANDLERS, @@ -223,7 +221,8 @@ def query_exception_handler(request): try: decoder = get_decoder(request) - handlers = sorted([ + handlers = sorted( + [ handler() for handler in EXCEPTION_HANDLERS if handler_supports_service(handler, decoder.service) @@ -240,7 +239,7 @@ def query_exception_handler(request): # return the exception handler with the highest version, # if one is available return handlers[0] - except: + except Exception: # swallow any exception here, because we *really* need a handler # to correctly show the exception. pass @@ -314,7 +313,7 @@ def filter_handlers(handlers=None, service=None, versions=None, request=None, def handler_supports_service(handler, service=None): """ Convenience method to check whether or not a handler supports a service. """ - if isinstance(handler.service, string_types): + if isinstance(handler.service, str): return handler.service.upper() == service else: return service in handler.service diff --git a/eoxserver/services/ows/interfaces.py b/eoxserver/services/ows/interfaces.py index 3318b7d3c..231367c10 100644 --- a/eoxserver/services/ows/interfaces.py +++ b/eoxserver/services/ows/interfaces.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class ServiceHandlerInterface(object): @@ -32,8 +32,8 @@ class ServiceHandlerInterface(object): @property def service(self): - """ The name of the supported service in uppercase letters. This can - also be an iterable, if the handler shall support more than one + """ The name of the supported service in uppercase letters. This can + also be an iterable, if the handler shall support more than one service specifier. Some service specifications demand that the service parameter can be omitted for certain requests. In this case this property can alse be @@ -51,31 +51,31 @@ def request(self): """ def handle(self, request): - """ The main handling method. Takes a `django.http.Request` object as + """ The main handling method. Takes a `django.http.Request` object as single parameter. """ @property def constraints(self): - """ Optional property to return a dict with constraints for default + """ Optional property to return a dict with constraints for default values. """ @property def index(self): - """ Optional. The index this service handler shall have when being + """ Optional. The index this service handler shall have when being reported in a capabilities document. """ -class ExceptionHandlerInterface(object): +class ExceptionHandlerInterface(object): """ Interface for OWS exception handlers. """ @property def service(self): - """ The name of the supported service in uppercase letters. This can - also be an iterable, if the handler shall support more than one + """ The name of the supported service in uppercase letters. This can + also be an iterable, if the handler shall support more than one service specifier. Some service specifications demand that the service parameter can be omitted for certain requests. In this case this property can alse be @@ -93,7 +93,7 @@ def request(self): """ def handle_exception(self, request, exception): - """ The main exception handling method. Parameters are an object of the + """ The main exception handling method. Parameters are an object of the `django.http.Request` type and the raised exception. """ diff --git a/eoxserver/services/ows/version.py b/eoxserver/services/ows/version.py index defb499ae..625171edc 100644 --- a/eoxserver/services/ows/version.py +++ b/eoxserver/services/ows/version.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,16 +23,10 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -from functools import wraps -try: - from functools import total_ordering -except ImportError: - from eoxserver.core.util.functools import total_ordering - -from django.utils.six import string_types +from functools import wraps, total_ordering __all__ = ["parse_version_string", "Version"] @@ -52,7 +46,7 @@ def convert_to_version(f): def wrapper(self, other): if isinstance(other, Version): return f(self, other) - elif isinstance(other, string_types): + elif isinstance(other, str): return f(self, parse_version_string(other)) try: return f(self, Version(*other)) diff --git a/eoxserver/services/ows/wcs/interfaces.py b/eoxserver/services/ows/wcs/interfaces.py index 1b0b9f734..0f0859452 100644 --- a/eoxserver/services/ows/wcs/interfaces.py +++ b/eoxserver/services/ows/wcs/interfaces.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class WCSCapabilitiesRendererInterface(object): @@ -31,12 +31,12 @@ class WCSCapabilitiesRendererInterface(object): """ def render(self, params): - """ Render the capabilities including information about the given + """ Render the capabilities including information about the given coverages. """ def supports(self, params): - """ Returns a boolean value to indicate whether or not the renderer is + """ Returns a boolean value to indicate whether or not the renderer is able to render the capabilities with the given parameters. """ @@ -50,7 +50,7 @@ def render(self, params): """ def supports(self, params): - """ Returns a boolean value to indicate whether or not the renderer is + """ Returns a boolean value to indicate whether or not the renderer is able to render the coverage and the given WCS version. """ @@ -64,7 +64,7 @@ def render(self, params): """ def supports(self, params): - """ Returns a boolean value to indicate whether or not the renderer is + """ Returns a boolean value to indicate whether or not the renderer is able to render the coverage with the given parameters. """ @@ -74,12 +74,12 @@ class PackageWriterInterface(object): """ def supports(self, format, params): - """ Return a boolen value, whether or not a writer supports a given + """ Return a boolen value, whether or not a writer supports a given format. """ def create_package(self, filename, format, params): - """ Create a package, which the encoder can later add items to with the + """ Create a package, which the encoder can later add items to with the `cleanup` and `add_to_package` method. """ @@ -88,7 +88,7 @@ def cleanup(self, package): """ def add_to_package(self, package, file_obj, size, location): - """ Add the file object to the package, that is returned by the + """ Add the file object to the package, that is returned by the `create_package` method. """ @@ -98,18 +98,18 @@ def get_mime_type(self, package, format, params): """ def get_file_extension(self, package, format, params): - """ Retrieve the file extension for the given package and format + """ Retrieve the file extension for the given package and format specifier. """ class EncodingExtensionInterface(object): def supports(self, format, options): - """ Return a boolen value, whether or not an encoding extension + """ Return a boolen value, whether or not an encoding extension supports a given format. """ def parse_encoding_params(self, request): - """ Return a dict, containing all additional encoding parameters from a + """ Return a dict, containing all additional encoding parameters from a given request. """ diff --git a/eoxserver/services/ows/wcs/parameters.py b/eoxserver/services/ows/wcs/parameters.py index 0001b425e..9952c8ffa 100644 --- a/eoxserver/services/ows/wcs/parameters.py +++ b/eoxserver/services/ows/wcs/parameters.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.services.parameters import ( @@ -35,7 +35,7 @@ class WCSParamsMixIn(object): def __iter__(self): for k, v in super(WCSParamsMixIn, self).__iter__(): yield k, v - + yield ("service", "WCS") diff --git a/eoxserver/services/ows/wcs/v10/describecoverage.py b/eoxserver/services/ows/wcs/v10/describecoverage.py index 75cbaf423..1eaa6b195 100644 --- a/eoxserver/services/ows/wcs/v10/describecoverage.py +++ b/eoxserver/services/ows/wcs/v10/describecoverage.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,13 +23,13 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, implements from eoxserver.core.decoders import xml, kvp, typelist from eoxserver.services.ows.interfaces import ( - ServiceHandlerInterface, GetServiceHandlerInterface, + ServiceHandlerInterface, GetServiceHandlerInterface, PostServiceHandlerInterface ) from eoxserver.services.ows.wcs.basehandlers import ( diff --git a/eoxserver/services/ows/wcs/v10/exceptionhandler.py b/eoxserver/services/ows/wcs/v10/exceptionhandler.py index c54fc513b..ed6d543d9 100644 --- a/eoxserver/services/ows/wcs/v10/exceptionhandler.py +++ b/eoxserver/services/ows/wcs/v10/exceptionhandler.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.services.ows.common.v20.encoders import OWS20ExceptionXMLEncoder from eoxserver.core.decoders import ( @@ -41,7 +41,7 @@ def handle_exception(self, request, exception): code = getattr(exception, "code", None) locator = getattr(exception, "locator", None) status = 400 - + # TODO diff --git a/eoxserver/services/ows/wcs/v10/getcoverage.py b/eoxserver/services/ows/wcs/v10/getcoverage.py index 91abe9c18..dff7dea04 100644 --- a/eoxserver/services/ows/wcs/v10/getcoverage.py +++ b/eoxserver/services/ows/wcs/v10/getcoverage.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,12 +23,12 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, implements from eoxserver.core.decoders import xml, kvp from eoxserver.services.ows.interfaces import ( - ServiceHandlerInterface, GetServiceHandlerInterface, + ServiceHandlerInterface, GetServiceHandlerInterface, PostServiceHandlerInterface ) from eoxserver.services.ows.wcs.basehandlers import WCSGetCoverageHandlerBase @@ -54,7 +54,7 @@ def get_decoder(self, request): def get_params(self, coverage, decoder, request): return WCS10CoverageRenderParams( - coverage, decoder.bbox, decoder.crs, decoder.format, + coverage, decoder.bbox, decoder.crs, decoder.format, decoder.response_crs, decoder.width, decoder.height, decoder.resx, decoder.resy, decoder.interpolation ) diff --git a/eoxserver/services/ows/wcs/v10/parameters.py b/eoxserver/services/ows/wcs/v10/parameters.py index 8bc9dcad2..86ff0cb23 100644 --- a/eoxserver/services/ows/wcs/v10/parameters.py +++ b/eoxserver/services/ows/wcs/v10/parameters.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.services.ows.wcs.parameters import ( CoverageRenderParams, CoverageDescriptionRenderParams @@ -41,8 +41,8 @@ def __init__(self, coverages): class WCS10CoverageRenderParams(CoverageRenderParams): - def __init__(self, coverage, bbox, crs, format, response_crs=None, - width=None, height=None, resx=None, resy=None, + def __init__(self, coverage, bbox, crs, format, response_crs=None, + width=None, height=None, resx=None, resy=None, interpolation=None): super(WCS10CoverageRenderParams, self).__init__(coverage, "1.0.0") @@ -83,21 +83,21 @@ def __iter__(self): yield ("bbox", ",".join(map(str, self.bbox))) yield ("crs", self.crs) yield ("format", self.format) - + if self.response_crs: yield ("response_crs", self.response_crs) - + if self.width is not None: yield ("width", str(self.width)) - + if self.height is not None: yield ("height", str(self.height)) - + if self.resx is not None: yield ("resx", self.resx) if self.resy is not None: yield ("resy", self.resy) - + if self.interpolation: yield ("interpolation", self.interpolation) diff --git a/eoxserver/services/ows/wcs/v10/util.py b/eoxserver/services/ows/wcs/v10/util.py index 9dbdb3fe5..2347f5c62 100644 --- a/eoxserver/services/ows/wcs/v10/util.py +++ b/eoxserver/services/ows/wcs/v10/util.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core.util.xmltools import NameSpace, NameSpaceMap diff --git a/eoxserver/services/ows/wcs/v11/describecoverage.py b/eoxserver/services/ows/wcs/v11/describecoverage.py index 3ec4dbd58..ffc63436f 100644 --- a/eoxserver/services/ows/wcs/v11/describecoverage.py +++ b/eoxserver/services/ows/wcs/v11/describecoverage.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,13 +23,13 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, implements from eoxserver.core.decoders import xml, kvp, typelist from eoxserver.services.ows.interfaces import ( - ServiceHandlerInterface, GetServiceHandlerInterface, + ServiceHandlerInterface, GetServiceHandlerInterface, PostServiceHandlerInterface ) from eoxserver.services.ows.wcs.basehandlers import ( diff --git a/eoxserver/services/ows/wcs/v11/exceptionhandler.py b/eoxserver/services/ows/wcs/v11/exceptionhandler.py index f8c6e5d69..f829b3598 100644 --- a/eoxserver/services/ows/wcs/v11/exceptionhandler.py +++ b/eoxserver/services/ows/wcs/v11/exceptionhandler.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.services.ows.common.v11.encoders import OWS11ExceptionXMLEncoder from eoxserver.core.decoders import ( @@ -42,7 +42,7 @@ def handle_exception(self, request, exception): code = getattr(exception, "code", None) locator = getattr(exception, "locator", None) status = 400 - + if code is None: if isinstance(exception, MissingParameterException): code = "MissingParameterValue" diff --git a/eoxserver/services/ows/wcs/v11/getcoverage.py b/eoxserver/services/ows/wcs/v11/getcoverage.py index 8d431054d..bae176c02 100644 --- a/eoxserver/services/ows/wcs/v11/getcoverage.py +++ b/eoxserver/services/ows/wcs/v11/getcoverage.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,13 +23,13 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, implements from eoxserver.core.decoders import xml, kvp, typelist from eoxserver.services.ows.interfaces import ( - ServiceHandlerInterface, GetServiceHandlerInterface, + ServiceHandlerInterface, GetServiceHandlerInterface, PostServiceHandlerInterface ) from eoxserver.services.ows.wcs.basehandlers import WCSGetCoverageHandlerBase @@ -54,8 +54,8 @@ def get_decoder(self, request): def get_params(self, coverage, decoder, request): return WCS11CoverageRenderParams( - coverage, decoder.boundingbox, decoder.format, decoder.gridcs, - decoder.gridbasecrs, decoder.gridtype, decoder.gridorigin, + coverage, decoder.boundingbox, decoder.format, decoder.gridcs, + decoder.gridbasecrs, decoder.gridtype, decoder.gridorigin, decoder.gridoffsets ) diff --git a/eoxserver/services/ows/wcs/v11/parameters.py b/eoxserver/services/ows/wcs/v11/parameters.py index 64894b088..57969a65a 100644 --- a/eoxserver/services/ows/wcs/v11/parameters.py +++ b/eoxserver/services/ows/wcs/v11/parameters.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.services.ows.wcs.parameters import ( CoverageRenderParams, CoverageDescriptionRenderParams @@ -41,7 +41,7 @@ def __init__(self, coverages): class WCS11CoverageRenderParams(CoverageRenderParams): - def __init__(self, coverage, bbox, format, gridcs=None, gridbasecrs=None, + def __init__(self, coverage, bbox, format, gridcs=None, gridbasecrs=None, gridtype=None, gridorigin=None, gridoffsets=None): super(WCS11CoverageRenderParams, self).__init__(coverage, "1.1.2") @@ -77,18 +77,18 @@ def __iter__(self): yield ("boundingbox", ",".join(map(str, self.bbox))) yield ("format", self.format) - + if self.gridcs: yield ("gridcs", self.gridcs) - + if self.gridbasecrs: yield ("gridbasecrs", self.gridbasecrs) - + if self.gridoffsets: yield ("gridoffsets", ",".join(map(str, self.gridoffsets))) - + if self.gridtype is not None: yield ("gridtype", self.gridtype) - + if self.gridorigin is not None: yield ("gridorigin", ",".join(map(str, self.gridorigin))) diff --git a/eoxserver/services/ows/wcs/v11/util.py b/eoxserver/services/ows/wcs/v11/util.py index 49a9e0aec..9d37a2216 100644 --- a/eoxserver/services/ows/wcs/v11/util.py +++ b/eoxserver/services/ows/wcs/v11/util.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core.util.xmltools import NameSpace, NameSpaceMap diff --git a/eoxserver/services/ows/wcs/v20/describecoverage.py b/eoxserver/services/ows/wcs/v20/describecoverage.py index d7a8acfc3..d8079ba0c 100644 --- a/eoxserver/services/ows/wcs/v20/describecoverage.py +++ b/eoxserver/services/ows/wcs/v20/describecoverage.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core.decoders import xml, kvp, typelist diff --git a/eoxserver/services/ows/wcs/v20/describeeocoverageset.py b/eoxserver/services/ows/wcs/v20/describeeocoverageset.py index 4470ced2c..790a659bb 100644 --- a/eoxserver/services/ows/wcs/v20/describeeocoverageset.py +++ b/eoxserver/services/ows/wcs/v20/describeeocoverageset.py @@ -25,11 +25,10 @@ # THE SOFTWARE. # ------------------------------------------------------------------------------ - +import sys import logging from django.db.models import Q -from django.utils.six import MAXSIZE from eoxserver.core.config import get_eoxserver_config from eoxserver.core.decoders import xml, kvp, typelist, enum @@ -262,7 +261,7 @@ class WCS20DescribeEOCoverageSetKVPDecoder(kvp.Decoder, SectionsMixIn): eo_ids = kvp.Parameter("eoid", type=typelist(str, ","), num=1, locator="eoid") subsets = kvp.Parameter("subset", type=parse_subset_kvp, num="*") containment = kvp.Parameter(type=containment_enum, num="?") - count = kvp.Parameter(type=pos_int, num="?", default=MAXSIZE) + count = kvp.Parameter(type=pos_int, num="?", default=sys.maxsize) sections = kvp.Parameter(type=typelist(sections_enum, ","), num="?") @@ -270,7 +269,7 @@ class WCS20DescribeEOCoverageSetXMLDecoder(xml.Decoder, SectionsMixIn): eo_ids = xml.Parameter("wcseo:eoId/text()", num="+", locator="eoid") subsets = xml.Parameter("wcs:DimensionTrim", type=parse_subset_xml, num="*") containment = xml.Parameter("wcseo:containment/text()", type=containment_enum, locator="containment") - count = xml.Parameter("@count", type=pos_int, num="?", default=MAXSIZE, locator="count") + count = xml.Parameter("@count", type=pos_int, num="?", default=sys.maxsize, locator="count") sections = xml.Parameter("wcseo:sections/wcseo:section/text()", type=sections_enum, num="*", locator="sections") namespaces = nsmap diff --git a/eoxserver/services/ows/wcs/v20/encoders.py b/eoxserver/services/ows/wcs/v20/encoders.py index 6f0f7221b..4d04900b8 100644 --- a/eoxserver/services/ows/wcs/v20/encoders.py +++ b/eoxserver/services/ows/wcs/v20/encoders.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from __future__ import division diff --git a/eoxserver/services/ows/wcs/v20/encodings/geotiff.py b/eoxserver/services/ows/wcs/v20/encodings/geotiff.py index 8a5f13ed7..561522f68 100644 --- a/eoxserver/services/ows/wcs/v20/encodings/geotiff.py +++ b/eoxserver/services/ows/wcs/v20/encodings/geotiff.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core.decoders import ( kvp, xml, enum, value_range, boolean, InvalidParameterException @@ -93,7 +93,7 @@ def get_encoding_params(self, request): "'Deflate'.", "geotiff:predictor" ) - if jpeg_quality is not None: + if jpeg_quality is not None: if compression != "JPEG": raise CompressionNotSupported( "geotiff:jpeg_quality requires compression method 'JPEG'.", diff --git a/eoxserver/services/ows/wcs/v20/exceptionhandler.py b/eoxserver/services/ows/wcs/v20/exceptionhandler.py index 1a15f908c..7f8732a94 100644 --- a/eoxserver/services/ows/wcs/v20/exceptionhandler.py +++ b/eoxserver/services/ows/wcs/v20/exceptionhandler.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import traceback diff --git a/eoxserver/services/ows/wcs/v20/getcoverage.py b/eoxserver/services/ows/wcs/v20/getcoverage.py index 7e3cc688b..f33ba8c0e 100644 --- a/eoxserver/services/ows/wcs/v20/getcoverage.py +++ b/eoxserver/services/ows/wcs/v20/getcoverage.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from itertools import chain diff --git a/eoxserver/services/ows/wcs/v20/geteocoverageset.py b/eoxserver/services/ows/wcs/v20/geteocoverageset.py index dd2ead873..dee2f3836 100644 --- a/eoxserver/services/ows/wcs/v20/geteocoverageset.py +++ b/eoxserver/services/ows/wcs/v20/geteocoverageset.py @@ -26,6 +26,7 @@ # ------------------------------------------------------------------------------ +import sys import os import tempfile import logging @@ -33,13 +34,8 @@ import mimetypes from django.db.models import Q -from django.http import HttpResponse -try: - from django.http import StreamingHttpResponse -except ImportError: - StreamingHttpResponse = HttpResponse +from django.http import StreamingHttpResponse -from django.utils.six import MAXSIZE from django.conf import settings from django.utils.module_loading import import_string @@ -385,7 +381,7 @@ class WCS20GetEOCoverageSetKVPDecoder(kvp.Decoder): eo_ids = kvp.Parameter("eoid", type=typelist(str, ","), num=1, locator="eoid") subsets = kvp.Parameter("subset", type=parse_subset_kvp, num="*") containment = kvp.Parameter(type=containment_enum, num="?") - count = kvp.Parameter(type=pos_int, num="?", default=MAXSIZE) + count = kvp.Parameter(type=pos_int, num="?", default=sys.maxsize) start_index = kvp.Parameter("startIndex", type=pos_int, num="?", default=0) package_format = kvp.Parameter("packageFormat", num="?", type=parse_package_format) mediatype = kvp.Parameter("mediatype", num="?") @@ -404,7 +400,7 @@ class WCS20GetEOCoverageSetXMLDecoder(xml.Decoder): eo_ids = xml.Parameter("wcseo11:eoId/text()", num="+", locator="eoid") subsets = xml.Parameter("wcs:DimensionTrim", type=parse_subset_xml, num="*") containment = xml.Parameter("wcseo11:containment/text()", num="?", type=containment_enum, locator="containment") - count = xml.Parameter("@count", type=pos_int, num="?", default=MAXSIZE, locator="count") + count = xml.Parameter("@count", type=pos_int, num="?", default=sys.maxsize, locator="count") start_index = xml.Parameter("@startIndex", type=pos_int, num="?", default=0, locator="startIndex") package_format = xml.Parameter("wcseo11:packageFormat/text()", type=parse_package_format, num="?", locator="packageFormat") mediatype = xml.Parameter("wcseo11:mediaType/text()", num="?", locator="mediatype") diff --git a/eoxserver/services/ows/wcs/v20/parameters.py b/eoxserver/services/ows/wcs/v20/parameters.py index f2166abea..85449929e 100644 --- a/eoxserver/services/ows/wcs/v20/parameters.py +++ b/eoxserver/services/ows/wcs/v20/parameters.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core.util.timetools import isoformat from eoxserver.services.subset import Slice diff --git a/eoxserver/services/ows/wcs/v20/util.py b/eoxserver/services/ows/wcs/v20/util.py index ee302ed65..e777e34b1 100644 --- a/eoxserver/services/ows/wcs/v20/util.py +++ b/eoxserver/services/ows/wcs/v20/util.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,14 +23,13 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import re from datetime import datetime from lxml.builder import ElementMaker -from django.utils.six import string_types from eoxserver.core.util.xmltools import NameSpace, NameSpaceMap, ns_xsi from eoxserver.core.util.timetools import parse_iso8601 @@ -86,11 +85,10 @@ class RangeSubset(list): def get_band_indices(self, range_type, offset=0): - current_idx = -1 all_bands = range_type[:] for subset in self: - if isinstance(subset, string_types): + if isinstance(subset, str): # slice, i.e single band start = stop = subset @@ -101,19 +99,18 @@ def get_band_indices(self, range_type, offset=0): if start != stop: stop_idx = self._find(all_bands, stop) if stop_idx <= start_idx: - raise IllegalFieldSequenceException( + raise InvalidFieldSequenceException( "Invalid interval '%s:%s'." % (start, stop), start ) # expand interval to indices - for i in range(start_idx, stop_idx+1): + for i in range(start_idx, stop_idx + 1): yield i + offset else: # return the item yield start_idx + offset - def _find(self, all_bands, name): for i, band in enumerate(all_bands): if band.identifier == name: @@ -300,6 +297,7 @@ def parse_subset_xml(elem): "lanczos", "mode" ) + def parse_interpolation(raw): """ Returns a unified string denoting the interpolation method used. """ diff --git a/eoxserver/services/ows/wcs11Transaction.py b/eoxserver/services/ows/wcs11Transaction.py index c28db2a4f..f7319c30e 100644 --- a/eoxserver/services/ows/wcs11Transaction.py +++ b/eoxserver/services/ows/wcs11Transaction.py @@ -1,16 +1,16 @@ -#----------------------------------------------------------------------- +# ---------------------------------------------------------------------- # -# Description: +# Description: # -# This file contains definition of WCS 1.1.x Transaction extension operation handler. +# This file contains definition of WCS 1.1.x Transaction extension operation handler. # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- -# Copyright (C) 2011 Iguassu Software Systems, a.s +# ------------------------------------------------------------------------------ +# Copyright (C) 2011 Iguassu Software Systems, a.s # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -29,12 +29,12 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import os.path import logging -import traceback +import traceback #from eoxserver.core.util.xmltools import DOMElementToXML #from eoxserver.core.exceptions import InternalError @@ -46,15 +46,15 @@ from eoxserver.services.requests import Response #from eoxserver.services.ogc import OGCExceptionHandler from eoxserver.services.exceptions import InvalidRequestException -from eoxserver.services.base import BaseRequestHandler +from eoxserver.services.base import BaseRequestHandler -from eoxserver.services.ows.wcst.wcstXML import parseCoverageXML +from eoxserver.services.ows.wcst.wcstXML import parseCoverageXML from eoxserver.services.ows.wcst.wcst11Transaction import wcst11Transaction from eoxserver.services.ows.wcst.wcst11Context import contextCreate, contextDiscardSuccess, contextDiscardFailure, contextDiscardAsync from eoxserver.services.ows.wcst.wcst11Exception import createXML_OWS11Exception, ExOperationNotSupported -# -# NOTE: WCS-T allows service to be '1.1' only. Since the EOxServer accept version '1.1.0' only -# we need to define a new version handler dedicated to WCS-T only. +# +# NOTE: WCS-T allows service to be '1.1' only. Since the EOxServer accept version '1.1.0' only +# we need to define a new version handler dedicated to WCS-T only. # If you (EOX guys) know a better solution please let me know. # @@ -63,7 +63,7 @@ class WCS11VersionHandler(OWSCommonVersionHandler): SERVICE = "wcs" - + REGISTRY_CONF = { "name": "WCS 1.1 Version Handler", "impl_id": "services.ows.wcs11Transaction.WCS11VersionHandler", @@ -76,7 +76,7 @@ class WCS11VersionHandler(OWSCommonVersionHandler): WCS11VersionHandlerImplementation = VersionHandlerInterface.implement(WCS11VersionHandler) # -# WCS-T operation handler +# WCS-T operation handler # NS_WCST11="http://www.opengis.net/wcs/1.1/wcst" @@ -96,55 +96,55 @@ class WCS11TransactionHandler(BaseRequestHandler): "requestId": {"xml_location": "/{%s}RequestId"%NS_WCST11, "xml_type": "string", "kvp_key": "requestId", "kvp_type": "string"}, "responseHandler": {"xml_location": "/{%s}ResponseHandler"%NS_WCST11, "xml_type": "string", "kvp_key": "responseHandler", "kvp_type": "string"}, "actions": {"xml_location":"/{%s}InputCoverages/{%s}Coverage"%(NS_WCST11,NS_WCST11),"xml_type":"element[]","kvp_key":"coverages","kvp_type":"string"}, - } + } def _handleException(self, req, exception): - logger.debug("WCS110: Transaction() - Exception Handler!") + logger.debug("WCS110: Transaction() - Exception Handler!") + + # dump exception to the log file + logger.error( traceback.format_exc() ) - # dump exception to the log file - logger.error( traceback.format_exc() ) + return Response( content=createXML_OWS11Exception(exception) , content_type="text/xml" , status=500 ) - return Response( content=createXML_OWS11Exception(exception) , content_type="text/xml" , status=500 ) - def _processRequest(self, req ): - logger.debug("WCS110: Transaction()") + logger.debug("WCS110: Transaction()") - # KVP encoding is not supported by WCS-T - if req.http_req.method.upper() == "GET" : - raise ExOperationNotSupported("transaction","Operation does not support KVP encoding!") + # KVP encoding is not supported by WCS-T + if req.http_req.method.upper() == "GET" : + raise ExOperationNotSupported("transaction","Operation does not support KVP encoding!") - # parse request - req.decoder.setSchema( self.PARAM_SCHEMA ) + # parse request + req.decoder.setSchema( self.PARAM_SCHEMA ) # get actions (requests) and context (working env.) - actions = map( parseCoverageXML , req.decoder.getValue('actions') ) - context = contextCreate( req.decoder.getValue('requestId') , req.decoder.getValue('responseHandler') ) + actions = map( parseCoverageXML , req.decoder.getValue('actions') ) + context = contextCreate( req.decoder.getValue('requestId') , req.decoder.getValue('responseHandler') ) - try: + try: - # execute transaction + # execute transaction response = wcst11Transaction( actions , context ) - except : #FAILURE + except : #FAILURE - # discard permanent and temporary storage + # discard permanent and temporary storage contextDiscardFailure( context ) - raise + raise - else : # SUCCESS + else : # SUCCESS - # clean-up TMP space of a synchronous operation - if not context['isAsync'] : - contextDiscardSuccess( context ) - # no TMP clean-up for asynnchronous operation - else : - contextDiscardAsync( context ) + # clean-up TMP space of a synchronous operation + if not context['isAsync'] : + contextDiscardSuccess( context ) + # no TMP clean-up for asynnchronous operation + else : + contextDiscardAsync( context ) - # prepare the response - return Response( content=response , content_type="text/xml" , status=200 ) + # prepare the response + return Response( content=response , content_type="text/xml" , status=200 ) WCS11TransactionHandlerImplementation = OperationHandlerInterface.implement(WCS11TransactionHandler) diff --git a/eoxserver/services/ows/wms/exceptions.py b/eoxserver/services/ows/wms/exceptions.py index c9e8a5ad2..73cb3bf9f 100644 --- a/eoxserver/services/ows/wms/exceptions.py +++ b/eoxserver/services/ows/wms/exceptions.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class LayerNotDefined(Exception): diff --git a/eoxserver/services/ows/wms/interfaces.py b/eoxserver/services/ows/wms/interfaces.py index 818dd4773..bd3df0d62 100644 --- a/eoxserver/services/ows/wms/interfaces.py +++ b/eoxserver/services/ows/wms/interfaces.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class WMSCapabilitiesRendererInterface(object): @@ -31,7 +31,7 @@ class WMSCapabilitiesRendererInterface(object): """ def render(self, collections, coverages, request_values): - """ Render a capabilities document, containing metadata of the given + """ Render a capabilities document, containing metadata of the given collections and coverages. """ @@ -46,7 +46,7 @@ def suffixes(self): """ def render(self, layer_groups, request_values, **options): - """ Render the given layer hierarchy with the provided request values + """ Render the given layer hierarchy with the provided request values and further options. ``options`` contains relevant options such as specified bands. @@ -62,7 +62,7 @@ def suffixes(self): """ def render(self, layer_groups, request_values, **options): - """ Render the given layer hierarchy with the provided request values + """ Render the given layer hierarchy with the provided request values and further options. ``options`` contains relevant options such as specified bands. diff --git a/eoxserver/services/ows/wms/util.py b/eoxserver/services/ows/wms/util.py index 962494ba6..3ff8c15ff 100644 --- a/eoxserver/services/ows/wms/util.py +++ b/eoxserver/services/ows/wms/util.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import logging diff --git a/eoxserver/services/ows/wms/v10/getcapabilities.py b/eoxserver/services/ows/wms/v10/getcapabilities.py index e10ffe7ae..1b748257c 100644 --- a/eoxserver/services/ows/wms/v10/getcapabilities.py +++ b/eoxserver/services/ows/wms/v10/getcapabilities.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, implements diff --git a/eoxserver/services/ows/wms/v10/getfeatureinfo.py b/eoxserver/services/ows/wms/v10/getfeatureinfo.py index ffbac3274..22b0b4348 100644 --- a/eoxserver/services/ows/wms/v10/getfeatureinfo.py +++ b/eoxserver/services/ows/wms/v10/getfeatureinfo.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from itertools import chain @@ -62,16 +62,16 @@ def handle(self, request): if not layers: raise InvalidParameterException("No layers specified", "layers") - + minx, miny, maxx, maxy = bbox subsets = Subsets(( Trim("x", minx, maxx), Trim("y", miny, maxy), ), crs=srs) - + root_group = lookup_layers(layers, subsets) - + result, _ = self.renderer.render( root_group, request.GET.items(), request ) diff --git a/eoxserver/services/ows/wms/v10/getmap.py b/eoxserver/services/ows/wms/v10/getmap.py index 6ee7031f4..740328566 100644 --- a/eoxserver/services/ows/wms/v10/getmap.py +++ b/eoxserver/services/ows/wms/v10/getmap.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, implements, UniqueExtensionPoint from eoxserver.core.decoders import kvp, typelist, InvalidParameterException diff --git a/eoxserver/services/ows/wms/v11/getcapabilities.py b/eoxserver/services/ows/wms/v11/getcapabilities.py index e34d06cfa..c3da6abaa 100644 --- a/eoxserver/services/ows/wms/v11/getcapabilities.py +++ b/eoxserver/services/ows/wms/v11/getcapabilities.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, implements diff --git a/eoxserver/services/ows/wms/v11/getfeatureinfo.py b/eoxserver/services/ows/wms/v11/getfeatureinfo.py index 00d6e4e00..420dda0c3 100644 --- a/eoxserver/services/ows/wms/v11/getfeatureinfo.py +++ b/eoxserver/services/ows/wms/v11/getfeatureinfo.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from itertools import chain @@ -63,16 +63,16 @@ def handle(self, request): if not layers: raise InvalidParameterException("No layers specified", "layers") - + minx, miny, maxx, maxy = bbox subsets = Subsets(( Trim("x", minx, maxx), Trim("y", miny, maxy), ), crs=srs) - if time: + if time: subsets.append(time) - + renderer = self.renderer root_group = lookup_layers(layers, subsets, renderer.suffixes) diff --git a/eoxserver/services/ows/wms/v11/getmap.py b/eoxserver/services/ows/wms/v11/getmap.py index 26cc54ce5..15d83c8c4 100644 --- a/eoxserver/services/ows/wms/v11/getmap.py +++ b/eoxserver/services/ows/wms/v11/getmap.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, implements, UniqueExtensionPoint diff --git a/eoxserver/services/ows/wms/v13/exceptionhandler.py b/eoxserver/services/ows/wms/v13/exceptionhandler.py index 672bfcd6a..194578303 100644 --- a/eoxserver/services/ows/wms/v13/exceptionhandler.py +++ b/eoxserver/services/ows/wms/v13/exceptionhandler.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,13 +23,10 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -try: - from io import StringIO -except ImportError: - from cStringIO import StringIO +from io import BytesIO try: from PIL import Image, ImageFont, ImageDraw @@ -43,12 +40,6 @@ from eoxserver.core.util.xmltools import XMLEncoder, NameSpace, NameSpaceMap from eoxserver.services.ows.interfaces import ExceptionHandlerInterface -try: - # Python 2 - xrange -except NameError: - # Python 3, xrange is now named range - xrange = range class WMS13ExceptionHandler(Component): implements(ExceptionHandlerInterface) @@ -64,10 +55,12 @@ def get_encoder(self, request): return WMS13ExceptionXMLEncoder() elif exceptions in ("inimage", "blank"): return WMS13ExceptionImageEncoder( - decoder.width, decoder.height, decoder.format, decoder.bgcolor, - exceptions=="blank" + decoder.width, + decoder.height, + decoder.format, + decoder.bgcolor, + exceptions == "blank", ) - print (decoder.exceptions) def handle_exception(self, request, exception): encoder = self.get_encoder(request) @@ -77,12 +70,10 @@ def handle_exception(self, request, exception): return ( encoder.serialize( - encoder.encode_exception( - str(exception), code, locator - ), - ), - encoder.content_type, - 400 + encoder.encode_exception(str(exception), code, locator), + ), + encoder.content_type, + 400, ) @@ -98,20 +89,17 @@ class WMS13Decoder(kvp.Decoder): nsmap = NameSpaceMap(ns_ogc) OGC = ElementMaker(namespace=ns_ogc.uri, nsmap=nsmap) + class WMS13ExceptionXMLEncoder(XMLEncoder): def encode_exception(self, message, code, locator=None): - attributes = { - "code": code - } + attributes = {"code": code} if locator: attributes["locator"] = locator - return OGC("ServiceExceptionReport", - OGC("ServiceException", - str(message), - **attributes - ), - version="1.3.0" + return OGC( + "ServiceExceptionReport", + OGC("ServiceException", str(message), **attributes), + version="1.3.0", ) @property @@ -129,7 +117,7 @@ def __init__(self, width=None, height=None, format=None, bgcolor=None, blank=Fal self.width = width if width > 0 else 256 self.height = height if height > 0 else 256 if "/" in format: - format = format[format.find("/") + 1:] + format = format[format.find("/") + 1 :] self.format = format or "jpeg" self.bgcolor = bgcolor or "white" self.blank = blank @@ -148,10 +136,11 @@ def encode_exception(self, message, code, locator=None): draw = ImageDraw.Draw(image) yoffset = 0 while len(message): - for i in xrange(len(message)): + for i in range(len(message)): part = message if i == 0 else message[:-i] - xsize, ysize = font.getsize(part) - print (i, xsize, ysize, part) + left, top, right, bottom = font.getbbox(part) + xsize = right - left + ysize = bottom - top if xsize < width: break draw.text((0, yoffset), part, font=font, fill="red") @@ -162,9 +151,9 @@ def encode_exception(self, message, code, locator=None): return image def serialize(self, image): - f = StringIO() + f = BytesIO() try: image.save(f, self.format) except (IOError, KeyError): - image.save(f, "jpeg") # Fallback solution + image.save(f, "jpeg") # Fallback solution return f.getvalue() diff --git a/eoxserver/services/ows/wms/v13/getcapabilities.py b/eoxserver/services/ows/wms/v13/getcapabilities.py index 1a3e3a785..fc151b63b 100644 --- a/eoxserver/services/ows/wms/v13/getcapabilities.py +++ b/eoxserver/services/ows/wms/v13/getcapabilities.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, implements diff --git a/eoxserver/services/ows/wms/v13/getfeatureinfo.py b/eoxserver/services/ows/wms/v13/getfeatureinfo.py index 21a0cbf4b..dcf7cbafb 100644 --- a/eoxserver/services/ows/wms/v13/getfeatureinfo.py +++ b/eoxserver/services/ows/wms/v13/getfeatureinfo.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from itertools import chain @@ -79,9 +79,9 @@ def handle(self, request): Trim("x", minx, maxx), Trim("y", miny, maxy), ), crs=crs) - if time: + if time: subsets.append(time) - + renderer = self.renderer root_group = lookup_layers(layers, subsets, renderer.suffixes) diff --git a/eoxserver/services/ows/wms/v13/getlegendgraphic.py b/eoxserver/services/ows/wms/v13/getlegendgraphic.py index 4795c73d1..3f3d9cca3 100644 --- a/eoxserver/services/ows/wms/v13/getlegendgraphic.py +++ b/eoxserver/services/ows/wms/v13/getlegendgraphic.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, implements, UniqueExtensionPoint from eoxserver.core.decoders import kvp, InvalidParameterException diff --git a/eoxserver/services/ows/wms/v13/getmap.py b/eoxserver/services/ows/wms/v13/getmap.py index 8e722ce6a..be1584c23 100644 --- a/eoxserver/services/ows/wms/v13/getmap.py +++ b/eoxserver/services/ows/wms/v13/getmap.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, implements, UniqueExtensionPoint diff --git a/eoxserver/services/ows/wps/context.py b/eoxserver/services/ows/wps/context.py index 0a223e778..6531f5f81 100644 --- a/eoxserver/services/ows/wps/context.py +++ b/eoxserver/services/ows/wps/context.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Base context class # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2016 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class ContextError(Exception): diff --git a/eoxserver/services/ows/wps/exceptions.py b/eoxserver/services/ows/wps/exceptions.py index 048e0c54d..e2cdc3a7f 100644 --- a/eoxserver/services/ows/wps/exceptions.py +++ b/eoxserver/services/ows/wps/exceptions.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013-2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class OWS10Exception(Exception): """ Base OWS 1.0 exception of the WPS 1.0.0 exceptions """ @@ -34,7 +34,7 @@ def __init__(self, code, locator, message): self.locator = locator Exception.__init__(self, message) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # All possible WPS 1.0.0 exceptions. For list of OWS exception used by WPS # see OGC 05-007r7 Table 38 and Table 62 @@ -73,7 +73,7 @@ class VersionNegotiationFailed(OWS10Exception): def __init__(self, message, locator): OWS10Exception.__init__(self, "VersionNegotiationFailed", locator, message) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Derived specific exceptions. # # Note that WPS 1.0.0 allows use of "vendor specific exception code" as locator diff --git a/eoxserver/services/ows/wps/interfaces.py b/eoxserver/services/ows/wps/interfaces.py index cf29e8139..9c81418a0 100644 --- a/eoxserver/services/ows/wps/interfaces.py +++ b/eoxserver/services/ows/wps/interfaces.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class AsyncBackendInterface(object): diff --git a/eoxserver/services/ows/wps/parameters/__init__.py b/eoxserver/services/ows/wps/parameters/__init__.py index 2d4d3683d..bd5d20556 100644 --- a/eoxserver/services/ows/wps/parameters/__init__.py +++ b/eoxserver/services/ows/wps/parameters/__init__.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS input and output parameters and data types # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from .base import Parameter from .literaldata import LiteralData diff --git a/eoxserver/services/ows/wps/parameters/allowed_values.py b/eoxserver/services/ows/wps/parameters/allowed_values.py index 62185cf08..58708a4a0 100644 --- a/eoxserver/services/ows/wps/parameters/allowed_values.py +++ b/eoxserver/services/ows/wps/parameters/allowed_values.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS Literal Data - allowed values # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from math import isinf try: diff --git a/eoxserver/services/ows/wps/parameters/base.py b/eoxserver/services/ows/wps/parameters/base.py index d1120b67f..fa5f0c2bc 100644 --- a/eoxserver/services/ows/wps/parameters/base.py +++ b/eoxserver/services/ows/wps/parameters/base.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS input and output parameters' base class # @@ -6,7 +6,7 @@ # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # pylint: disable=too-few-public-methods, too-many-arguments # NOTE: Currently, the inputs parameters are not allowed to be present diff --git a/eoxserver/services/ows/wps/parameters/bboxdata.py b/eoxserver/services/ows/wps/parameters/bboxdata.py index 9022fb883..9fc83b189 100644 --- a/eoxserver/services/ows/wps/parameters/bboxdata.py +++ b/eoxserver/services/ows/wps/parameters/bboxdata.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS Bounding-Box Data type # @@ -6,7 +6,7 @@ # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import re from itertools import chain @@ -34,7 +34,6 @@ from .data_types import Double from .crs import CRSType from .base import Parameter -from django.utils.six import string_types # pre-compiled regular expression used to eliminate repeated extra white-spaces _RE_MULTIWS = re.compile(r"\s+") @@ -178,7 +177,7 @@ def parse(self, raw_bbox): (raw_bbox.lower, raw_bbox.upper), raw_bbox.crs if raw_bbox.crs is not None else self.default_crs ) - elif isinstance(raw_bbox, string_types): + elif isinstance(raw_bbox, str): items = raw_bbox.split(',') dim = len(items)//2 lower = [self.dtype.parse(item) for item in items[0:dim]] diff --git a/eoxserver/services/ows/wps/parameters/codecs.py b/eoxserver/services/ows/wps/parameters/codecs.py index 9bedbedb9..534d3c86e 100644 --- a/eoxserver/services/ows/wps/parameters/codecs.py +++ b/eoxserver/services/ows/wps/parameters/codecs.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS Complex Data codecs (encoders/decoders) # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from base64 import ( standard_b64encode, standard_b64decode, urlsafe_b64encode, urlsafe_b64decode, diff --git a/eoxserver/services/ows/wps/parameters/complexdata.py b/eoxserver/services/ows/wps/parameters/complexdata.py index 2bd9eb951..84632d4c0 100644 --- a/eoxserver/services/ows/wps/parameters/complexdata.py +++ b/eoxserver/services/ows/wps/parameters/complexdata.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS Complex Data type # @@ -6,7 +6,7 @@ # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,37 +26,25 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # pylint: disable=too-few-public-methods, import json from os import remove from copy import deepcopy +from io import BytesIO, StringIO +from collections import OrderedDict -try: - from StringIO import StringIO - from cStringIO import StringIO as FastStringIO - BytesIO = StringIO -except ImportError: - from io import BytesIO - from io import StringIO - from io import StringIO as FastStringIO - -try: - # available in Python 2.7+ - from collections import OrderedDict -except ImportError: - from django.utils.datastructures import SortedDict as OrderedDict - +from django.utils.encoding import smart_str from lxml import etree + from .base import Parameter from .formats import Format -from django.utils.encoding import smart_str -from django.utils.six import string_types, text_type, itervalues, binary_type -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # complex data - data containers + class CDBase(object): """ Base class of the complex data container. @@ -222,7 +210,7 @@ def __init__(self, data='', *args, **kwargs): self.text_encoding = kwargs.get('text_encoding', None) def write(self, data): - if not isinstance(data, string_types): + if not isinstance(data, str): data = str(data) CDByteBuffer.write(self, data.encode('ascii')) @@ -231,7 +219,7 @@ def read(self, size=None): data = CDByteBuffer.read(self) else: data = CDByteBuffer.read(self, size) - if self.text_encoding not in ('ascii', 'utf-8'): # ASCII is a subset of UTF-8 + if self.text_encoding not in ('ascii', 'utf-8'): # ASCII is a subset of UTF-8 data = data.decode('ascii') if self.text_encoding is not None: data = data.encode(self.text_encoding) @@ -333,7 +321,8 @@ def __init__(self, *args, **kwargs): kwargs['remove_file'] = False CDFile.__init__(self, *args, **kwargs) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ + class ComplexData(Parameter): """ Complex-data parameter class @@ -364,7 +353,7 @@ def __init__(self, identifier, formats, *args, **kwargs): @property def default_format(self): """ Get default the default format. """ - return next(itervalues(self.formats)) + return next(iter(self.formats.values())) def get_format(self, mime_type, encoding=None, schema=None): """ Get format definition for the given mime-type and the optional @@ -408,12 +397,12 @@ def parse(self, data, mime_type, schema, encoding, **opt): # pylint: disable=redefined-variable-type parsed_data = CDTextBuffer(_unicode(data, text_encoding), **fattr) parsed_data.seek(0) - else: # generic binary byte-stream + else: # generic binary byte-stream parsed_data = CDByteBuffer(data, **fattr) if format_.encoding is not None: data_out = BytesIO() for chunk in format_.decode(parsed_data, **opt): - if isinstance(chunk, binary_type): + if isinstance(chunk, bytes): chunk = chunk.decode('utf-8') data_out.write(chunk) parsed_data = data_out @@ -445,17 +434,17 @@ def encode_xml(self, data): elif format_.is_json: return json.dumps(data, ensure_ascii=False) elif format_.is_text: - if not isinstance(data, string_types): + if not isinstance(data, str): data.seek(0) data = data.read() return data - else: # generic binary byte-stream + else: # generic binary byte-stream if format_.encoding is not None: data.seek(0) - data_out = FastStringIO() + data_out = StringIO() # data_out.write(str(data.data,'utf-8')) for chunk in format_.encode(data): - if isinstance(chunk, binary_type): + if isinstance(chunk, bytes): chunk = chunk.decode('utf-8') data_out.write(chunk) @@ -529,7 +518,7 @@ def _bytestring(data): def _unicode(data, encoding): - if isinstance(data, text_type): + if isinstance(data, str): return data elif isinstance(data, bytes): return smart_str(data, encoding) diff --git a/eoxserver/services/ows/wps/parameters/crs.py b/eoxserver/services/ows/wps/parameters/crs.py index f485c5c00..55f925865 100644 --- a/eoxserver/services/ows/wps/parameters/crs.py +++ b/eoxserver/services/ows/wps/parameters/crs.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # CRS data type. # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.resources.coverages.crss import ( asURL, fromURL, fromURN, fromShortCode, validateEPSGCode, parseEPSGCode, diff --git a/eoxserver/services/ows/wps/parameters/data_types.py b/eoxserver/services/ows/wps/parameters/data_types.py index 376c1d99d..1d8a2e6cd 100644 --- a/eoxserver/services/ows/wps/parameters/data_types.py +++ b/eoxserver/services/ows/wps/parameters/data_types.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Library of primitive data type classes. # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,27 +25,22 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -from datetime import datetime, date, time, timedelta -from django.utils.dateparse import parse_date, parse_datetime, parse_time, utc -from django.utils.six import PY2, PY3, string_types +from datetime import datetime, date, time, timedelta, timezone +from django.utils.dateparse import parse_date, parse_datetime, parse_time from django.utils.encoding import smart_str from eoxserver.core.util.timetools import parse_duration -try: - from datetime import timezone +utc = timezone.utc - # as this class will be deprecated in Django 3.1, offer a constructor - def FixedOffset(offset, name=None): - if isinstance(offset, timedelta): - pass - else: - offset = timedelta(minutes=offset) - return timezone(offset) if name is None else timezone(offset, name) -except ImportError: - from django.utils.timezone import FixedOffset +def FixedOffset(offset, name=None): + if isinstance(offset, timedelta): + pass + else: + offset = timedelta(minutes=offset) + return timezone(offset) if name is None else timezone(offset, name) class BaseType(object): @@ -53,10 +48,7 @@ class BaseType(object): This class defines the class interface. """ name = None # to be replaced by a name - if PY2: - dtype = str - elif PY3: - dtype = bytes + dtype = bytes zero = None # when applicable to be replaced by a proper zero value comparable = True # indicate whether the type can be compared (<,>,==) @@ -96,7 +88,7 @@ class Boolean(BaseType): @classmethod def parse(cls, raw_value): - if isinstance(raw_value, string_types): + if isinstance(raw_value, str): raw_value = smart_str(raw_value.lower()) if raw_value in ('1', 'true'): return True @@ -165,10 +157,7 @@ def sub(cls, value0, value1): class String(BaseType): """ Unicode character string literal data type class. """ name = "string" - if PY2: - dtype = unicode - elif PY3: - dtype = str + dtype = str encoding = 'utf-8' comparable = False # disabled although Python implements comparable strings @@ -386,30 +375,14 @@ def encode(self, value): # mapping of plain Python types to data type classes -if PY3: - - DTYPES = { - bytes: String, - str: String, - bool: Boolean, - int: Integer, - float: Double, - date: Date, - datetime: DateTime, - time: Time, - timedelta: Duration, - } -elif PY2: - - DTYPES = { - str: String, - unicode: String, - bool: Boolean, - int: Integer, - long: Integer, - float: Double, - date: Date, - datetime: DateTime, - time: Time, - timedelta: Duration, - } +DTYPES = { + bytes: String, + str: String, + bool: Boolean, + int: Integer, + float: Double, + date: Date, + datetime: DateTime, + time: Time, + timedelta: Duration, +} diff --git a/eoxserver/services/ows/wps/parameters/formats.py b/eoxserver/services/ows/wps/parameters/formats.py index 64e1f8cb7..33e564637 100644 --- a/eoxserver/services/ows/wps/parameters/formats.py +++ b/eoxserver/services/ows/wps/parameters/formats.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS Complex Data formats # @@ -6,7 +6,7 @@ # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from .codecs import CodecBase64, CodecRaw diff --git a/eoxserver/services/ows/wps/parameters/inputs.py b/eoxserver/services/ows/wps/parameters/inputs.py index f877ac697..6f9df09f2 100644 --- a/eoxserver/services/ows/wps/parameters/inputs.py +++ b/eoxserver/services/ows/wps/parameters/inputs.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Input objects used by the execute requests and responses # @@ -6,7 +6,7 @@ # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from .base import ParamMetadata diff --git a/eoxserver/services/ows/wps/parameters/literaldata.py b/eoxserver/services/ows/wps/parameters/literaldata.py index 89f882cb6..779fcf9e1 100644 --- a/eoxserver/services/ows/wps/parameters/literaldata.py +++ b/eoxserver/services/ows/wps/parameters/literaldata.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS Literal Data type # @@ -6,7 +6,7 @@ # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,20 +26,16 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -try: - # available in Python 2.7+ - from collections import OrderedDict -except ImportError: - from django.utils.datastructures import SortedDict as OrderedDict +from collections import OrderedDict + +from django.utils.encoding import smart_str from .base import Parameter from .data_types import BaseType, String, DTYPES from .allowed_values import BaseAllowed, AllowedAny, AllowedEnum from .units import UnitOfMeasure, UnitLinear -from django.utils.encoding import smart_str -from django.utils.six import text_type class LiteralData(Parameter): @@ -192,7 +188,7 @@ def parse(self, raw_value, uom=None, encoding="utf-8"): """ try: - if isinstance(raw_value, text_type): + if isinstance(raw_value, str): _value = raw_value elif isinstance(raw_value, str): _value = smart_str(raw_value, encoding) diff --git a/eoxserver/services/ows/wps/parameters/response_form.py b/eoxserver/services/ows/wps/parameters/response_form.py index e2abdfacb..6271d4160 100644 --- a/eoxserver/services/ows/wps/parameters/response_form.py +++ b/eoxserver/services/ows/wps/parameters/response_form.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Response form objects. # @@ -6,7 +6,7 @@ # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,14 +26,9 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -try: - # available in Python 2.7+ - from collections import OrderedDict -except ImportError: - from django.utils.datastructures import SortedDict as OrderedDict -from django.utils.six import iteritems +from collections import OrderedDict from .base import ParamMetadata @@ -102,10 +97,10 @@ def __init__(self, lineage=False, status=False, store_response=False): self.status = status self.store_response = store_response - def __reduce__(self): # NOTE: needed for correct async-WPS request pickling + def __reduce__(self): # NOTE: needed for correct async-WPS request pickling return ( self.__class__, (self.lineage, self.status, self.store_response), - None, None, iteritems(self) + None, None, self.items() ) def __str__(self): diff --git a/eoxserver/services/ows/wps/parameters/units.py b/eoxserver/services/ows/wps/parameters/units.py index b175329bd..d9894a7d4 100644 --- a/eoxserver/services/ows/wps/parameters/units.py +++ b/eoxserver/services/ows/wps/parameters/units.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS Literal Data - units of measure # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class UnitOfMeasure(object): """ Base unit of measure class. diff --git a/eoxserver/services/ows/wps/test_allowed_values.py b/eoxserver/services/ows/wps/test_allowed_values.py index 2287f152c..10d69cf74 100644 --- a/eoxserver/services/ows/wps/test_allowed_values.py +++ b/eoxserver/services/ows/wps/test_allowed_values.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS Literal Data - allowed values - debuging unit-tests # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # pylint: disable=missing-docstring from unittest import TestCase, main @@ -35,8 +35,8 @@ Integer, Double, String, Duration, Date, Time, DateTime, ) -from django.utils.six import text_type -#------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- + class BaseTestMixin(object): # pylint: disable=too-few-public-methods @@ -46,17 +46,18 @@ def test(self): self.assertTrue(self.domain.check(val)) self.assertTrue(val is self.domain.verify(val)) except: - print ("\n%s: value: %r" % (type(self).__name__, val)) + print("\n%s: value: %r" % (type(self).__name__, val)) raise for val in self.rejected: try: self.assertFalse(self.domain.check(val)) self.assertRaises(ValueError, self.domain.verify, val) except: - print ("\n%s: value: %r" % (type(self).__name__, val)) + print("\n%s: value: %r" % (type(self).__name__, val)) raise -#------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- + class TestAllowedAny(TestCase, BaseTestMixin): def setUp(self): @@ -70,7 +71,8 @@ def setUp(self): ] self.rejected = [] -#------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- + class TestAllowedEnumFloat(TestCase, BaseTestMixin): def setUp(self): @@ -126,7 +128,7 @@ def setUp(self): class TestAllowedEnumString3(TestCase, BaseTestMixin): def setUp(self): enum = ['John', 'James', 'Jeffrey', 'Jacob', 'Jerry'] - self.domain = AllowedEnum(enum, dtype=text_type) + self.domain = AllowedEnum(enum, dtype=str) self.accepted = ['John', 'Jacob', 'Jerry'] self.rejected = ['Alex', ''] @@ -202,7 +204,8 @@ def setUp(self): self.accepted = [vlist[1], Duration.parse(vlist[0])] self.rejected = [Duration.parse('P7DT15H8M')] -#------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- + class TestAllowedRangeFloat(TestCase, BaseTestMixin): def setUp(self): @@ -355,7 +358,8 @@ def setUp(self): 'P1Y', ] -#------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- + class TestAllowedRangeDiscrFloat(TestCase, BaseTestMixin): def setUp(self): @@ -379,7 +383,7 @@ def setUp(self): ) self.accepted = [ Duration.parse('PT2H'), - timedelta(0, 3*3600, 0), + timedelta(0, 3 * 3600, 0), 'PT4H', 'PT5H', 'PT2H0.000001S', @@ -430,7 +434,7 @@ def setUp(self): '2014-01-11T10:30Z', ] -#------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- class TestAllowedRangeCollectionFloat(TestCase, BaseTestMixin): @@ -450,7 +454,7 @@ def setUp(self): self.accepted = ['-inf', -100., -3, 2, 6, 300] self.rejected = ['nan', '+inf', 7, 3, -0.5, -5] -#------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- if __name__ == '__main__': diff --git a/eoxserver/services/ows/wps/test_data_types.py b/eoxserver/services/ows/wps/test_data_types.py index 522512fcc..aa1b73ecd 100644 --- a/eoxserver/services/ows/wps/test_data_types.py +++ b/eoxserver/services/ows/wps/test_data_types.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS Literal Data - data-types - unit-tests # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # pylint: disable=missing-docstring, line-too-long from unittest import TestCase, main @@ -35,7 +35,7 @@ Duration, Date, Time, DateTime, DateTimeTZAware, CRSType, ) -#------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- class BaseTestMixin(object): @@ -101,7 +101,7 @@ def testParseTimeZone(self): print ("\n%r != %r" % (res, dst)) raise -#------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- class TestDataTypeBool(TestCase, BaseTestMixin): def setUp(self): @@ -501,7 +501,7 @@ def setUp(self): "EPSG:0" ] -#------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- if __name__ == '__main__': main() diff --git a/eoxserver/services/ows/wps/util.py b/eoxserver/services/ows/wps/util.py index eb1c1908f..7651d0f92 100644 --- a/eoxserver/services/ows/wps/util.py +++ b/eoxserver/services/ows/wps/util.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS specific utilities. # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2016 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,21 +25,16 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from contextlib import closing from logging import getLogger - -try: - # available in Python 2.7+ - from collections import OrderedDict -except ImportError: - from django.utils.datastructures import SortedDict as OrderedDict +from urllib import parse, request, error +from collections import OrderedDict from django.conf import settings from django.utils.module_loading import import_string -from django.utils.six.moves.urllib import parse, request, error from eoxserver.core.util.multiparttools import iterate as iterate_multipart from eoxserver.services.ows.wps.config import ( @@ -109,6 +104,7 @@ def _resolve_http(self, href, body=None, headers=None): PROCESSES = None ASYNC_BACKENDS = None + def _setup_processes(): global PROCESSES specifiers = getattr( @@ -120,6 +116,7 @@ def _setup_processes(): for identifier in specifiers ] + def _setup_async_backends(): global ASYNC_BACKENDS specifiers = getattr( diff --git a/eoxserver/services/ows/wps/v10/describeprocess.py b/eoxserver/services/ows/wps/v10/describeprocess.py index 9addc9791..2f6f5481f 100644 --- a/eoxserver/services/ows/wps/v10/describeprocess.py +++ b/eoxserver/services/ows/wps/v10/describeprocess.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core.decoders import kvp, xml, typelist from eoxserver.services.ows.wps.util import get_processes diff --git a/eoxserver/services/ows/wps/v10/encoders/__init__.py b/eoxserver/services/ows/wps/v10/encoders/__init__.py index a5024fe2d..fd19d0937 100644 --- a/eoxserver/services/ows/wps/v10/encoders/__init__.py +++ b/eoxserver/services/ows/wps/v10/encoders/__init__.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS 1.0 XML encoders # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from .base import WPS10BaseXMLEncoder from .capabilities import WPS10CapabilitiesXMLEncoder diff --git a/eoxserver/services/ows/wps/v10/encoders/base.py b/eoxserver/services/ows/wps/v10/encoders/base.py index f51be9fc9..9603f6e6b 100644 --- a/eoxserver/services/ows/wps/v10/encoders/base.py +++ b/eoxserver/services/ows/wps/v10/encoders/base.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS 1.0 base XML encoder # @@ -6,7 +6,7 @@ # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core.util.xmltools import XMLEncoder from eoxserver.services.ows.wps.v10.util import ns_wps diff --git a/eoxserver/services/ows/wps/v10/encoders/capabilities.py b/eoxserver/services/ows/wps/v10/encoders/capabilities.py index 733592846..701bfd6be 100644 --- a/eoxserver/services/ows/wps/v10/encoders/capabilities.py +++ b/eoxserver/services/ows/wps/v10/encoders/capabilities.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS 1.0 Capabilities XML encoders # @@ -6,7 +6,7 @@ # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ #pylint: disable=bad-continuation from eoxserver.core.config import get_eoxserver_config diff --git a/eoxserver/services/ows/wps/v10/encoders/execute_response.py b/eoxserver/services/ows/wps/v10/encoders/execute_response.py index f274c0dae..968bcbd56 100644 --- a/eoxserver/services/ows/wps/v10/encoders/execute_response.py +++ b/eoxserver/services/ows/wps/v10/encoders/execute_response.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS 1.0 execute response XML encoder # @@ -6,7 +6,7 @@ # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,12 +26,11 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- -#pylint: disable=too-many-arguments, too-many-locals, bad-continuation +# ------------------------------------------------------------------------------ +# pylint: disable=too-many-arguments, too-many-locals, bad-continuation from lxml import etree from django.utils.timezone import now -from django.utils.six import itervalues from eoxserver.core.config import get_eoxserver_config from eoxserver.services.ows.common.config import CapabilitiesConfigReader @@ -80,7 +79,7 @@ def encode_response(self, results): "The processes execution completed successfully." )) outputs = [] - for result, prm, req in itervalues(results): + for result, prm, req in results.values(): outputs.append(_encode_output(result, prm, req)) elem.append(WPS("ProcessOutputs", *outputs)) return elem @@ -126,7 +125,8 @@ def encode_accepted(self): "ProcessAccepted", "The processes was accepted for execution." )) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ + def _encode_common_response(process, status_elem, inputs, raw_inputs, resp_doc): """Encode common execute response part shared by all specific responses.""" @@ -210,13 +210,13 @@ def _encode_output(data, prm, req): def _encode_input_reference(ref): """ Encode DataInputs/Reference element. """ - #TODO proper input reference encoding + # TODO proper input reference encoding return WPS("Reference", **{ns_xlink("href"): ref.href}) def _encode_output_reference(ref, prm): """ Encode ProcessOutputs/Reference element. """ - #TODO proper output reference encoding + # TODO proper output reference encoding mime_type = getattr(ref, 'mime_type', None) encoding = getattr(ref, 'encoding', None) schema = getattr(ref, 'schema', None) @@ -226,7 +226,7 @@ def _encode_output_reference(ref, prm): encoding = default_format.encoding schema = default_format.schema attr = { - #ns_xlink("href"): ref.href, + # ns_xlink("href"): ref.href, 'href': ref.href, } if mime_type: @@ -271,9 +271,9 @@ def _encode_bbox(data, prm): OWS("LowerCorner", lower), OWS("UpperCorner", upper), crs=crs, - #dimension="%d"%prm.dimension, + # dimension="%d"%prm.dimension, ) - #NOTE: Although derived from OWS BoundingBox the WPS (schema) does not + # NOTE: Although derived from OWS BoundingBox the WPS (schema) does not # allow the dimension attribute. diff --git a/eoxserver/services/ows/wps/v10/encoders/execute_response_raw.py b/eoxserver/services/ows/wps/v10/encoders/execute_response_raw.py index fdb93bc91..35a01e074 100644 --- a/eoxserver/services/ows/wps/v10/encoders/execute_response_raw.py +++ b/eoxserver/services/ows/wps/v10/encoders/execute_response_raw.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS 1.0 execute response raw encoder # @@ -6,7 +6,7 @@ # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,13 +26,10 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import types -try: - from StringIO import StringIO -except ImportError: - from io import StringIO +from io import StringIO from eoxserver.services.result import ( to_http_response, ResultItem, @@ -41,7 +38,6 @@ LiteralData, ComplexData, BoundingBoxData, ) from eoxserver.services.ows.wps.exceptions import InvalidOutputValueError -from django.utils.six import string_types, itervalues class WPS10ExecuteResponseRawEncoder(object): @@ -60,7 +56,7 @@ def __init__(self, resp_form): def encode_response(self, results): """Pack the raw execute response.""" outputs = [] - for data, prm, req in itervalues(results): + for data, prm, req in results.values(): if prm.identifier in self.resp_form: outputs.append(_encode_raw_output(data, prm, req)) @@ -71,7 +67,8 @@ def encode_response(self, results): return outputs -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ + class ResultAlt(ResultItem): """ Alternative implementation of the result buffer. The object can be @@ -83,8 +80,9 @@ def __init__(self, buf, content_type=None, filename=None, identifier=None, close=False, headers=None): # pylint: disable=too-many-arguments ResultItem.__init__(self, content_type, filename, identifier) - if isinstance(buf, string_types) or isinstance(buf, bytes): - self._file = StringIO(buf.decode('utf-8')) # make sure a byte string is passed + if isinstance(buf, str) or isinstance(buf, bytes): + # make sure a byte string is passed + self._file = StringIO(buf.decode('utf-8')) elif isinstance(buf, (tuple, list, types.GeneratorType)): tmp = StringIO() for chunk in buf: @@ -119,7 +117,7 @@ def chunked(self, chunksize): for chunk in iter(lambda: data_file.read(chunksize), ''): yield chunk -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ def _encode_raw_output(data, prm, req): @@ -130,7 +128,7 @@ def _encode_raw_output(data, prm, req): return _encode_raw_bbox(data, prm, req) elif isinstance(prm, ComplexData): return _encode_raw_complex(data, prm) - raise TypeError("Invalid output type! %r"%(prm)) + raise TypeError("Invalid output type! %r" % (prm)) def _encode_raw_literal(data, prm, req): @@ -149,7 +147,7 @@ def _encode_raw_literal(data, prm, req): def _encode_raw_bbox(data, prm, req): """ Encode a raw bounding box.""" content_type = "text/plain" if req.mime_type is None else req.mime_type - content_type = "%s; charset=utf-8"%content_type + content_type = "%s; charset=utf-8" % content_type try: encoded_data = prm.encode_kvp(data).encode('utf-8') except (ValueError, TypeError) as exc: diff --git a/eoxserver/services/ows/wps/v10/encoders/parameters.py b/eoxserver/services/ows/wps/v10/encoders/parameters.py index 146e3147b..a1c48bd00 100644 --- a/eoxserver/services/ows/wps/v10/encoders/parameters.py +++ b/eoxserver/services/ows/wps/v10/encoders/parameters.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS 1.0 parameters' XML encoders # @@ -6,7 +6,7 @@ # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,9 +26,8 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # pylint: disable=bad-continuation -from django.utils.six import itervalues from eoxserver.services.ows.wps.parameters import ( LiteralData, ComplexData, BoundingBoxData, @@ -183,7 +182,7 @@ def _encode_complex(prm, is_input): """ return NIL("ComplexData" if is_input else "ComplexOutput", NIL("Default", _encode_format(prm.default_format)), - NIL("Supported", *[_encode_format(f) for f in itervalues(prm.formats)]) + NIL("Supported", *[_encode_format(f) for f in prm.formats.values()]) ) diff --git a/eoxserver/services/ows/wps/v10/encoders/process_description.py b/eoxserver/services/ows/wps/v10/encoders/process_description.py index 8069d1d8f..66430cea4 100644 --- a/eoxserver/services/ows/wps/v10/encoders/process_description.py +++ b/eoxserver/services/ows/wps/v10/encoders/process_description.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # WPS 1.0 ProcessDescriptsions XML encoders # @@ -6,7 +6,7 @@ # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.services.ows.wps.v10.util import ( OWS, WPS, NIL, ns_wps, ns_xlink, ns_xml diff --git a/eoxserver/services/ows/wps/v10/exceptionhandler.py b/eoxserver/services/ows/wps/v10/exceptionhandler.py index 2dd075fa0..bbcac35ab 100644 --- a/eoxserver/services/ows/wps/v10/exceptionhandler.py +++ b/eoxserver/services/ows/wps/v10/exceptionhandler.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core import Component, implements from eoxserver.services.ows.interfaces import ExceptionHandlerInterface diff --git a/eoxserver/services/ows/wps/v10/execute.py b/eoxserver/services/ows/wps/v10/execute.py index 489416786..25e37aad2 100644 --- a/eoxserver/services/ows/wps/v10/execute.py +++ b/eoxserver/services/ows/wps/v10/execute.py @@ -1,10 +1,10 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from logging import getLogger diff --git a/eoxserver/services/ows/wps/v10/execute_decoder_common.py b/eoxserver/services/ows/wps/v10/execute_decoder_common.py index 55ddeef4e..dd483e86f 100644 --- a/eoxserver/services/ows/wps/v10/execute_decoder_common.py +++ b/eoxserver/services/ows/wps/v10/execute_decoder_common.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Execute - common decoder subroutines # @@ -6,7 +6,7 @@ # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ def parse_bool(raw_value): """ Parse boolean value. """ diff --git a/eoxserver/services/ows/wps/v10/execute_decoder_kvp.py b/eoxserver/services/ows/wps/v10/execute_decoder_kvp.py index 0e7faed2b..207de921b 100644 --- a/eoxserver/services/ows/wps/v10/execute_decoder_kvp.py +++ b/eoxserver/services/ows/wps/v10/execute_decoder_kvp.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Execute - KVP decoder # @@ -6,7 +6,7 @@ # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,9 +26,9 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -from django.utils.six.moves.urllib.parse import unquote_plus +from urllib.parse import unquote_plus from eoxserver.core.decoders import kvp from eoxserver.services.ows.wps.parameters import ( @@ -54,7 +54,7 @@ def _parse_inputs(raw_string): schema=param.get("schema") ) else: - #NOTE: KVP Bounding box cannot be safely detected and parsed. + # NOTE: KVP Bounding box cannot be safely detected and parsed. input_ = InputData( data=value, identifier=id_, @@ -123,7 +123,7 @@ def parse_query_string(query_string): class WPS10ExecuteKVPDecoder(kvp.Decoder): """ WPS 1.0 Execute HTTP/GET KVP request decoder. """ - #pylint: disable=too-few-public-methods + # pylint: disable=too-few-public-methods identifier = kvp.Parameter() @property @@ -145,11 +145,10 @@ def response_form(self): status=self._status, store_response=self._store_response ) - for output in self._outputs: # pylint: disable=not-an-iterable + for output in self._outputs: # pylint: disable=not-an-iterable resp_doc.set_output(output) return resp_doc - _inputs = kvp.Parameter("DataInputs", type=_parse_inputs, num="?") _outputs = kvp.Parameter( "ResponseDocument", type=_parse_outputs, num="?", default=() diff --git a/eoxserver/services/ows/wps/v10/execute_decoder_xml.py b/eoxserver/services/ows/wps/v10/execute_decoder_xml.py index 8efebaf0d..c6e6514c2 100644 --- a/eoxserver/services/ows/wps/v10/execute_decoder_xml.py +++ b/eoxserver/services/ows/wps/v10/execute_decoder_xml.py @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Execute - XML decoder # @@ -6,7 +6,7 @@ # Authors: Fabian Schindler # Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from lxml import etree from eoxserver.core.decoders import xml diff --git a/eoxserver/services/ows/wps/v10/execute_util.py b/eoxserver/services/ows/wps/v10/execute_util.py index 7e9197275..21e439025 100644 --- a/eoxserver/services/ows/wps/v10/execute_util.py +++ b/eoxserver/services/ows/wps/v10/execute_util.py @@ -4,7 +4,7 @@ # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2016 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,9 +24,8 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -from django.utils.six import iteritems, itervalues from eoxserver.services.ows.wps.util import OrderedDict from eoxserver.services.ows.wps.parameters import ( fix_parameter, LiteralData, BoundingBoxData, ComplexData, @@ -42,7 +41,7 @@ def parse_params(param_defs): """ Parse process's inputs/outputs parameter definitions. """ if isinstance(param_defs, dict): - param_defs = iteritems(param_defs) + param_defs = param_defs.items() return OrderedDict( (param.identifier, (name, param)) for name, param in ( (name, fix_parameter(name, param)) for name, param in param_defs @@ -68,7 +67,7 @@ def check_invalid_outputs(outputs, output_defs): def resolve_request_parameters(inputs, input_defs, request): """ Resolve request parameters. """ - for identifier, (_, input_def) in iteritems(input_defs): + for identifier, (_, input_def) in input_defs.items(): if isinstance(input_def, RequestParameter): inputs[identifier] = input_def.parse_request(request) return inputs @@ -79,7 +78,7 @@ def decode_raw_inputs(raw_inputs, input_defs, resolver): all given inputs. This also includes resolving of references. """ decoded_inputs = {} - for identifier, (name, input_def) in iteritems(input_defs): + for identifier, (name, input_def) in input_defs.items(): raw_value = raw_inputs.get(identifier) if isinstance(input_def, RequestParameter): value = raw_value @@ -118,7 +117,7 @@ def _decode_input(input_def, raw_value): raw_value.schema, raw_value.encoding, urlsafe=raw_value.asurl ) else: - raise TypeError("Unsupported parameter type %s!"%(type(input_def))) + raise TypeError("Unsupported parameter type %s!" % (type(input_def))) def _resolve_reference(input_ref, resolver): @@ -150,7 +149,7 @@ def decode_output_requests(response_form, output_defs): is passed as an input to the process """ output_requests = {} - for identifier, (name, output_def) in iteritems(output_defs): + for identifier, (name, output_def) in output_defs.items(): request = response_form.get_output(identifier) if isinstance(output_def, ComplexData): format_ = output_def.get_format( @@ -181,7 +180,7 @@ def pack_outputs(outputs, response_form, output_defs): # Normalize the outputs to a dictionary. if not isinstance(outputs, dict): if len(output_defs) == 1: - outputs = {list(itervalues(output_defs))[0][0]: outputs} + outputs = {list(output_defs.values())[0][0]: outputs} else: outputs = dict(outputs) # Pack the outputs to a tuple containing: @@ -189,7 +188,7 @@ def pack_outputs(outputs, response_form, output_defs): # - the process output declaration (ProcessDescription/Output) # - the output's requested form (RequestForm/Output) packed = OrderedDict() - for identifier, (name, output_def) in iteritems(output_defs): + for identifier, (name, output_def) in output_defs.items(): request = response_form.get_output(identifier) result = outputs.get(name) # TODO: Can we silently skip the missing outputs? Check the standard! diff --git a/eoxserver/services/ows/wps/v10/getcapabilities.py b/eoxserver/services/ows/wps/v10/getcapabilities.py index 696133e8d..33bacaaf1 100644 --- a/eoxserver/services/ows/wps/v10/getcapabilities.py +++ b/eoxserver/services/ows/wps/v10/getcapabilities.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from eoxserver.core.decoders import kvp, xml from eoxserver.services.ows.wps.util import get_processes diff --git a/eoxserver/services/ows/wps/v10/util.py b/eoxserver/services/ows/wps/v10/util.py index b14cacfb4..8038656e6 100644 --- a/eoxserver/services/ows/wps/v10/util.py +++ b/eoxserver/services/ows/wps/v10/util.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # pylint: disable=invalid-name, unused-import from lxml.builder import ElementMaker diff --git a/eoxserver/services/parameters.py b/eoxserver/services/parameters.py index 4df76f359..616c82e97 100644 --- a/eoxserver/services/parameters.py +++ b/eoxserver/services/parameters.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class RenderParameters(object): diff --git a/eoxserver/services/result.py b/eoxserver/services/result.py index 87fdee5de..e059eeda2 100644 --- a/eoxserver/services/result.py +++ b/eoxserver/services/result.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,19 +23,14 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import os import os.path -try: - from io import StringIO -except ImportError: - from cStringIO import StringIO - +from io import StringIO from uuid import uuid4 from django.http import HttpResponse -from django.utils.six import b from eoxserver.core.util import multiparttools as mp @@ -73,7 +68,7 @@ def content_type(self): """ Reterns a binary value of content-type if it is a string. """ if isinstance(self._content_type, str): - self._content_type = b(self._content_type) + self._content_type = self._content_type.encode() return self._content_type def __len__(self): @@ -160,7 +155,7 @@ def chunked(self, chunksize): i = 0 while i < size: - yield self.buf[i:i+chunksize] + yield self.buf[i:i + chunksize] i += chunksize @@ -183,8 +178,8 @@ def get_headers(result_item): yield b"Content-Type", result_item.content_type or b"application/octet-stream" if result_item.identifier: yield b"Content-Id", result_item.identifier.encode('utf-8') - if isinstance(result_item.filename, str): - result_item.filename = b(result_item.filename) + if isinstance(result_item.filename, str): + result_item.filename = result_item.filename.encode() if result_item.filename: yield ( b"Content-Disposition", b'attachment; filename="%s"' @@ -244,7 +239,7 @@ class to be used. It must be capable to work with iterators. This elif len(result_set) < 1 or result_set[0].content_type is None: boundary = None content_type = b"application/octet-stream" - headers = (('Content-Length', 0 ),) + headers = (('Content-Length', 0),) else: boundary = None @@ -261,8 +256,8 @@ def response_iterator(items, boundary=None): if boundary: yield boundary_str yield mp.CRLF.join( - b"%s: %s" % (key, value) - for key, value in get_headers(item) + b"%s: %s" % (key, value) + for key, value in get_headers(item) ) + mp.CRLFCRLF yield item.data if boundary: diff --git a/eoxserver/services/subset.py b/eoxserver/services/subset.py index 77af29b29..4f106a7af 100644 --- a/eoxserver/services/subset.py +++ b/eoxserver/services/subset.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import logging diff --git a/eoxserver/services/templatetags/services_extra.py b/eoxserver/services/templatetags/services_extra.py index 725e540a7..511b88012 100644 --- a/eoxserver/services/templatetags/services_extra.py +++ b/eoxserver/services/templatetags/services_extra.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2016 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # from https://gist.github.com/kulturlupenguen/69aec1259131b5619fb7 diff --git a/eoxserver/services/tests.py b/eoxserver/services/tests.py index f6ace8683..7316bb2d1 100644 --- a/eoxserver/services/tests.py +++ b/eoxserver/services/tests.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,18 +23,16 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import http from textwrap import dedent import importlib import sys - from django.conf import settings from django.test import TestCase, TransactionTestCase, Client, override_settings from django.contrib.gis.geos import Polygon, MultiPolygon -from django.utils.six import assertCountEqual, b from django.urls import clear_url_caches from eoxserver.core.util import multiparttools as mp @@ -47,12 +45,11 @@ import eoxserver.services.views - class MultipartTest(TestCase): """ Test class for multipart parsing/splitting """ - example_multipart = b(dedent("""\ + example_multipart = dedent("""\ MIME-Version: 1.0\r Content-Type: multipart/mixed; boundary=frontier\r \r @@ -67,7 +64,7 @@ class MultipartTest(TestCase): \r PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUgYm9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==\r --frontier-- - """)) + """).encode() def test_multipart_iteration(self): parsed = [ @@ -75,17 +72,35 @@ def test_multipart_iteration(self): for i in mp.iterate(self.example_multipart) ] - self.assertEqual([ - ({b"MIME-Version": b"1.0", b"Content-Type": b"multipart/mixed; boundary=frontier"}, b""), - ({b"Content-Type": b"text/plain"}, b"This is the body of the message."), - ({b"Content-Type": b"application/octet-stream", b"Content-Transfer-Encoding": b"base64"}, b"PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUgYm9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==") + self.assertEqual( + [ + ( + { + b"MIME-Version": b"1.0", + b"Content-Type": b"multipart/mixed; boundary=frontier" + }, + b"" + ), + ( + { + b"Content-Type": b"text/plain" + }, + b"This is the body of the message."), + ( + { + b"Content-Type": b"application/octet-stream", + b"Content-Transfer-Encoding": b"base64" + }, + b"PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGh" + b"pcyBpcyB0aGUgYm9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pg" + b"o8L2h0bWw+Cg==") ], parsed ) class ResultSetTestCase(TestCase): - example_multipart = b(dedent("""\ + example_multipart = dedent("""\ MIME-Version: 1.0\r Content-Type: multipart/mixed; boundary=frontier\r \r @@ -102,7 +117,7 @@ class ResultSetTestCase(TestCase): \r PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUgYm9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==\r --frontier-- - """)) + """).encode() def test_result_set_from_raw(self): result_set = result_set_from_raw_data(self.example_multipart) @@ -110,17 +125,17 @@ def test_result_set_from_raw(self): first = result_set[0] second = result_set[1] - + if isinstance(first.data, str): - first_data = b(first.data) + first_data = first.data.encode() else: first_data = first.data if isinstance(second.data, str): - second_data = b(second.data) + second_data = second.data.encode() else: second_data = second.data - + self.assertEqual( first_data, b"This is the body of the message." @@ -139,7 +154,8 @@ def test_result_set_from_raw(self): ) self.assertEqual( second_data, - b"PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUgYm9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==" + b"PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcy" + b"B0aGUgYm9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==" ) @@ -158,8 +174,8 @@ def setUp(self): axis_2_name='lat', axis_1_type=0, axis_2_type=0, - axis_1_offset=5/100, - axis_2_offset=5/100, + axis_1_offset=5 / 100, + axis_2_offset=5 / 100, ) coverage_type = models.CoverageType.objects.create(name="RGB") @@ -748,6 +764,7 @@ def test_slice_4_contains(self): self.make_subsets("2000-01-01T00:00:40Z"), "contains", ("H",) ) + class CachingTest(TestCase): def _reload_ows_views(self): # NOTE: we have to do this dance because the setting @@ -757,7 +774,6 @@ def _reload_ows_views(self): importlib.reload(sys.modules[settings.ROOT_URLCONF]) clear_url_caches() - def test_ows_view_not_cached_by_default(self): response = Client().get("/ows", {"service": "WMS", "request": "GetCapabilities"}) self.assertEqual(response.status_code, http.HTTPStatus.OK) @@ -766,7 +782,10 @@ def test_ows_view_not_cached_by_default(self): def test_ows_view_cached_if_configured(self): with override_settings(EOXS_RENDERER_CACHE_TIME="3"): self._reload_ows_views() - response = Client().get("/ows", {"service": "WMS", "request": "GetCapabilities"}) + response = Client().get( + "/ows", + {"service": "WMS", "request": "GetCapabilities"} + ) self._reload_ows_views() diff --git a/eoxserver/services/urls.py b/eoxserver/services/urls.py index 369719335..306e58e67 100644 --- a/eoxserver/services/urls.py +++ b/eoxserver/services/urls.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ try: from django.conf.urls import url as re_path diff --git a/eoxserver/services/views.py b/eoxserver/services/views.py index d5c9ef63e..d305a6981 100644 --- a/eoxserver/services/views.py +++ b/eoxserver/services/views.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ """This model contains Django views for the EOxServer software. Its main function is :func:`ows` which handles all incoming OWS requests""" @@ -35,13 +35,9 @@ from django.conf import settings from django.http import HttpResponse -try: - from django.http import StreamingHttpResponse -except: - class StreamingHttpResponse(object): - pass +from django.http import StreamingHttpResponse + from django.views.decorators.csrf import csrf_exempt -from django.utils.six import string_types from eoxserver.core import env from eoxserver.services.ows.component import ServiceComponent @@ -95,7 +91,7 @@ def ows(request): if isinstance(result, (HttpResponse, StreamingHttpResponse)): return result - elif isinstance(result, string_types): + elif isinstance(result, str): return HttpResponse(result) # convert result to a django response diff --git a/eoxserver/testing/xcomp.py b/eoxserver/testing/xcomp.py index 16c68cb80..e52ab2530 100644 --- a/eoxserver/testing/xcomp.py +++ b/eoxserver/testing/xcomp.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # simple tool comparing XML documents - powered by Python miniDOM # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,17 +25,15 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # """ Simple XML documets' comparator. """ import xml.dom.minidom as dom -from django.utils.six import string_types - -# define node types +# define node types ELEMENT_NODE = dom.Element.ELEMENT_NODE ATTRIBUTE_NODE = dom.Element.ATTRIBUTE_NODE TEXT_NODE = dom.Element.TEXT_NODE @@ -49,8 +47,8 @@ DOCUMENT_FRAGMENT_NODE = dom.Element.DOCUMENT_FRAGMENT_NODE NOTATION_NODE = dom.Element.NOTATION_NODE -# define note type to string conversion -NODE_DICT = { +# define note type to string conversion +NODE_DICT = { ELEMENT_NODE : "ELEMENT_NODE", ATTRIBUTE_NODE : "ATTRIBUTE_NODE", TEXT_NODE : "TEXT_NODE", @@ -63,183 +61,183 @@ DOCUMENT_TYPE_NODE : "DOCUMENT_TYPE_NODE", DOCUMENT_FRAGMENT_NODE : "DOCUMENT_FRAGMENT_NODE", NOTATION_NODE : "NOTATION_NODE", -} +} -# exceptions +# exceptions -class XMLError( Exception ) : +class XMLError( Exception ) : """ XML base error error """ -class XMLParseError( XMLError ) : +class XMLParseError( XMLError ) : """ XML parse error """ -class XMLMismatchError( XMLError ) : - """ XML mismatch error """ +class XMLMismatchError( XMLError ) : + """ XML mismatch error """ -#------------------------------------------------------------------------------- -# low level utilities +# ------------------------------------------------------------------------------ +# low level utilities -def _getNodeName( node ) : +def _getNodeName( node ) : """ get full node name in '{namespace}tagName' format """ - if ( node.namespaceURI is None ) : + if ( node.namespaceURI is None ) : return node.nodeName - else : - return "{%s}%s"%( node.namespaceURI , node.localName ) + else : + return "{%s}%s"%( node.namespaceURI , node.localName ) def _packName( pair ) : - """ pack the (,) tuple to curly bracket notation - {} """ - if ( pair[0] is None ) : - return pair[1] + """ pack the (,) tuple to curly bracket notation + {} """ + if ( pair[0] is None ) : + return pair[1] else : return "{%s}%s"%(pair[0],pair[1]) -def _skipIgnorable( node , path ) : - """ get node sibling skipping empty text nodes and comments """ +def _skipIgnorable( node , path ) : + """ get node sibling skipping empty text nodes and comments """ - while ( node is not None ) : - # expected nodes - return immediatelly - if node.nodeType in (ELEMENT_NODE,CDATA_SECTION_NODE): break - # special treatment of text nodes - ignore blank text - if node.nodeType == TEXT_NODE : - # ignore blank text - if 0 < len( node.wholeText.strip() ) : break - # unexpected nodes - raise exception + while ( node is not None ) : + # expected nodes - return immediatelly + if node.nodeType in (ELEMENT_NODE,CDATA_SECTION_NODE): break + # special treatment of text nodes - ignore blank text + if node.nodeType == TEXT_NODE : + # ignore blank text + if 0 < len( node.wholeText.strip() ) : break + # unexpected nodes - raise exception if node.nodeType in (ATTRIBUTE_NODE,DOCUMENT_NODE,DOCUMENT_FRAGMENT_NODE, - NOTATION_NODE,ENTITY_REFERENCE_NODE,ENTITY_NODE,DOCUMENT_TYPE_NODE): - raise XMLParseError("Unexpected child node '%s' ! PATH='%s'" % (NODE_DICT[node.nodeType],path)) - # the rest is just ignored + NOTATION_NODE,ENTITY_REFERENCE_NODE,ENTITY_NODE,DOCUMENT_TYPE_NODE): + raise XMLParseError("Unexpected child node '%s' ! PATH='%s'" % (NODE_DICT[node.nodeType],path)) + # the rest is just ignored #if node.nodeType in (COMMENT_NODE,PROCESSING_INSTRUCTION_NODE) : pass - node = node.nextSibling + node = node.nextSibling - return node + return node -def _compareAttributes( a0 , a1 , level , path , verbose = False ) : +def _compareAttributes( a0 , a1 , level , path , verbose = False ) : - # both nodes have no attributes - if ( a0 is None ) and ( a1 is None ) : return + # both nodes have no attributes + if ( a0 is None ) and ( a1 is None ) : return - #attribute mismatch + #attribute mismatch if ( a0 is None ) or ( a1 is None ) : - raise XMLMismatchError("Attribute mismatch! PATH=\"%s\""%path) + raise XMLMismatchError("Attribute mismatch! PATH=\"%s\""%path) - # get list of attributes and filter-out namespace definitions - isNotNS = lambda v : ( v[0][0] != "http://www.w3.org/2000/xmlns/" ) + # get list of attributes and filter-out namespace definitions + isNotNS = lambda v : ( v[0][0] != "http://www.w3.org/2000/xmlns/" ) packName = lambda v : ( _packName(v[0]) , v[1].strip() ) - items0 = sorted( map( packName , filter( isNotNS , a0.itemsNS() ) ) ) - items1 = sorted( map( packName , filter( isNotNS , a1.itemsNS() ) ) ) + items0 = sorted( map( packName , filter( isNotNS , a0.itemsNS() ) ) ) + items1 = sorted( map( packName , filter( isNotNS , a1.itemsNS() ) ) ) - if len( items0 ) != len( items0 ) : - if verbose : + if len( items0 ) != len( items0 ) : + if verbose : for item in items0 : print (" < \t %s@%s=\"%s\"" %( path , item[0] , item[1] )) for item in items1 : print (" > \t %s@%s=\"%s\"" %( path , item[0] , item[1] )) raise XMLMismatchError("Attribute count mismatch! PATH=\"%s\""%path) - for pair in zip( items0 , items1 ) : - if verbose : - print (" < \t %s@%s=\"%s\"" %( path , pair[0][0] , pair[0][1] )) + for pair in zip( items0 , items1 ) : + if verbose : + print (" < \t %s@%s=\"%s\"" %( path , pair[0][0] , pair[0][1] )) print (" > \t %s@%s=\"%s\"" %( path , pair[1][0] , pair[1][1] )) - if ( pair[0] != pair[1]) : + if ( pair[0] != pair[1]) : raise XMLMismatchError("Attribute mismatch! PATH=\"%s\""%path) -def _compareNode( n0 , n1 , level = 0 , path = "/" , verbose = False ) : +def _compareNode( n0 , n1 , level = 0 , path = "/" , verbose = False ) : """ compare DOM node or element subtree """ - + #nn0 , nn1 = _getNodeName( n0 ), _getNodeName( n1 ) nn0 , nn1 = n0.nodeName, n1.nodeName - path0 = "%s/%s"%( path , nn0 ) if level > 1 else "/%s"%nn0 if level == 1 else _getNodeName( n0 ) + path0 = "%s/%s"%( path , nn0 ) if level > 1 else "/%s"%nn0 if level == 1 else _getNodeName( n0 ) path1 = "%s/%s"%( path , nn1 ) if level > 1 else "/%s"%nn1 if level == 1 else _getNodeName( n0 ) - if verbose : - print ("< \t %s" %( path0 )) + if verbose : + print ("< \t %s" %( path0 )) print ("> \t %s" %( path1 )) - - # compare node name and node type - if (( n0.nodeType != n1.nodeType ) - or ( _getNodeName( n0 ) != _getNodeName( n1 ) )): - raise XMLMismatchError("Node mismatch! PATH0=\"%s\" vs. PATH1=\"%s\""%(path0,path1)) - - # compare attributes - _compareAttributes( n0.attributes , n1.attributes , level , path0 , verbose ) - - # in case of text-nodes and CDATA section check the content - if n0.nodeType == TEXT_NODE : - if verbose : + + # compare node name and node type + if (( n0.nodeType != n1.nodeType ) + or ( _getNodeName( n0 ) != _getNodeName( n1 ) )): + raise XMLMismatchError("Node mismatch! PATH0=\"%s\" vs. PATH1=\"%s\""%(path0,path1)) + + # compare attributes + _compareAttributes( n0.attributes , n1.attributes , level , path0 , verbose ) + + # in case of text-nodes and CDATA section check the content + if n0.nodeType == TEXT_NODE : + if verbose : print (" < TEXT: \t \"%s\"" % n0.wholeText.strip()) print (" > TEXT: \t \"%s\"" % n1.wholeText.strip()) - if n0.wholeText.strip() != n1.wholeText.strip() : - raise XMLMismatchError("Text mismatch! PATH=\"%s\""%(path)) - return + if n0.wholeText.strip() != n1.wholeText.strip() : + raise XMLMismatchError("Text mismatch! PATH=\"%s\""%(path)) + return - if n0.nodeType == CDATA_SECTION_NODE : - if verbose : + if n0.nodeType == CDATA_SECTION_NODE : + if verbose : print (" < CDATA: \t \"%s\"" % n0.wholeText) print (" > CDATA: \t \"%s\"" % n1.wholeText) - if n0.wholeText != n1.wholeText : - raise XMLMismatchError("CDATA mismatch! PATH=\"%s\""%(path)) - return + if n0.wholeText != n1.wholeText : + raise XMLMismatchError("CDATA mismatch! PATH=\"%s\""%(path)) + return + - # get first child nn0 = _skipIgnorable( n1.firstChild , path ) nn1 = _skipIgnorable( n0.firstChild , path ) - while ( nn0 is not None ) and ( nn1 is not None ) : - # sublevel comparison - _compareNode( nn0 , nn1 , level+1 , path0 , verbose ) - #get next sibling + while ( nn0 is not None ) and ( nn1 is not None ) : + # sublevel comparison + _compareNode( nn0 , nn1 , level+1 , path0 , verbose ) + #get next sibling nn0 = _skipIgnorable( nn0.nextSibling , path ) nn1 = _skipIgnorable( nn1.nextSibling , path ) - # make sure there are no remaining nodes - if not (( nn0 is None ) and ( nn1 is None )) : + # make sure there are no remaining nodes + if not (( nn0 is None ) and ( nn1 is None )) : raise XMLMismatchError("Childern count mismatch! PATH=\"%s\""%path0) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -def xmlCompareDOMs( xml0 , xml1 , verbose = False ) : +def xmlCompareDOMs( xml0 , xml1 , verbose = False ) : """ Compare two XML documents passed as DOM trees (xml.dom.minidom).""" - return _compareNode( xml0 , xml1 , verbose = verbose ) + return _compareNode( xml0 , xml1 , verbose = verbose ) -def xmlCompareStrings( str0 , str1 , verbose = False ) : - """ Compare two XML documents passed as strings. """ +def xmlCompareStrings( str0 , str1 , verbose = False ) : + """ Compare two XML documents passed as strings. """ - def parse( src , label ) : - try : - return dom.parseString( src ) - except Exception as e : - raise XMLParseError("Failed to parse %s XML string! %s" % ( label , str(e) )) + def parse( src , label ) : + try : + return dom.parseString( src ) + except Exception as e : + raise XMLParseError("Failed to parse %s XML string! %s" % ( label , str(e) )) - return xmlCompareDOMs( parse(str0,"the first") , parse(str1,"the second") , verbose ) + return xmlCompareDOMs( parse(str0,"the first") , parse(str1,"the second") , verbose ) -def xmlCompareFiles( src0 , src1 , verbose = False ) : - """ Compare two XML documents passed as filenames, file or file-like objects.""" +def xmlCompareFiles( src0 , src1 , verbose = False ) : + """ Compare two XML documents passed as filenames, file or file-like objects.""" - def parseFileName( src ) : - try : - with open( src ) as fid : - return dom.parse( fid ) - except Exception as e : - raise XMLParseError("Failed to parse the \"%s\" file! %s" % ( src , str(e) )) + def parseFileName( src ) : + try : + with open( src ) as fid : + return dom.parse( fid ) + except Exception as e : + raise XMLParseError("Failed to parse the \"%s\" file! %s" % ( src , str(e) )) - def parseFileObj( src , label ) : - try : - return dom.parse( src ) - except Exception as e : - raise XMLParseError("Failed to parse the %s XML file(-like) object! %e" % ( label , str(e) )) + def parseFileObj( src , label ) : + try : + return dom.parse( src ) + except Exception as e : + raise XMLParseError("Failed to parse the %s XML file(-like) object! %e" % ( label , str(e) )) - def parse( src , label ) : - return parseFileName( src ) if ( type(src) in string_types ) else parseFileObj( src , label ) + def parse( src , label ) : + return parseFileName( src ) if ( type(src) == str ) else parseFileObj( src , label ) - return xmlCompareDOMs( parse(src0,"the first") , parse(src1,"the second") , verbose ) + return xmlCompareDOMs( parse(src0,"the first") , parse(src1,"the second") , verbose ) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ diff --git a/eoxserver/views.py b/eoxserver/views.py index 7959244ff..877906a78 100644 --- a/eoxserver/views.py +++ b/eoxserver/views.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2012 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from django.shortcuts import render from django.template import RequestContext diff --git a/eoxserver/webclient/admin.py b/eoxserver/webclient/admin.py index 3694d8401..8f0482307 100644 --- a/eoxserver/webclient/admin.py +++ b/eoxserver/webclient/admin.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from django.contrib.gis import admin diff --git a/eoxserver/webclient/migrations/0003_alter_extra_id.py b/eoxserver/webclient/migrations/0003_alter_extra_id.py new file mode 100644 index 000000000..a3324f2bf --- /dev/null +++ b/eoxserver/webclient/migrations/0003_alter_extra_id.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2 on 2025-04-18 15:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('webclient', '0002_extra_fields'), + ] + + operations = [ + migrations.AlterField( + model_name='extra', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + ] diff --git a/eoxserver/webclient/models.py b/eoxserver/webclient/models.py index b9ce24d25..126b213f3 100644 --- a/eoxserver/webclient/models.py +++ b/eoxserver/webclient/models.py @@ -1,9 +1,9 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2014 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from django.db import models diff --git a/requirements.txt b/requirements.txt index 5991b1543..92cd18bbe 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,18 +1,15 @@ -django<4 -python-dateutil +django==5.2.* django-model-utils<5.0.0 -django-utils-six==2.0 -django-prometheus -tzdata -zipstream -psycopg2 -lxml +django-prometheus==2.3.* +zipstream==1.1.* +psycopg2==2.9.* +lxml==5.4.* pycql==0.0.8 -matplotlib +matplotlib==3.10.* numpy<2.0.0 pyows>=0.2.6 python-keystoneclient<6.0.0 python-swiftclient<5.0.0 -jsonfield -gunicorn -mapscript +gunicorn==23.0.* +mapscript==8.0.* +jsonfield==3.1.* \ No newline at end of file diff --git a/setup.py b/setup.py index 1840b0ce2..aa909a154 100644 --- a/setup.py +++ b/setup.py @@ -11,9 +11,13 @@ ] try: - gdal_version = subprocess.check_output(['gdal-config','--version']).decode('utf-8').strip() + gdal_version = subprocess.check_output( + ['gdal-config', '--version'] + ).decode('utf-8').strip() except FileNotFoundError: - gdal_version = subprocess.check_output(['gdalinfo','--version']).decode('utf-8').split(' ')[1].strip(',') + gdal_version = subprocess.check_output( + ['gdalinfo', '--version'] + ).decode('utf-8').split(' ')[1].strip(',') install_requires.append(f'gdal=={gdal_version}') diff --git a/tools/atp_demo.py b/tools/atp_demo.py index b6c4d85be..82faa7bd6 100755 --- a/tools/atp_demo.py +++ b/tools/atp_demo.py @@ -1,31 +1,31 @@ #!/usr/bin/env python -#----------------------------------------------------------------------- +# ---------------------------------------------------------------------- # -# Description: +# Description: # -# asynchronous task processing - simple test task feed +# asynchronous task processing - simple test task feed # -# Quick Start: +# Quick Start: # -# 1) set PYTHONPATH env.var to point to both: -# - EOxServer installation -# - EOxServer (configured) instance -# 2) optionally set also DJANGO_SETTINGS_MODULE env.var -# 3) run this script +# 1) set PYTHONPATH env.var to point to both: +# - EOxServer installation +# - EOxServer (configured) instance +# 2) optionally set also DJANGO_SETTINGS_MODULE env.var +# 3) run this script # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- -# Copyright (C) 2011 Iguassu Software Systems, a.s +# ------------------------------------------------------------------------------ +# Copyright (C) 2011 Iguassu Software Systems, a.s # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all @@ -38,8 +38,8 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- -# Step 1 - Handler subroutine +# ------------------------------------------------------------------------------ +# Step 1 - Handler subroutine def handler( taskStatus , input ) : """ example ATP handler subroutine """ @@ -55,13 +55,13 @@ def handler( taskStatus , input ) : # store the response and terminate taskStatus.storeResponse( str(sum) , "text/plain" ) -#------------------------------------------------------------------------------- -# make sure the following commands are not -# executed while included as module +# ------------------------------------------------------------------------------ +# make sure the following commands are not +# executed while included as module -if __name__ == "__main__" : +if __name__ == "__main__" : - # imports + # imports import time from eoxserver.resources.processes.tracker import \ @@ -69,20 +69,20 @@ def handler( taskStatus , input ) : getTaskStatusByIdentifier, getTaskLog, \ getTaskResponse, deleteTaskByIdentifier - # delete previous task if exists - try : + # delete previous task if exists + try : deleteTaskByIdentifier( "SequenceSum" , "Task001" ) - except : pass + except : pass -#------------------------------------------------------------------------------- -# Step 2 - task registration +# ------------------------------------------------------------------------------ +# Step 2 - task registration registerTaskType( "SequenceSum" , "tools.atp_demo.handler" , 60 , 600 , 3 ) -#------------------------------------------------------------------------------- -# Step 3 - new task creation - +# ------------------------------------------------------------------------------ +# Step 3 - new task creation + while True : try: enqueueTask( "SequenceSum" , "Task001" , (1,2,3,4,5) ) @@ -91,8 +91,8 @@ def handler( taskStatus , input ) : print ("QueueFull!") time.sleep( 5 ) -#------------------------------------------------------------------------------- -# Step 4 - polling task status +# ------------------------------------------------------------------------------ +# Step 4 - polling task status while True : status = getTaskStatusByIdentifier( "SequenceSum" , "Task001" ) @@ -100,22 +100,22 @@ def handler( taskStatus , input ) : if status[1] in ( "FINISHED" , "FAILED" ) : break time.sleep( 5 ) -#------------------------------------------------------------------------------- -# Step 5 - getting the logged task history +# ------------------------------------------------------------------------------ +# Step 5 - getting the logged task history print ("Processing history:") for rec in getTaskLog( "SequenceSum" , "Task001" ) : print ("-" , rec[0] , "Status: " , rec[1][1] , "\t Message: %s"%rec[2] if rec[2] else "") -#------------------------------------------------------------------------------- -# Step 6 - getting result +# ------------------------------------------------------------------------------ +# Step 6 - getting result if status[1] == "FINISHED" : print ("Result: " , getTaskResponse( "SequenceSum" , "Task001" )) -#------------------------------------------------------------------------------- -# Step 7 - removing task +# ------------------------------------------------------------------------------ +# Step 7 - removing task deleteTaskByIdentifier( "SequenceSum" , "Task001" ) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ diff --git a/tools/atp_test.py b/tools/atp_test.py index eee21ed4f..09176ef10 100755 --- a/tools/atp_test.py +++ b/tools/atp_test.py @@ -1,31 +1,31 @@ #!/usr/bin/env python -#----------------------------------------------------------------------- +# ---------------------------------------------------------------------- # -# Description: +# Description: # -# asynchronous task processing - simple test task feed +# asynchronous task processing - simple test task feed # -# Quick Start: +# Quick Start: # -# 1) set PYTHONPATH env.var to point to both: -# - EOxServer installation -# - EOxServer (configured) instance -# 2) optionally set also DJANGO_SETTINGS_MODULE env.var -# 3) run this script +# 1) set PYTHONPATH env.var to point to both: +# - EOxServer installation +# - EOxServer (configured) instance +# 2) optionally set also DJANGO_SETTINGS_MODULE env.var +# 3) run this script # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- -# Copyright (C) 2011 Iguassu Software Systems, a.s +# ------------------------------------------------------------------------------ +# Copyright (C) 2011 Iguassu Software Systems, a.s # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all @@ -38,51 +38,51 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- -# imports +# ------------------------------------------------------------------------------ +# imports import os import sys -import uuid -import time +import uuid +import time try: # Python 2 xrange except NameError: # Python 3, xrange is now named range xrange = range -#---------------------------------------------------------------------- -#number of test tasks +# --------------------------------------------------------------------- +#number of test tasks N=100 -#---------------------------------------------------------------------- +# --------------------------------------------------------------------- -# default django settings module +# default django settings module DJANGO_SETTINGS_DEFAULT = "settings" os.environ["DJANGO_SETTINGS_MODULE"] = os.environ.get("DJANGO_SETTINGS_MODULE",DJANGO_SETTINGS_DEFAULT) -# setup search paths +# setup search paths -#paths = [] -#paths = [ +#paths = [] +#paths = [ # "/home/test/o3s/sandbox_wcst" , -# "/home/test/o3s/sandbox_wcst_instance" ] -#for path in paths : +# "/home/test/o3s/sandbox_wcst_instance" ] +#for path in paths : -for path in sys.argv[1:] : +for path in sys.argv[1:] : print (path ) if path not in sys.path: sys.path.append(path) -#---------------------------------------------------------------------- -# imports +# --------------------------------------------------------------------- +# imports from eoxserver.resources.processes.tracker import QueueFull, registerTaskType, enqueueTask -#---------------------------------------------------------------------- -# register new task handler +# --------------------------------------------------------------------- +# register new task handler PROCESS_CLASS="TEST-PROCESS" ASYNC_HANDLER="tools.atp_test.testHandler" @@ -91,68 +91,68 @@ registerTaskType( PROCESS_CLASS , ASYNC_HANDLER , ASYNC_TIMEOUT , ASYNC_TIMERET ) -#---------------------------------------------------------------------- -# async handler +# --------------------------------------------------------------------- +# async handler def testHandler( taskStatus , param ) : print ("HANDLER:" , param ) - # change status + # change status #taskStatus.setSuccess() -#---------------------------------------------------------------------- +# --------------------------------------------------------------------- -# optimal wait time +# optimal wait time -WAIT_TIME = ( 0.05 , 0.1 , 0.2 , 0.4 , 0.8 , 1.6 , 3.2 , 6.4 , 12.8 ) +WAIT_TIME = ( 0.05 , 0.1 , 0.2 , 0.4 , 0.8 , 1.6 , 3.2 , 6.4 , 12.8 ) -def getWaitTime(idx ) : +def getWaitTime(idx ) : if ( idx >= len( WAIT_TIME ) ) : return WAIT_TIME[-1] - return WAIT_TIME[idx] + return WAIT_TIME[idx] -# enqueue task +# enqueue task -def testEnqueue( param ) : +def testEnqueue( param ) : - cnt = 0 ; + cnt = 0 ; tid = "test_%s"%uuid.uuid4().hex - while True : - - try: + while True : - # enqueue task for execution + try: + + # enqueue task for execution enqueueTask( PROCESS_CLASS , tid , param ) - - print ("ENQUEUE: %s" % tid , param) - - break - except QueueFull : # retry if queue full + print ("ENQUEUE: %s" % tid , param) + + break + + except QueueFull : # retry if queue full - print (" --- QueueFull #%i - sleep: %g s"%( cnt + 1 , getWaitTime(cnt) )) + print (" --- QueueFull #%i - sleep: %g s"%( cnt + 1 , getWaitTime(cnt) )) - time.sleep(getWaitTime(cnt)) + time.sleep(getWaitTime(cnt)) - cnt += 1 - - continue + cnt += 1 + continue -if __name__ == "__main__" : + +if __name__ == "__main__" : from eoxserver.core.system import System - # initialize the system + # initialize the system System.init() - for i in xrange(N) : - - testEnqueue("%6.6u"%i) + for i in xrange(N) : + + testEnqueue("%6.6u"%i) - #time.sleep(0.1) + #time.sleep(0.1) diff --git a/tools/eoxs_configure_centos.sh b/tools/eoxs_configure_centos.sh index ff44fa119..6cc86a7ef 100755 --- a/tools/eoxs_configure_centos.sh +++ b/tools/eoxs_configure_centos.sh @@ -1,27 +1,27 @@ -#!/bin/sh -#----------------------------------------------------------------------- +#!/bin/sh +# ---------------------------------------------------------------------- # -# Description: +# Description: # -# Automatic installation and configuration on CentOS -# (applicable also to RHEL and its clones). +# Automatic installation and configuration on CentOS +# (applicable also to RHEL and its clones). # -# The script creates and configures EOxServer instance. -# set the instance name as the first argument. +# The script creates and configures EOxServer instance. +# set the instance name as the first argument. # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all @@ -34,13 +34,13 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -set -x -set -e +set -x +set -e -#------------------------------------------------------------------------------- -# if not set the default HOSTNAME is used +# ------------------------------------------------------------------------------ +# if not set the default HOSTNAME is used #HOSTNAME= INSTANCE=${1:-"instance00"} @@ -66,40 +66,40 @@ PG_HBA="/var/lib/pgsql/data/pg_hba.conf" MNGCMD="${INSTROOT}/${INSTANCE}/manage.py" SOCKET_PREFIX="run/wsgi" -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -if [ -z "$HOSTNAME" ] -then +if [ -z "$HOSTNAME" ] +then echo "Set the HOSTNAME variable!" 1>&2 - exit 1 -fi + exit 1 +fi -#------------------------------------------------------------------------------- -# 4 create instance +# ------------------------------------------------------------------------------ +# 4 create instance if [ -d "$INSTROOT/$INSTANCE" ] then echo "Instance directory: $INSTROOT/$INSTANCE" 1>&2 echo "Instance directory exists! The instance seems to exists already." 1>&2 - exit 1 + exit 1 fi # ver.: 0.2 -#sudo -u eoxserver eoxserver-admin.py create_instance "$INSTANCE" -d "$INSTROOT" +#sudo -u eoxserver eoxserver-admin.py create_instance "$INSTANCE" -d "$INSTROOT" # ver.: 0.3 sudo -u eoxserver mkdir -p "$INSTROOT/$INSTANCE" -sudo -u eoxserver eoxserver-admin.py create_instance "$INSTANCE" "$INSTROOT/$INSTANCE" +sudo -u eoxserver eoxserver-admin.py create_instance "$INSTANCE" "$INSTROOT/$INSTANCE" -#------------------------------------------------------------------------------- -# 5 DB setup part 2 +# ------------------------------------------------------------------------------ +# 5 DB setup part 2 -# 5.1 - create DB +# 5.1 - create DB sudo -u postgres psql -q -c "CREATE USER $DBUSER WITH ENCRYPTED PASSWORD '$DBPASSWD' NOSUPERUSER NOCREATEDB NOCREATEROLE ;" sudo -u postgres psql -q -c "CREATE DATABASE $DBNAME WITH OWNER $DBUSER TEMPLATE template_postgis ENCODING 'UTF-8' ;" -# prepend to the beginning of the acess list -sudo -u postgres ex "$PG_HBA" <' $F` ] - then + if [ 0 -lt `grep -c '^[ ]*' $F` ] + then CONF=$F - break + break fi done -#if the virtual host is not present - create one +#if the virtual host is not present - create one if [ -z "$CONF" ] then CONF="$CONF_DEFAULT" - echo "Default virtual host not located creting own one in: $CONF" + echo "Default virtual host not located creting own one in: $CONF" cat >"$CONF" < END else - echo "Default virtual host located in: $CONF" + echo "Default virtual host located in: $CONF" fi -# insert the configuration to the virtual host +# insert the configuration to the virtual host ex "$CONF" </a @@ -210,7 +210,7 @@ ex "$CONF" < - # static content + # static content Alias $INSTSTAT_URL "$INSTSTAT_DIR" Options -MultiViews +FollowSymLinks @@ -222,29 +222,29 @@ ex "$CONF" <> /etc/httpd/conf.d/wsgi.conf + echo "WSGISocketPrefix $SOCKET_PREFIX" >> /etc/httpd/conf.d/wsgi.conf fi -# set the service url +# set the service url sudo -u eoxserver ex "$EOXSCONF" < # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all @@ -34,12 +34,12 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -set -x -set -e +set -x +set -e -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ HTTPUSER="apache" INSTUSER="eoxserver" @@ -48,14 +48,14 @@ INSTROOT="/srv/${INSTUSER}" #DATAROOT="/srv/${DATAUSER}" PG_HBA="/var/lib/pgsql/data/pg_hba.conf" -#------------------------------------------------------------------------------- -# 1 installation +# ------------------------------------------------------------------------------ +# 1 installation rpm -q --quiet elgis-release || rpm -Uvh http://elgis.argeo.org/repos/6/elgis-release-6-6_0.noarch.rpm rpm -q --quiet epel-release || rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -q --quiet eox-release || rpm -Uvh http://yum.packages.eox.at/el/eox-release-6-2.noarch.rpm -# uncomment for unstable releases +# uncomment for unstable releases #ex /etc/yum.repos.d/eox-testing.repo < # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 Iguassu Software Systems, a.s # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -33,13 +33,13 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # default django settings module DJANGO_SETTINGS_DEFAULT = "settings" DJANGO_DB_DEFAULT = "default" -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import os import sys @@ -65,13 +65,13 @@ except NameError: # Python 3, xrange is now named range xrange = range -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ QUEUE_EMPTY_QUERY_DELAY=1.5 # time in seconds of next query to empty queue QUEUE_PUT_TIMEOUT=1.0 # time out used by internal task queue put operation QUEUE_CLEAN_UP_COUNT=300 -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # generate unique server instance ID SERVER_ID=0 @@ -80,7 +80,7 @@ SERVER_ID = struct.unpack( 'q' , tmp )[0] SERVER_ID_STR = "0x%16.16X"%( struct.unpack( 'Q' , tmp )[0] ) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ dbLock = Lock() writeLock = Lock() @@ -95,14 +95,14 @@ def info( msg ) : write( ("INFO: %s\n"%(msg)).encode('UTF-8') ) def warn( msg ) : write( ("WARNINIG: %s\n"%(msg)).encode('UTF-8') ) def error( msg ) : write( ("ERROR: %s\n"%(msg)).encode('UTF-8') ) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # global worker pool global GWP GWP = None -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # iterrupt and terminate signal handlers @@ -123,7 +123,7 @@ def signal_handler_sigterm(sig, frm): GWP.terminate = True GWP.killChild = True # force immediate termination -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ class Importer( object ) : """ smart importer of the handler subroutine @@ -217,7 +217,7 @@ def taskDispatch( taskID , threadID ) : error( "[%3.3i] %s " % ( threadID , smart_str((e) ) ) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ def worker( queue , id ) : @@ -353,7 +353,7 @@ def startLoop( self ) : debug( "[MASTER]: reenquing task ID=%i ... " % item ) dbLocker( dbLock , reenqueueTask , item , message = "Reenqued by ATPD." ) except MPQEmpty : pass -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ def usage() : """ print usage info """ @@ -372,7 +372,7 @@ def usage() : return "\n".join(s) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ if __name__ == "__main__" : @@ -417,7 +417,7 @@ def usage() : error( "Invalid commandline option '%s' !" % arg ) sys.exit(1) - #------------------------------------------------------------------- + # ------------------------------------------------------------------ # initialize the working enviroment # django settings module @@ -435,14 +435,14 @@ def usage() : # initialize the system System.init() - #------------------------------------------------------------------- + # ------------------------------------------------------------------ info( "ATPD Asynchronous Task Processing Daemon has just been started!") info( "ATPD: id=%s (%i)" % ( SERVER_ID_STR , SERVER_ID ) ) info( "ATPD: hostname=%s" % socket.getfqdn() ) info( "ATPD: pid=%i " % os.getpid() ) - #------------------------------------------------------------------- + # ------------------------------------------------------------------ # start the worker pool GWP = WorkerPool( NTHREAD ) diff --git a/tools/eoxserver-preprocess.py b/tools/eoxserver-preprocess.py index f58eddf3d..f017ebbb0 100644 --- a/tools/eoxserver-preprocess.py +++ b/tools/eoxserver-preprocess.py @@ -1,18 +1,18 @@ #!/usr/bin/python -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Fabian Schindler # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import sys import re @@ -54,130 +54,130 @@ def main(args): parser = argparse.ArgumentParser(add_help=True, fromfile_prefix_chars='@', argument_default=argparse.SUPPRESS, formatter_class=argparse.RawDescriptionHelpFormatter) - + parser.description = textwrap.dedent("""\ - Takes raster data and pre-processes it into - .tif, a GeoTIFF converted to RGB using default internal - tiling, internal overviews, no compression, and 0 as no-data value, and + Takes raster data and pre-processes it into + .tif, a GeoTIFF converted to RGB using default internal + tiling, internal overviews, no compression, and 0 as no-data value, and .xml, a EOxServer simple XML EO metadata file. - The outfiles are ready to be used with the eoxs_register command of an + The outfiles are ready to be used with the eoxs_register command of an EOxServer instance. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!Caution, you will loose data quality!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - The data quality of .tif is most likely different from - because of the pre-processing applied. Reasons include + The data quality of .tif is most likely different from + because of the pre-processing applied. Reasons include re-projection, compression, conversion to RGB, indexing, etc. - + Examples: - + # basic usage with no creation of metadata eoxserver-preprocess.py --no-metadata input.tif - + # basic usage with creation of metadata with specific basename - eoxserver-preprocess.py --coverage-id=a --begin-time=2008-03-01T13:00:00Z \\ + eoxserver-preprocess.py --coverage-id=a --begin-time=2008-03-01T13:00:00Z \\ --end-time=2008-03-01T13:00:00Z input.tif output - + # with RGBA band selection eoxserver-preprocess.py --bands 1:0:255,2:0:255,3:0:100,4 --rgba \\ --no-metadata input.tif # with DEFLATE compression and color index from a palette file - eoxserver-preprocess.py --compression=DEFLATE --zlevel=2 --indexed \\ + eoxserver-preprocess.py --compression=DEFLATE --zlevel=2 --indexed \\ --pct palette.vrt --no-metadata input.tif - + # (re-)setting the extent of the file eoxserver-preprocess.py --extent 0,0,10,10,4326 --no-metadata input.tif - + # Using GCPs eoxserver-preprocess.py --no-metadata --gcp 0,0,10,10 --gcp 2560,0,50,10 \\ - --gcp 0,1920,10,50 --gcp 2560,1920,50,50 \\ + --gcp 0,1920,10,50 --gcp 2560,1920,50,50 \\ --georef-crs 4326 input.tif - + # reading arguments from a file (1 line per argument), with overrides eoxserver-preprocess.py @args.txt --crs=3035 --no-tiling input.tif """) - - #=========================================================================== + + # ========================================================================== # Metadata parsing group - #=========================================================================== - + # ========================================================================== + # TODO: won't work with mutual exclusive groups. Bug in Argparse? #md_g = parser.add_mutually_exclusive_group(required=True) - + #md_g.add_argument("--no-metadata", dest="generate_metadata", # action="store_false", - # help="Explicitly turn off the creation of a metadata " + # help="Explicitly turn off the creation of a metadata " # "file.") - + #md_g_data = md_g.add_argument_group() - - #md_g_data.add_argument("--begin-time", dest="begin_time", + + #md_g_data.add_argument("--begin-time", dest="begin_time", # type=_parse_datetime, # help="The ISO 8601 timestamp of the begin time.") #md_g_data.add_argument("--end-time", dest="end_time", # type=_parse_datetime, # help="The ISO 8601 timestamp of the end time.") #md_g_data.add_argument("--coverage-id", dest="coverage_id", - # type=_parse_coverage_id, + # type=_parse_coverage_id, # help="The ID of the coverage, must be a valid " # "NCName.") - + # should be mutually exclusive parser.add_argument("--no-metadata", dest="generate_metadata", action="store_false", - help="Explicitly turn off the creation of a metadata " + help="Explicitly turn off the creation of a metadata " "file.") parser.add_argument("--begin-time", dest="begin_time", type=_parse_datetime, help="The ISO 8601 timestamp of the begin time.") parser.add_argument("--end-time", dest="end_time", type=_parse_datetime, help="The ISO 8601 timestamp of the end time.") parser.add_argument("--coverage-id", dest="coverage_id", - type=_parse_coverage_id, + type=_parse_coverage_id, help="The ID of the coverage, must be a valid NCName.") - - #=========================================================================== + + # ========================================================================== # Georeference group - #=========================================================================== - + # ========================================================================== + georef_g = parser.add_mutually_exclusive_group() georef_g.add_argument("--extent", dest="extent", type=_parse_extent, help="The extent of the dataset, as a 4-tuple of " "floats.") - #georef_g.add_argument("--footprint", dest="footprint", + #georef_g.add_argument("--footprint", dest="footprint", # type=_parse_footprint, # help="The footprint of the dataset, as a Polygon WKT.") georef_g.add_argument("--gcp", dest="gcps", type=_parse_gcp, action="append", help="A Ground Control Point in the format: " "'pixel,line,easting,northing[,elevation]'.") - + parser.add_argument("--georef-crs", dest="georef_crs") - - #=========================================================================== + + # ========================================================================== # Arbitraries - #=========================================================================== - - parser.add_argument("--crs", dest="crs", type=int, + # ========================================================================== + + parser.add_argument("--crs", dest="crs", type=int, help="The desired output CRS ID of the dataset.") parser.add_argument("--no-tiling", dest="tiling", action="store_false", - default=True, + default=True, help="Explicitly turn of the tiling of the output " "dataset.") parser.add_argument("--no-overviews", dest="overviews", action="store_false", default=True, help="Explicitly turn of the creation of overview " "images of the output dataset.") - - #=========================================================================== + + # ========================================================================== # Bands group - #=========================================================================== - + # ========================================================================== + bands_g = parser.add_mutually_exclusive_group() - + bands_g.add_argument("--rgba", dest="bandmode", action="store_const", const=RGBA, help="Convert the image to RGBA, using the first four " @@ -185,8 +185,8 @@ def main(args): bands_g.add_argument("--orig-bands", dest="bandmode", action="store_const", const=ORIG_BANDS, help="Explicitly keep all original bands.") - - parser.add_argument("--bands", dest="bands", type=_parse_bands, + + parser.add_argument("--bands", dest="bands", type=_parse_bands, help="A comma separated list of bands with optional " "subsets in the form: 'no[:low:high]'. Either " "three bands, or four when --rgba is requested.") @@ -196,7 +196,7 @@ def main(args): help="A comma separated list of bands with optional " "subsets in the form: 'no[:low:high]'. Either " "three bands, or four when --rgba is requested.") - + parser.add_argument("--compression", dest="compression", choices=GeoTIFFFormatSelection.SUPPORTED_COMPRESSIONS, help="The desired compression technique.") @@ -206,28 +206,28 @@ def main(args): parser.add_argument("--zlevel", dest="zlevel", type=int, help="The zlevel quality setting when DEFLATE " "compression is requested.") - + indexed_group = parser.add_argument_group() - + # TODO: pct depends on indexed - + parser.add_argument("--indexed", dest="color_index", action="store_true", help="Create a paletted (indexed) image.") parser.add_argument("--pct", dest="palette_file", help="Use the given file as color palette. If not " "given, a new palette will be calculated.") - - parser.add_argument("--no-data-value", dest="no_data_value", + + parser.add_argument("--no-data-value", dest="no_data_value", type=_parse_nodata_values, help="Either one, or a list of no-data values.") - - parser.add_argument("--co", dest="creation_options", type=int, + + parser.add_argument("--co", dest="creation_options", type=int, action="append", help="Additional GDAL dataset creation options. " "See http://www.gdal.org/frmt_gtiff.html") - + parser.add_argument("--traceback", action="store_true", default=False) - + parser.add_argument("--force", "-f", dest="force", action="store_true", default=False, help="Override files, if they already exist.") @@ -235,46 +235,46 @@ def main(args): parser.add_argument("--verbosity", "-v", dest="verbosity", type=int, default=1, help="Set the verbosity (0, 1, 2). Default is 1.") - + parser.add_argument("input_filename", metavar="infile", nargs=1, help="The input raster file to be processed.") parser.add_argument("output_basename", metavar="outfiles_basename", - nargs="?", + nargs="?", help="The base name of the outputfile(s) to be " "generated.") - + values = vars(parser.parse_args(args)) - - + + # check metadata values - if "generate_metadata" in values and ("begin_time" in values + if "generate_metadata" in values and ("begin_time" in values or "end_time" in values or "coverage_id" in values): parser.error("--no-metadata is mutually exclusive with --begin-time, " "--end-time and --coverage-id.") - elif "generate_metadata" not in values and not ("begin_time" in values + elif "generate_metadata" not in values and not ("begin_time" in values and "end_time" in values and "coverage_id" in values): parser.error("Enter the full metadata with --begin-time, --end-time " "and --coverage-id.") - + # hack to flatten the list values["input_filename"] = values["input_filename"][0] - + georef_crs = values.pop("georef_crs", None) - + if "extent" in values: values["geo_reference"] = Extent(*values.pop("extent"), srid=georef_crs or 4326) - + if "gcps" in values: values["geo_reference"] = GCPList(values.pop("gcps"), georef_crs or 4326) - + if "palette_file" in values and not "color_index" in values: parser.error("--pct can only be used with --indexed") - + # Extract format and execution specific values - format_values = _extract(values, ("tiling", "compression", "jpeg_quality", + format_values = _extract(values, ("tiling", "compression", "jpeg_quality", "zlevel", "creation_options")) exec_values = _extract(values, ("input_filename", "geo_reference", "generate_metadata")) @@ -294,7 +294,7 @@ def main(args): elif verbosity >= 3: level = logging.DEBUG logging.basicConfig(format="%(levelname)s: %(message)s", stream=sys.stderr, level=level) - + try: # create a format selection @@ -306,7 +306,7 @@ def main(args): if not output_basename: output_filename = splitext(input_filename)[0] + "_proc" + format_selection.extension output_md_filename = splitext(input_filename)[0] + "_proc.xml" - + else: output_filename = output_basename + format_selection.extension output_md_filename = output_basename + ".xml" @@ -329,10 +329,10 @@ def main(args): metadata_values["begin_time"], metadata_values["end_time"], result.footprint_raw)) - + with open(output_md_filename, "w+") as f: f.write(xml) - + except Exception as e: # error wrapping if other_values["traceback"]: @@ -343,36 +343,36 @@ def main(args): def _parse_datetime(input_str): """ Helper callback function to check if a given datetime is correct. """ - + try: getDateTime(input_str) except: raise argparse.ArgumentTypeError("Wrong datetime format. Use ISO 8601.") - + return input_str - + def _parse_coverage_id(input_str): - """ Helper callback function to check if a given coverage ID is a valid + """ Helper callback function to check if a given coverage ID is a valid NCName. """ - + if not re.match(r'^[a-zA-z_][a-zA-Z0-9_.-]*$', input_str): raise argparse.ArgumentTypeError("The given coverage ID '%s' is not a " "valid NCName." % input_str) - + return input_str def _parse_extent(input_str): """ Helper callback function to parse an extent. """ - + parts = input_str.split(",") if len(parts) != 4: raise argparse.ArgumentTypeError("Wrong format of extent.") - + return map(float, parts) @@ -384,16 +384,16 @@ def _parse_footprint(input_str): def _parse_gcp(input_str): - """ Helper callback function to parse one GCP in the form - "pixel,line,easting,northing[,elevation]" and transform it into a list + """ Helper callback function to parse one GCP in the form + "pixel,line,easting,northing[,elevation]" and transform it into a list like [x,y[,z],pixel,line] """ - + parts = input_str.split(",") - + if not (len(parts) != 4 or len(parts) != 5): raise argparse.ArgumentTypeError("Wrong number of arguments for GCP.") - + try: gcps = [float(part) for part in parts] return gcps[2:] + gcps[:2] @@ -402,12 +402,12 @@ def _parse_gcp(input_str): def _parse_bands(input_str): - """ Helper callback function to parse a list of selected bands given from + """ Helper callback function to parse a list of selected bands given from the user. """ - + result = [] - + def parse_minmax(subparts, index): try: if subparts[index] in ("min", "max"): @@ -418,32 +418,32 @@ def parse_minmax(subparts, index): return None except ValueError: raise argparse.ArgumentTypeError("Wrong format of band subset.") - + for part in input_str.split(","): subparts = part.split(":") - + if len(subparts) < 1 or len(subparts) > 3: raise argparse.ArgumentTypeError("Wrong format of band.") - + number = int(subparts[0]) dmin = parse_minmax(subparts, 1) dmax = parse_minmax(subparts, 2) result.append((number, dmin, dmax)) - + return result def _parse_nodata_values(input_str): - """ Helper callback function to parse no-data values. + """ Helper callback function to parse no-data values. """ - + return [int(part) for part in input_str.split(",")] def _parse_creation_options(input_str): - """ Helper callback function to parse additional dataset creation options. + """ Helper callback function to parse additional dataset creation options. """ - + return input_str.split("=") diff --git a/tools/eoxserver-validate_xml.py b/tools/eoxserver-validate_xml.py index 826d60a9c..9dfc9c15e 100755 --- a/tools/eoxserver-validate_xml.py +++ b/tools/eoxserver-validate_xml.py @@ -1,18 +1,18 @@ #!/usr/bin/env python -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all @@ -25,17 +25,17 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import sys, os from lxml import etree """ - Validate given XML document(s) against schema(s) referenced in + Validate given XML document(s) against schema(s) referenced in schemaLocation attribute of root element. - + Usage: validate_xml.py - + Basically same as: xmllint --noout --schema """ if __name__ == "__main__" : @@ -53,7 +53,7 @@ doc = etree.parse(name).getroot() schema_locations = doc.get("{http://www.w3.org/2001/XMLSchema-instance}schemaLocation") locations = schema_locations.split() - + # Create schema importing all referenced schemas schema_def = etree.Element("schema", attrib={ "elementFormDefault": "qualified", @@ -69,10 +69,10 @@ } ) print ("Schema: Namespace: %s, Location: %s" % (ns, location)) - + # TODO: Workaround, but otherwise the doc is not recognized as schema schema = etree.XMLSchema(etree.XML(etree.tostring(schema_def))) - + # Validate file against schema try: schema.assertValid(doc) diff --git a/tools/gdalcompare.py b/tools/gdalcompare.py index c32f807b1..effd02a91 100755 --- a/tools/gdalcompare.py +++ b/tools/gdalcompare.py @@ -1,10 +1,10 @@ #!/usr/bin/env python -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Simple CLI tool to compare files with GDAL. @@ -12,8 +12,8 @@ # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all @@ -26,7 +26,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ import sys @@ -34,7 +34,7 @@ def extent_from_ds(ds): gt = ds.GetGeoTransform() size_x = ds.RasterXSize size_y = ds.RasterYSize - + return (gt[0], # minx gt[3] + size_x * gt[5], # miny gt[0] + size_y * gt[1], # maxx @@ -48,12 +48,12 @@ def resolution_from_ds(ds): def compare_files(filename1, filename2): import filecmp, os - + try: os.stat(filename1) except OSError: raise Exception("Error while reading '%s'." % filename1) - + try: os.stat(filename2) except OSError: @@ -61,7 +61,7 @@ def compare_files(filename1, filename2): if filecmp.cmp(filename2,filename1,0): return True - + try: try: from osgeo import gdal @@ -69,7 +69,7 @@ def compare_files(filename1, filename2): except ImportError: import gdal from osr import SpatialReference - + gdal.PushErrorHandler('CPLQuietErrorHandler') file1 = gdal.Open(filename1) gdal.PopErrorHandler() @@ -79,10 +79,10 @@ def compare_files(filename1, filename2): gdal.PopErrorHandler() if file2 == None: raise Exception("Error while reading '%s' via GDAL." % filename2) - + # Check image checksums print ("Checking checksums...") - + for band_num in range(1,file2.RasterCount+1): if file1.GetRasterBand(band_num).Checksum() != \ file2.GetRasterBand(band_num).Checksum(): @@ -93,19 +93,19 @@ def compare_files(filename1, filename2): else: print ("Checksum of band '%s' matches and is '%s'." % \ (band_num, file1.GetRasterBand(band_num).Checksum())) - + # Check image size print "Checking size..." - + if file1.RasterXSize != file2.RasterXSize or \ file1.RasterYSize != file2.RasterYSize: raise Exception("Size differs: '%s x %s' != '%s x %s'." % \ - (file1.RasterXSize, file1.RasterYSize, + (file1.RasterXSize, file1.RasterYSize, file2.RasterXSize, file2.RasterYSize)) - + # Check extent print ("Checking extent...") - + EPSILON = 1e-8 extent1 = extent_from_ds(file1) extent2 = extent_from_ds(file2) @@ -113,60 +113,60 @@ def compare_files(filename1, filename2): abs(extent1[i] - extent2[i]) for i in range(0, 4) ]) >= EPSILON: raise Exception("Extent differs: '%s' != '%s'." % \ - ((', '.join(map(str, extent1))), + ((', '.join(map(str, extent1))), (', '.join(map(str, extent2))))) - + # Check resolution print ("Checking resolution...") - + resolution1 = resolution_from_ds(file1) resolution2 = resolution_from_ds(file2) if resolution1[0] != resolution2[0] or resolution1[1] != resolution2[1]: raise Exception("Resolution differs: '%s' != '%s'." % \ - ((', '.join(map(str, resolution1))), + ((', '.join(map(str, resolution1))), (', '.join(map(str, resolution2))))) - + # Check projection print ("Checking projection...") - + if file1.GetProjection() != file2.GetProjection(): raise Exception("Projection differs.") - + # Check GCPs print ("Checking GCPs...") - + if file1.GetGCPCount() != file2.GetGCPCount(): raise Exception("Number of GCPs differs: '%s' != '%s'." % \ (file1.GetGCPCount(), file2.GetGCPCount())) - + # Check GCP projection print ("Checking GCP projection...") - + if file1.GetGCPProjection() != file2.GetGCPProjection(): raise Exception("GCP projection differs.") - + # Check metadata print ("Checking metadata...") - + file1_md = file1.GetMetadata() file2_md = file2.GetMetadata() if file1_md.keys() != file2_md.keys(): raise Exception("Metadata keys don't match.") - + diffkeys = [k for k in file1_md if file1_md[k] != file2_md[k]] error = "" for k in diffkeys: error += " %s: %s != %s\n" % (k, file1_md[k], file2_md[k]) if len(diffkeys) > 0: raise Exception("Metadata not equal:\n%s" % error) - + except Exception as e: raise Exception("Comparison via GDAL failed: '%s'" % e) if __name__ == "__main__": - + try: src0 = sys.argv[1] src1 = sys.argv[2] @@ -176,12 +176,12 @@ def compare_files(filename1, filename2): sys.stderr.write("ERROR: Not enough input arguments!\n") sys.stderr.write("USAGE: %s \n" % sys.argv[0]) sys.exit(1) - + try: compare_files(src0, src1) except Exception as e: sys.stderr.write("ERROR: %s\n" % str(e)) sys.exit(1) - + print ("OK - Files match.") sys.exit(0) diff --git a/tools/gen_envisat_md.py b/tools/gen_envisat_md.py index b328b6f44..de3e46c20 100755 --- a/tools/gen_envisat_md.py +++ b/tools/gen_envisat_md.py @@ -1,11 +1,11 @@ #!/usr/bin/python -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Fabian Schindler # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2012 EOX IT Services GmbH # # Simple CLI tool to compare files with GDAL. @@ -13,8 +13,8 @@ # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all @@ -27,7 +27,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from osgeo import gdal import re @@ -47,7 +47,7 @@ from eoxserver.services.gml.v32.encoders import EOP20Encoder -EOMetadata = namedtuple("EOMetadata", +EOMetadata = namedtuple("EOMetadata", ("identifier", "begin_time", "end_time", "footprint") ) @@ -67,7 +67,7 @@ elif not reader.test_ds(ds): print ("Dataset '%s' does not contain required ENVISAT metadata." % path) exit(1) - + md = reader.read_ds(ds) del ds @@ -75,10 +75,10 @@ footprint.srid = 4326 encoder = EOP20Encoder() - + xml = encoder.serialize( encoder.encode_earth_observation(EOMetadata(footprint=footprint, **md)) ) - + with open(os.path.join(os.path.dirname(path))) as f: f.write(xml) diff --git a/tools/gml2gtiff.py b/tools/gml2gtiff.py index 632c10252..5e63ba123 100644 --- a/tools/gml2gtiff.py +++ b/tools/gml2gtiff.py @@ -1,18 +1,18 @@ #!/usr/bin/env python -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all @@ -25,31 +25,14 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -from osgeo import gdal, osr -try: - from lxml import etree -except ImportError: - try: - import xml.etree.cElementTree as etree - except ImportError: - try: - import xml.etree.ElementTree as etree - except ImportError: - try: - import cElementTree as etree - except ImportError: - try: - import elementtree.ElementTree as etree - except ImportError: - print("Failed to import ElementTree from any known place") -import sys -import numpy from argparse import ArgumentParser from decimal import Decimal -from django.utils.six import iteritems +from osgeo import gdal, osr +import numpy +from lxml import etree """ Helper functions to namespaceify xml tag names @@ -72,7 +55,7 @@ def ns_gmlcov(string): parser.add_argument("output", help = "the path to the output GTiff file") options = parser.parse_args() -""" +""" Parse the XML file into an ElementTree structure """ f = open(options.input) @@ -124,7 +107,7 @@ def ns_gmlcov(string): + ns_swe("significantFigures")) if significant_figures is not None: bandinfo['significant_figures'] = int(significant_figures) - + bands.append(bandinfo) """ @@ -142,13 +125,13 @@ def ns_gmlcov(string): assert(len(values) == len(bands)) for index, value in enumerate(values): band_values[index].append(float(value)) - + # find out significant figures e = abs(Decimal(value).as_tuple().exponent) try: if bands[index]['significant_figures'] < e: bands[index]['significant_figures'] = e - except KeyError: + except KeyError: bands[index]['significant_figures'] = e """ @@ -177,7 +160,7 @@ def ns_gmlcov(string): To set the projection, create a osr.SpatialReference, load the EPSG into it and export it as WKT to set as projection in the dataset. """ -srs = root.find(ns_gml("boundedBy/") +srs = root.find(ns_gml("boundedBy/") + ns_gml("Envelope") ).get("srsName") @@ -192,11 +175,11 @@ def ns_gmlcov(string): Create a textual representation of the extent. """ -extent = "%s %s" % (root.findtext(ns_gml("boundedBy/") +extent = "%s %s" % (root.findtext(ns_gml("boundedBy/") + ns_gml("Envelope/") + ns_gml("lowerCorner") ), - root.findtext(ns_gml("boundedBy/") + root.findtext(ns_gml("boundedBy/") + ns_gml("Envelope/") + ns_gml("upperCorner") ) @@ -206,7 +189,7 @@ def ns_gmlcov(string): To set the geotransform, find out the origin and the two offset vectors. """ -origin = [float(string) for string in +origin = [float(string) for string in root.findtext(ns_gml("domainSet/") + ns_gml("RectifiedGrid/") + ns_gml("origin/") @@ -256,16 +239,16 @@ def ns_gmlcov(string): layer.setMetaData("wcs_extent", extent) layer.setMetaData("wcs_size", "%d %d" % (width, height)) layer.setMetaData("wcs_default_format", "application/gml+xml") - + # set band metadata layer.setMetaData("wcs_bandcount", str(len(bands))) layer.setMetaData("wcs_band_names", " ".join([band['band_name'] for band in bands])) for band in bands: - for key, value in iteritems(band): + for key, value in band.items(): if value is None or key == "band_name": continue layer.setMetaData("%s_%s" % (band['band_name'], key), str(value)) - + # append GML outputformat format = outputFormatObj("GDAL/GTiff", "GML") format.setExtension("xml") diff --git a/tools/install_centos.sh b/tools/install_centos.sh index 89ca1ed93..34472878b 100755 --- a/tools/install_centos.sh +++ b/tools/install_centos.sh @@ -1,26 +1,26 @@ -#!/bin/sh -#----------------------------------------------------------------------- +#!/bin/sh +# ---------------------------------------------------------------------- # -# Description: +# Description: # -# Automatic installation on CentOS (applicable also to RHEL and its clones). +# Automatic installation on CentOS (applicable also to RHEL and its clones). # -# The script install the EOxServer RPMs and setups and configures +# The script install the EOxServer RPMs and setups and configures # EOxServer instance. # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all @@ -33,13 +33,13 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -set -x -set -e +set -x +set -e -#------------------------------------------------------------------------------- -# if not set the default HOSTNAME is used +# ------------------------------------------------------------------------------ +# if not set the default HOSTNAME is used #HOSTNAME= INSTANCE="instance00" @@ -65,22 +65,22 @@ PG_HBA="/var/lib/pgsql/data/pg_hba.conf" MNGCMD="${INSTROOT}/${INSTANCE}/manage.py" SOCKET_PREFIX="run/wsgi" -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -if [ -z "$HOSTNAME" ] -then - echo "Set the HOSTNAME variable!" 1>&1 - exit 1 -fi +if [ -z "$HOSTNAME" ] +then + echo "Set the HOSTNAME variable!" 1>&1 + exit 1 +fi -#------------------------------------------------------------------------------- -# 1 installation +# ------------------------------------------------------------------------------ +# 1 installation rpm -q --quiet elgis-release || rpm -Uvh http://elgis.argeo.org/repos/6/elgis-release-6-6_0.noarch.rpm rpm -q --quiet epel-release || yum install epel-release rpm -q --quiet eox-release || rpm -Uvh http://yum.packages.eox.at/el/eox-release-6-2.noarch.rpm -# uncomment for unstable releases +# uncomment for unstable releases #ex /etc/yum.repos.d/eox-testing.repo <' $F` ] - then + if [ 0 -lt `grep -c '^[ ]*' $F` ] + then CONF=$F - break + break fi done -#if the virtual host is not present - create one +#if the virtual host is not present - create one if [ -z "$CONF" ] then CONF="$CONF_DEFAULT" - echo "Default virtual host not located creting own one in: $CONF" + echo "Default virtual host not located creting own one in: $CONF" cat >"$CONF" < END else - echo "Default virtual host located in: $CONF" + echo "Default virtual host located in: $CONF" fi -# insert the configuration to the virtual host +# insert the configuration to the virtual host ex "$CONF" </a @@ -258,7 +258,7 @@ ex "$CONF" < - # static content + # static content Alias $INSTSTAT_URL "$INSTSTAT_DIR" Options -MultiViews +FollowSymLinks @@ -270,29 +270,29 @@ ex "$CONF" <> /etc/httpd/conf.d/wsgi.conf + echo "WSGISocketPrefix $SOCKET_PREFIX" >> /etc/httpd/conf.d/wsgi.conf fi -# set the service url +# set the service url sudo -u eoxserver ex "$EOXSCONF" < # Authors: Stephan Krause # Stephan Meissl # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ from osgeo import gdal, osr import numpy as np diff --git a/tools/xcomp.py b/tools/xcomp.py index a08835317..e6329ec14 100755 --- a/tools/xcomp.py +++ b/tools/xcomp.py @@ -1,19 +1,19 @@ #!/usr/bin/env python -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # -# simple CLI tool comparing XML documents +# simple CLI tool comparing XML documents # # Project: EOxServer # Authors: Martin Paces # -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # Copyright (C) 2011 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all @@ -26,32 +26,32 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ # -import sys -from eoxserver.testing import xcomp # NOTE : make sure to set the right PYTHONPATH +import sys +from eoxserver.testing import xcomp # NOTE : make sure to set the right PYTHONPATH -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ -if __name__ == "__main__" : +if __name__ == "__main__" : try : - src0 = sys.argv[1] - src1 = sys.argv[2] - + src0 = sys.argv[1] + src1 = sys.argv[2] + print ("< FILE: %s" % src0) print ("> FILE: %s" % src1) except : - sys.stderr.write( "ERROR: Not enough input arguments!\n" ) - sys.stderr.write( "USAGE: %s \n" % sys.argv[0] ) + sys.stderr.write( "ERROR: Not enough input arguments!\n" ) + sys.stderr.write( "USAGE: %s \n" % sys.argv[0] ) sys.exit(1) - try : - xcomp.xmlCompareFiles( src0 , src1 , True ) - except Exception as e : - sys.stderr.write( "ERROR: %s\n" % str(e) ) + try : + xcomp.xmlCompareFiles( src0 , src1 , True ) + except Exception as e : + sys.stderr.write( "ERROR: %s\n" % str(e) ) sys.exit(1) print (" OK - XML files match. ") - sys.exit(0) + sys.exit(0)