Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
voisardf committed Aug 21, 2024
2 parents 46444b5 + 87b1062 commit f50347b
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
sudo apt-get install libpq-dev
make doc-html
- name: Deploy 🚀
uses: JamesIves/[email protected].1
uses: JamesIves/[email protected].3
with:
branch: gh-pages # The branch the action should deploy to.
folder: doc/build/html # The folder the action should deploy.
Expand Down
11 changes: 10 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
=========

Notes:
------
- This python package specifies the version numbers only of directly imported python packages. This approach may result in a build failure of older versions of the project if incompatibilities arise between imported packages over time. The build process of the master branch is regularly tested in an automatic process.

2.5.2
-----
- Add configuration Option to check certificate for external WMS. Default setting: True
- Library upgrades (shapely, geoalchemy2, sqlalchemy, lxml)

2.5.1
-----
- Library upgrades (SQLAlchemy, shapely, geoalchemy2, responses, urllib3, lxml)
Expand All @@ -20,7 +29,7 @@ Changelog

2.4.7
-----
- Add extract_index to disclaimer and general infomation (#1753)
- Add extract_index to disclaimer and general infomation (#1753). Note that this improvement requires an additional attribute "extract_index" in tables "general_information" and "disclaimer" of the main schema.
- Interlis bug fix (#1881)
- Library upgrades (geoalchemy2, SQLAlchemy, jsonschema, lxml, responses, urllib3, pypdf)
- Test coverage improvements
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.12.4-bullseye
FROM python:3.12.5-bullseye

ENV DEBIAN_FRONTEND=noninteractive

Expand Down
4 changes: 4 additions & 0 deletions dev/config/pyramid_oereb.yml.mako
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,17 @@ pyramid_oereb:
fr: https://wms.geo.admin.ch/?SERVICE=WMS&REQUEST=GetMap&VERSION=1.3.0&STYLES=default&CRS=EPSG:2056&BBOX=2475000,1065000,2850000,1300000&WIDTH=493&HEIGHT=280&FORMAT=image/png&LAYERS=ch.swisstopo-vd.amtliche-vermessung
layer_index: 0
layer_opacity: 1.0
# Option to check certificate for external WMS. Default and recommended setting: True
verify_certificate: True
plan_for_land_register_main_page:
# WMS URL to query the plan for land register specially for static extracts overview page
reference_wms:
de: https://wms.geo.admin.ch/?SERVICE=WMS&REQUEST=GetMap&VERSION=1.3.0&STYLES=default&CRS=EPSG:2056&BBOX=2475000,1065000,2850000,1300000&WIDTH=493&HEIGHT=280&FORMAT=image/png&LAYERS=ch.swisstopo-vd.amtliche-vermessung
fr: https://wms.geo.admin.ch/?SERVICE=WMS&REQUEST=GetMap&VERSION=1.3.0&STYLES=default&CRS=EPSG:2056&BBOX=2475000,1065000,2850000,1300000&WIDTH=493&HEIGHT=280&FORMAT=image/png&LAYERS=ch.swisstopo-vd.amtliche-vermessung
layer_index: 0
layer_opacity: 1.0
# Option to check certificate for external WMS. Default and recommended setting: True
verify_certificate: True
visualisation:
method: pyramid_oereb.core.hook_methods.produce_sld_content
# Note: these parameters must fit to the attributes provided by the RealEstateRecord!!!!
Expand Down
7 changes: 7 additions & 0 deletions doc/source/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ Changes/Hints for migration
This chapter will give you hints on how to handle version migration, in particular regarding what you may need
to adapt in your project configuration, database etc. when upgrading to a new version.

Version 2.5.2
-------------
Feature and maintenance release:

* Add configuration Option to check certificate for external WMS. Default setting: True
* Library upgrades (shapely, geoalchemy2, sqlalchemy, lxml)

Version 2.5.1
-------------
Maintenance release:
Expand Down
24 changes: 12 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pyramid_oereb"
version = "2.5.1"
version = "2.5.2"
description = "pyramid_oereb, extension for pyramid web frame work to provide a basic server part for the oereb project"

classifiers=[
Expand Down Expand Up @@ -35,15 +35,15 @@ Changelog = "https://github.com/openoereb/pyramid_oereb/blob/master/CHANGES.rst"
[project.optional-dependencies]
# Dependencies listed in "recommend" must be included in "no-version" without explicit version number
recommend = [
"pypdf==4.2.0",
"pypdf==4.3.1",
"filetype==1.2.0",
"geoalchemy2==0.15.1",
"geoalchemy2==0.15.2",
"pyramid==2.0.2",
"pyramid-debugtoolbar==4.12.1",
"qrcode==7.4.2",
"image==1.5.33",
"shapely==2.0.4",
"SQLAlchemy==2.0.31",
"shapely==2.0.6",
"SQLAlchemy==2.0.32",
"pyaml-env==1.2.1",
"urllib3==2.2.2",
"waitress==3.0.0",
Expand Down Expand Up @@ -73,21 +73,21 @@ no-version = [
"pyconizer",
"c2cwsgiutils[standard]"]
testing = [
"jsonschema==4.22.0",
"lxml==5.2.2",
"pytest==8.2.2",
"jsonschema==4.23.0",
"lxml==5.3.0",
"pytest==8.3.2",
"pytest-cov==5.0.0",
"pytest-ordering==0.6",
"requests-mock==1.12.1",
"responses==0.25.3",
"webtest==3.0.0",
"pillow==10.3.0"]
"pillow==10.4.0"]
dev = [
"flake8==7.1.0",
"flake8==7.1.1",
"Flake8-pyproject==1.2.3",
"pyflakes==3.2.0",
"pycodestyle==2.12.0",
"Sphinx==7.3.7",
"pycodestyle==2.12.1",
"Sphinx==7.4.7",
"sphinx_rtd_theme==2.0.0",
"psycopg2==2.9.9",
"mccabe==0.7.0",
Expand Down
4 changes: 3 additions & 1 deletion pyramid_oereb/contrib/data_sources/standard/sources/plr.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ def from_db_to_view_service_record(self, view_service_from_db, legend_entry_reco
Config.get('default_language'),
Config.get('srid'),
Config.get('proxies'),
legends=legend_entry_records
legends=legend_entry_records,
# Note: our standard database model does not contain an option to override the verify_certificate
verify_certificate=True
)
return view_service_record

Expand Down
6 changes: 4 additions & 2 deletions pyramid_oereb/core/readers/real_estate.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def read(self, params, nb_ident=None, number=None, egrid=None, geometry=None):
plan_for_land_register_config.get('layer_opacity'),
Config.get('default_language'),
Config.get('srid'),
Config.get('proxies')
Config.get('proxies'),
verify_certificate=plan_for_land_register_config.get('verify_certificate', True)
)

plan_for_land_register_main_page_config = Config.get_plan_for_land_register_main_page_config()
Expand All @@ -73,7 +74,8 @@ def read(self, params, nb_ident=None, number=None, egrid=None, geometry=None):
plan_for_land_register_main_page_config.get('layer_opacity'),
Config.get('default_language'),
Config.get('srid'),
Config.get('proxies')
Config.get('proxies'),
verify_certificate=plan_for_land_register_main_page_config.get('verify_certificate', True)
)

self._source_.read(params, nb_ident=nb_ident, number=number, egrid=egrid, geometry=geometry)
Expand Down
7 changes: 4 additions & 3 deletions pyramid_oereb/core/records/view_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ViewServiceRecord(object):
"""

def __init__(self, reference_wms, layer_index, layer_opacity, default_language,
srid, proxies=None, legends=None):
srid, proxies=None, legends=None, verify_certificate=True):
"""
Args:
Expand All @@ -91,6 +91,7 @@ def __init__(self, reference_wms, layer_index, layer_opacity, default_language,
srid (int): The SRID which is used for the WMS.
proxies (dict or None): The proxies which may be used
legends (list of LegendEntry or None): A list of all relevant legend entries.
verify_certificate (bool): indicates whether call to the WMS shall be verified
"""
self.reference_wms = reference_wms
self.image = dict() # multilingual dict with binary map images resulting from calling the wms link
Expand All @@ -105,13 +106,13 @@ def __init__(self, reference_wms, layer_index, layer_opacity, default_language,
self.default_language = default_language
self.srid = srid
self.proxies = proxies

if legends is None:
self.legends = []
else:
for legend in legends:
assert isinstance(legend.symbol, ImageRecord)
self.legends = legends
self.verify_certificate = verify_certificate

@staticmethod
def sanitize_layer_index(layer_index):
Expand Down Expand Up @@ -247,7 +248,7 @@ def download_wms_content(self, language):
if uri_validator(wms):
log.debug(f"Downloading image, url: {wms}")
try:
response = requests.get(wms, proxies=self.proxies)
response = requests.get(wms, proxies=self.proxies, verify=self.verify_certificate)
except Exception as ex:
dedicated_msg = f"An image could not be downloaded. URL was: {wms}, error was {ex}"
log.error(dedicated_msg)
Expand Down
19 changes: 11 additions & 8 deletions tests/core/records/test_view_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def test_init():
'de',
2056,
None,
None
None,
True
)
assert isinstance(record.reference_wms, dict)
assert isinstance(record.layer_index, int)
Expand All @@ -30,6 +31,7 @@ def test_init():
assert record.srid == 2056
assert record.proxies is None
assert len(record.legends) == 0
assert record.verify_certificate is True


def test_init_with_relation(pyramid_oereb_test_config):
Expand All @@ -49,7 +51,8 @@ def test_init_with_relation(pyramid_oereb_test_config):
'de',
2056,
None,
legend_records
legend_records,
True
)
assert isinstance(record.reference_wms, dict)
assert isinstance(record.layer_index, int)
Expand All @@ -63,20 +66,20 @@ def test_init_with_relation(pyramid_oereb_test_config):

def test_invalid_layer_index_arguments(pyramid_oereb_test_config):
with pytest.raises(AttributeError):
ViewServiceRecord({'de': 'http://example.com'}, -1001, 1, 'de', 2056, None, None)
ViewServiceRecord({'de': 'http://example.com'}, -1001, 1, 'de', 2056, None, None, True)
with pytest.raises(AttributeError):
ViewServiceRecord({'de': 'http://example.com'}, 1001, 1, 'de', 2056, None, None)
ViewServiceRecord({'de': 'http://example.com'}, 1001, 1, 'de', 2056, None, None, True)
with pytest.warns(UserWarning, match='Type of "layer_index" should be "int"'):
ViewServiceRecord({'de': 'http://example.com'}, 1.0, 1, 'de', 2056, None, None)
ViewServiceRecord({'de': 'http://example.com'}, 1.0, 1, 'de', 2056, None, None, True)


def test_invalid_layer_layer_opacity(pyramid_oereb_test_config):
with pytest.raises(AttributeError):
ViewServiceRecord({'de': 'http://example.com'}, 1, 2.0, 'de', 2056, None, None)
ViewServiceRecord({'de': 'http://example.com'}, 1, 2.0, 'de', 2056, None, None, True)
with pytest.raises(AttributeError):
ViewServiceRecord({'de': 'http://example.com'}, 1, -1.1, 'de', 2056, None, None)
ViewServiceRecord({'de': 'http://example.com'}, 1, -1.1, 'de', 2056, None, None, True)
with pytest.warns(UserWarning, match='Type of "layer_opacity" should be "float"'):
ViewServiceRecord({'de': 'http://example.com'}, 1, 1, 'de', 2056, None, None)
ViewServiceRecord({'de': 'http://example.com'}, 1, 1, 'de', 2056, None, None, True)


def test_check_min_max_attributes():
Expand Down

0 comments on commit f50347b

Please sign in to comment.