Skip to content

Commit

Permalink
fix MessageData-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
maaikelimper committed Mar 12, 2024
1 parent 338629e commit ae0beba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
8 changes: 4 additions & 4 deletions wis2box-management/wis2box/data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ def __init__(self, defs: dict) -> None:
self.filename = None
self.incoming_filepath = None
self.topic_hierarchy = TopicHierarchy(defs['topic_hierarchy'])
self.template = defs['template']
self.file_filter = defs['pattern']
self.enable_notification = defs['notify']
self.buckets = defs['buckets']
self.template = defs.get('template', None)
self.file_filter = defs.get('pattern', '.*')
self.enable_notification = defs.get('notify', False)
self.buckets = defs.get('buckets', ())
self.output_data = {}
self.discovery_metadata = {}
# if discovery_metadata:
Expand Down
9 changes: 6 additions & 3 deletions wis2box-management/wis2box/data/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ class MessageData(BaseAbstractData):
"""

def __init__(self, defs: dict) -> None:
self._meta = defs['_meta']
# remove _meta from defs before passing to super
defs.pop('_meta')
try:
self._meta = defs['_meta']
except KeyError:
error = f'No _meta in defs: {defs}'
LOGGER.error(error)
raise KeyError(error)
super().__init__(defs)

def transform(self, input_data: Union[Path, bytes],
Expand Down
4 changes: 2 additions & 2 deletions wis2box-management/wis2box/pubsub/subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def handle(self, filepath):
raise err

def handle_publish(self, message):
LOGGER.debug('Loading DataPublish plugin')
LOGGER.debug('Loading MessageData plugin to publish data from message') # noqa
defs = {
'topic_hierarchy': message['channel'].replace('origin/a/wis2/', ''), # noqa
'_meta': message['_meta'],
Expand All @@ -87,7 +87,7 @@ def handle_publish(self, message):
input_bytes = base64.b64decode(message['data'].encode('utf-8'))
plugin.transform(
input_data=input_bytes,
filename=self.filepath.split('/')[-1]
filename=message['filename']
)
except Exception as err:
msg = f'MessageData-transform failed: {err}'
Expand Down

0 comments on commit ae0beba

Please sign in to comment.