diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bfc362fb..0c1a00cc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Changes - [#169](https://github.com/LayerManager/layman/issues/169) [POST Workspace Layers](doc/rest.md#post-workspace-layers) accepts also compressed data files in ZIP format (`*.zip`) in `file` parameter. [PATCH Workspace Layer](doc/rest.md#patch-workspace-layer) accepts also data file in ZIP format (`*.zip`) in `file` parameter. - [#503](https://github.com/LayerManager/layman/issues/503) Normalized GeoTIFF for raster files are also compressed. +- [#232](https://github.com/LayerManager/layman/issues/232) Prefixes '>=' or '==' can be used in [MICKA_ACCEPTED_VERSION](doc/env-settings.md#micka_accepted_version). - [#169](https://github.com/LayerManager/layman/issues/169) [GET Workspace Layer](doc/rest.md#get-workspace-layer) returns path to main file inside archive if zipped file was sent (key `file.path`). - [#465](https://github.com/LayerManager/layman/issues/465) Fix situation, when Layman does not start if *.qgis file of the first layer with QML style does not exist. It was already fixed in v1.14.1. - [#464](https://github.com/LayerManager/layman/issues/464) Fix publishing layers with unusual attribute names (e.g. `x,` or `Číslo`) and QML styles. It was already fixed in v1.14.1. diff --git a/doc/env-settings.md b/doc/env-settings.md index 2459f5031..fa54f2310 100644 --- a/doc/env-settings.md +++ b/doc/env-settings.md @@ -203,7 +203,7 @@ Internal URL of [OGC Catalogue Service v2.0.2](https://www.opengeospatial.org/st Public URL of [OGC Catalogue Service v2.0.2](https://www.opengeospatial.org/standards/cat) endpoint. Tested with [Micka](http://micka.bnhelp.cz/). ### MICKA_ACCEPTED_VERSION -Version of Micka that Layman will accept on startup encoded as `version:revision`, e.g. `2020.014:2020-04-15.01`. If it is not set, a version defined in [LAYMAN_SETTINGS_MODULE](#LAYMAN_SETTINGS_MODULE) will be accepted. +Version of Micka that Layman will accept on startup encoded as `version:revision`, e.g. `2020.014:2020-04-15.01`. Also, on one of '>=' or '==' prefixes can be used with obvious meaning, `e.g. >=2020.014:2020-04-15.01`. For prefix '>=', version and revision are compared independently as strings. If the variable is not set, a version defined in [LAYMAN_SETTINGS_MODULE](#LAYMAN_SETTINGS_MODULE) will be accepted. If none prefix is used, value is compared as with '=='. ### MICKA_HOSTPORT String with public domain and optionally port, e.g. `` or `:`. Passed as configuration to Micka for demo purposes. diff --git a/src/layman_settings.py b/src/layman_settings.py index 3c67cbb84..ce0c75da8 100644 --- a/src/layman_settings.py +++ b/src/layman_settings.py @@ -203,11 +203,12 @@ CSW_RECORD_URL = os.getenv('CSW_RECORD_URL', None) # # tuples like (version, revision) -MICKA_ACCEPTED_VERSION = [ - ('2020.014', '2020-04-15.01'), -] if ':' not in os.getenv('MICKA_ACCEPTED_VERSION', '') else [ - tuple(os.environ['MICKA_ACCEPTED_VERSION'].split(':')) -] +MICKA_REGEXP = r"^(?P==|>=|)(?P[0-9.]+):(?P[0-9-.]+)$" +MICKA_REGEXP_MATCH = re.search(MICKA_REGEXP, os.getenv('MICKA_ACCEPTED_VERSION', None) or '==2020.014:2020-04-15.01') +assert MICKA_REGEXP_MATCH, f'os.getenv(MICKA_ACCEPTED_VERSION)={os.getenv("MICKA_ACCEPTED_VERSION", "")}, MICKA_REGEXP_MATCH={MICKA_REGEXP_MATCH}' +assert len( + MICKA_REGEXP_MATCH.groups()) == 3, f'os.getenv(MICKA_ACCEPTED_VERSION)={os.getenv("MICKA_ACCEPTED_VERSION", "")}, MICKA_REGEXP_MATCH={MICKA_REGEXP_MATCH}' +MICKA_ACCEPTED_VERSION = MICKA_REGEXP_MATCH.groups() LAYMAN_PUBLIC_URL_SCHEME = urlparse(LAYMAN_CLIENT_PUBLIC_URL).scheme diff --git a/src/wait_for_deps.py b/src/wait_for_deps.py index e648695e1..ab3bf2eea 100644 --- a/src/wait_for_deps.py +++ b/src/wait_for_deps.py @@ -130,7 +130,13 @@ def main(): version_match = re.search(MICKA_VERSION_RE, response) assert (version_match and len(version_match.groups()) == 2), 'Unknown version of Micka!' found_version = version_match.groups() - assert found_version in settings.MICKA_ACCEPTED_VERSION, f"Found Micka version {found_version}, but expecting one of {settings.MICKA_ACCEPTED_VERSION}. Please use one of expected version, e.g. by upgrading/downgrading Micka. Take special care about Micka's database." + err_message = f"Found Micka version {found_version}, but expecting version fulfilling {settings.MICKA_ACCEPTED_VERSION}. Please use one of expected version, e.g. by upgrading/downgrading Micka. Take special care about Micka's database." + if settings.MICKA_ACCEPTED_VERSION[0] == '>=': + assert found_version[0] >= settings.MICKA_ACCEPTED_VERSION[1] and found_version[1] >= settings.MICKA_ACCEPTED_VERSION[2], err_message + elif settings.MICKA_ACCEPTED_VERSION[0] in ('==', ''): + assert found_version == settings.MICKA_ACCEPTED_VERSION[1:], err_message + else: + raise NotImplementedError(f"Unknown Micka version comparision: {settings.MICKA_ACCEPTED_VERSION[0]}") print(f"Found Micka version {found_version}.") print(f"Attempt {attempt}/{MAX_ATTEMPTS} successful.")