Skip to content
Snippets Groups Projects
Commit 08786262 authored by Matthias Stefan Bodenbenner's avatar Matthias Stefan Bodenbenner
Browse files

2.6.0 - improved interaction with instances

parent 39680034
Branches
No related tags found
No related merge requests found
Pipeline #345714 passed
...@@ -115,4 +115,4 @@ venv.bak/ ...@@ -115,4 +115,4 @@ venv.bak/
logs/ logs/
private_testing/ private_test/
# WZL-MQTT # WZL-MQTT
Current stable version: 2.5.4 Current stable version: 2.6.0
## Documentation ## Documentation
...@@ -90,6 +90,10 @@ the European Union’s Horizon 2020 research and innovation programme and the EM ...@@ -90,6 +90,10 @@ the European Union’s Horizon 2020 research and innovation programme and the EM
## Changelog ## Changelog
**2.6.0** - 2024-01-10
- added the classmethod "client_names()" to client to retrieve the name of all instances
- the classmethod "get(username)" of the client raises the "ChildNotFoundError" if there is no instance having the specified username
**2.5.4** - 2023-04-18 **2.5.4** - 2023-04-18
- fixed usage of a randomized client_id, so that the same credentials can be used for multiple clients in parallel - fixed usage of a randomized client_id, so that the same credentials can be used for multiple clients in parallel
......
...@@ -4,7 +4,7 @@ with open("PyPI-README.md", "r", encoding="utf-8") as fh: ...@@ -4,7 +4,7 @@ with open("PyPI-README.md", "r", encoding="utf-8") as fh:
long_description = fh.read() long_description = fh.read()
setup(name='wzl-mqtt', setup(name='wzl-mqtt',
version='2.5.4', version='2.6.0',
url='https://git-ce.rwth-aachen.de/wzl-mq-public/iot/mqtt/', url='https://git-ce.rwth-aachen.de/wzl-mq-public/iot/mqtt/',
project_urls={ project_urls={
"Bug Tracker": "https://git-ce.rwth-aachen.de/wzl-mq-public/iot/mqtt/-/issues", "Bug Tracker": "https://git-ce.rwth-aachen.de/wzl-mq-public/iot/mqtt/-/issues",
......
...@@ -3,11 +3,11 @@ import sys ...@@ -3,11 +3,11 @@ import sys
import traceback import traceback
import uuid import uuid
import warnings import warnings
from typing import Callable, Union from typing import Callable, Union, List
import paho.mqtt.client as mqtt import paho.mqtt.client as mqtt
from .exceptions import ConnectionError from .exceptions import ConnectionError, ClientNotFoundError
from .exceptions import PublishError from .exceptions import PublishError
from .exceptions import SubscriptionError from .exceptions import SubscriptionError
from .logger import Logger from .logger import Logger
...@@ -69,8 +69,23 @@ class MQTTClient: ...@@ -69,8 +69,23 @@ class MQTTClient:
Returns: The client identified by the given key. Returns: The client identified by the given key.
Raises:
ChildNotFoundError: If no client with the given username could be found.
""" """
try:
return cls.instances[username] return cls.instances[username]
except KeyError:
raise ClientNotFoundError(f'There is no client with name "{username}".')
@classmethod
def client_names(cls) -> List[str]:
"""Returns al list of the usernames of all clients.
Returns: List of the usernames of all clients.
"""
return [key for key in cls.instances]
@property @property
def connected(self) -> bool: def connected(self) -> bool:
......
...@@ -21,3 +21,8 @@ class CallbackError(MQTTException): ...@@ -21,3 +21,8 @@ class CallbackError(MQTTException):
class PublishError(MQTTException): class PublishError(MQTTException):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
MQTTException.__init__(self, *args, **kwargs) MQTTException.__init__(self, *args, **kwargs)
class ClientNotFoundError(MQTTException):
def __init__(self, *args, **kwargs):
MQTTException.__init__(self, *args, **kwargs)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment