From a2b39f75707482b2f611595ab5bbc8fd3a55d151 Mon Sep 17 00:00:00 2001 From: Maaike Date: Wed, 13 Mar 2024 10:54:14 +0100 Subject: [PATCH] add requested changes --- wis2box-management/Dockerfile | 2 ++ wis2box-management/wis2box/api/__init__.py | 2 +- wis2box-management/wis2box/data/bufr2geojson.py | 4 ++-- wis2box-management/wis2box/pubsub/subscribe.py | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/wis2box-management/Dockerfile b/wis2box-management/Dockerfile index b4768baf..c1ae855e 100644 --- a/wis2box-management/Dockerfile +++ b/wis2box-management/Dockerfile @@ -21,6 +21,8 @@ FROM ubuntu:focal +LABEL maintainer="tomkralidis@gmail.com; mlimper@wmo.int" + ARG WIS2BOX_PIP3_EXTRA_PACKAGES ENV TZ="Etc/UTC" \ DEBIAN_FRONTEND="noninteractive" \ diff --git a/wis2box-management/wis2box/api/__init__.py b/wis2box-management/wis2box/api/__init__.py index 1405a936..3312667f 100644 --- a/wis2box-management/wis2box/api/__init__.py +++ b/wis2box-management/wis2box/api/__init__.py @@ -80,7 +80,7 @@ def execute_api_process(process_name: str, payload: dict) -> dict: location = location.replace(API_URL, DOCKER_API_URL) status = 'accepted' - while status == 'accepted' or status == 'running': + while status in ['accepted', 'running']: # get the job status headers = { 'accept': 'application/json', diff --git a/wis2box-management/wis2box/data/bufr2geojson.py b/wis2box-management/wis2box/data/bufr2geojson.py index 7335a1ec..a9b81141 100644 --- a/wis2box-management/wis2box/data/bufr2geojson.py +++ b/wis2box-management/wis2box/data/bufr2geojson.py @@ -59,11 +59,11 @@ def transform(self, input_data: Union[Path, bytes], result = execute_api_process(process_name, payload) # check for errors - if 'error' in result and result['error'] != '': + if result.get('error') not in [None, '']: LOGGER.error(result['error']) if 'items' not in result: - LOGGER.error(f'file={filename} failed to convert to geojson') + LOGGER.error(f'file={filename} failed to convert to GeoJSON') return False # loop over items in response diff --git a/wis2box-management/wis2box/pubsub/subscribe.py b/wis2box-management/wis2box/pubsub/subscribe.py index b6694e8a..5646e014 100644 --- a/wis2box-management/wis2box/pubsub/subscribe.py +++ b/wis2box-management/wis2box/pubsub/subscribe.py @@ -121,7 +121,7 @@ def on_message_handler(self, client, userdata, msg): while len(mp.active_children()) == mp.cpu_count(): sleep(0.1) mp.Process(target=self.handle, args=(filepath,)).start() - elif (topic == 'wis2box/data/publication'): + elif topic == 'wis2box/data/publication': LOGGER.debug('Publishing data') self.handle_publish(message) elif topic == 'wis2box/data_mappings/refresh':