From 49c4e5fdf872f440ef81ac40eb66493ca9a53a78 Mon Sep 17 00:00:00 2001 From: Maaike Date: Wed, 22 May 2024 21:01:49 +0200 Subject: [PATCH] add incoming filepath and identifier to failure message --- wis2box-management/wis2box/data/base.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wis2box-management/wis2box/data/base.py b/wis2box-management/wis2box/data/base.py index 6026f5d3..95972658 100644 --- a/wis2box-management/wis2box/data/base.py +++ b/wis2box-management/wis2box/data/base.py @@ -51,7 +51,7 @@ def __init__(self, defs: dict) -> None: LOGGER.debug('Parsing resource mappings') self.filename = None - self.incoming_filepath = None + self.incoming_filepath = defs.get('incoming_filepath', None) self.metadata_id = defs.get('metadata_id', None) self.topic_hierarchy = defs.get('topic_hierarchy', None) self.template = defs.get('template', None) @@ -63,9 +63,10 @@ def __init__(self, defs: dict) -> None: # if discovery_metadata: # self.setup_discovery_metadata(discovery_metadata) - def publish_failure_message(self, description, wsi=None): + def publish_failure_message(self, description, wsi=None, identifier=None): message = { - 'filepath': self.incoming_filepath, + 'incoming_filepath': self.incoming_filepath, + 'identifier': identifier, 'description': description } if wsi is not None: @@ -246,12 +247,10 @@ def publish_item(self, identifier, item) -> bool: if self.enable_notification and is_new: LOGGER.debug('Sending notification to broker') - try: datetime_ = item['_meta']['properties']['datetime'] except KeyError: datetime_ = item['_meta'].get('data_date') - self.notify(identifier, storage_path, datetime_, item['_meta'].get('geometry'), wsi, is_update) @@ -259,9 +258,10 @@ def publish_item(self, identifier, item) -> bool: LOGGER.debug('No notification sent') except Exception as err: msg = f'Failed to publish item {identifier}: {err}' - LOGGER.error(msg, exc_info=True) + LOGGER.error(msg) self.publish_failure_message( description='Failed to publish item', + identifier=identifier, wsi=wsi) return True