Skip to content

Commit

Permalink
add incoming filepath and identifier to failure message
Browse files Browse the repository at this point in the history
  • Loading branch information
maaikelimper committed May 22, 2024
1 parent e82068b commit 49c4e5f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions wis2box-management/wis2box/data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -246,22 +247,21 @@ 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)
else:
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

Expand Down

0 comments on commit 49c4e5f

Please sign in to comment.