Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Jan 16, 2024
1 parent 51ca3f7 commit bbe4f7e
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions msc_wis2node/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,14 @@ def identify(self, path: str) -> Union[dict, None]:
"""

for dataset in self.datasets:
dirpath = self._subtopic2dirpath(dataset['subtopic'])
if dirpath.startswith(dirpath):
subtopic_dirpath = self._subtopic2dirpath(dataset['subtopic'])

if path.startswith(subtopic_dirpath):
LOGGER.debug('Found match')
return dataset

LOGGER.debug('No match found')

return None

def publish_to_wis2(self, dataset: str, url: str) -> None:
Expand All @@ -132,23 +135,22 @@ def publish_to_wis2(self, dataset: str, url: str) -> None:
url=url
)

print("MESSAGE", message)
LOGGER.debug(json.dumps(message, indent=4))
LOGGER.info('Publishing WIS2 notification message')

# publish.single(
# topic,
# payload=json.dumps(message),
# qos=1,
# hostname=self.hostname,
# port=self.port,
# client_id=self.client_id,
# tls=self.tls,
# auth={
# 'username': self.username,
# 'password': self.password
# }
# )
publish.single(
topic,
payload=json.dumps(message),
qos=1,
hostname=self.hostname,
port=self.port,
client_id=self.client_id,
tls=self.tls,
auth={
'username': self.username,
'password': self.password
}
)

def _subtopic2dirpath(self, subtopic: str) -> str:
"""
Expand All @@ -161,11 +163,12 @@ def _subtopic2dirpath(self, subtopic: str) -> str:

LOGGER.debug(f'AMQP subtopic: {subtopic}')

dirpath = subtopic.replace('.', '/').rstrip('/#')
dirpath = '/' + subtopic.replace('.', '/').rstrip('/#')

LOGGER.debug(f'directory path: {dirpath}')

return dirpath

def __repr__(self):

return '<WIS2Publisher>'

0 comments on commit bbe4f7e

Please sign in to comment.