Skip to content

Commit

Permalink
Prefixes '>=' or '==' can be used in MICKA_ACCEPTED_VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
index-git committed Nov 2, 2021
1 parent 03bd298 commit c8bf4bf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion doc/env-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 fo '>=' or '==' prefixes can be used with obvious meaning. 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. `<domain>` or `<domain>:<port>`. Passed as configuration to Micka for demo purposes.
Expand Down
12 changes: 7 additions & 5 deletions src/layman_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,13 @@
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<operation>==|>=|)(?P<version>[0-9.]+):(?P<revision>[0-9-.]+)$"
MICKA_REGEXP_MATCH = re.search(MICKA_REGEXP, os.getenv('MICKA_ACCEPTED_VERSION', '')) or re.search(MICKA_REGEXP,
'=sgdf=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

Expand Down
8 changes: 7 additions & 1 deletion src/wait_for_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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], settings.MICKA_ACCEPTED_VERSION[2]), 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.")
Expand Down

0 comments on commit c8bf4bf

Please sign in to comment.