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

increased verbosity in case of errors

parent aab93882
Branches stable
No related tags found
No related merge requests found
FROM python:3.9 as build-stage
RUN mkdir /home/doc
WORKDIR /home
RUN mkdir /home/src
COPY ./requirements.txt .
COPY ./src /home/src
RUN pip3 install -r requirements.txt
WORKDIR /home/doc
COPY ./doc .
RUN make html
FROM nginx
COPY --from=build-stage /home/doc/build/html /usr/share/nginx/html
# WZL-MQTT # WZL-MQTT
[![pipeline status](https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/digital-mars/mqtt/badges/master/pipeline.svg)](https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/digital-mars/mqtt/badges/master) [![pipeline status](https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/digital-mars/mqtt/badges/master/pipeline.svg)](https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/digital-mars/mqtt/badges/master)
Current stable version: 2.5.0 Current stable version: 2.5.1
## Documentation ## Documentation
...@@ -84,6 +84,9 @@ Slightly more detailled examples can be found in the *sample* directory. ...@@ -84,6 +84,9 @@ Slightly more detailled examples can be found in the *sample* directory.
If there are any questions contact [Matthias Bodenbenner](mailto:m.bodenbenner@wzl-mq.rwth-aachen.de). If there are any questions contact [Matthias Bodenbenner](mailto:m.bodenbenner@wzl-mq.rwth-aachen.de).
## Changelog ## Changelog
2.5.1
- increased verbosity in case of errors by including the full stack trace
2.5.0 2.5.0
- changed signature of connect method - changed signature of connect method
- specifying the port is optional now, if not specified the port automatically is derived from the "websocket" and "ssl" flags - specifying the port is optional now, if not specified the port automatically is derived from the "websocket" and "ssl" flags
......
server {
listen 80;
listen [::]:80;
server_name iot.wzl-mq.rwth-aachen.de;
location /documentation/libs/mqtt {
alias /usr/share/nginx/html;
index index.html index.htm;
}
}
\ No newline at end of file
FROM python:3.9 as build-stage
RUN mkdir /home/doc
COPY ../requirements.txt /home/doc
WORKDIR /home/doc
RUN pip install -r requirements.txt
COPY . /home/doc
RUN make html
FROM nginx
COPY --from=build-stage /home/app/doc/build/html /usr/share/nginx/html
server {
listen 80;
listen [::]:80;
server_name iot.wzl-mq.rwth-aachen.de;
location /documentation/libs/mqtt {
alias /usr/share/nginx/html;
index index.html index.htm;
}
}
\ No newline at end of file
version: '3'
services:
mqtt-documenation:
build: .
container_name: documentation-mqtt
networks:
- documentation-network
volumes:
- ./default.conf:/etc/nginx/conf.d/default.conf
ports:
- 9010:80
restart: unless-stopped
networks:
documentation-network:
external: true
\ No newline at end of file
version: '3'
services:
mqtt-documenation:
image: registry.git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/digital-mars/mqtt:latest
container_name: documentation-mqtt
networks:
- documentation-network
volumes:
- ./default.conf:/etc/nginx/conf.d/default.conf
ports:
- 9010:80
restart: unless-stopped
networks:
documentation-network:
external: true
\ No newline at end of file
from setuptools import setup, find_packages from setuptools import setup, find_packages
setup(name='wzl-mqtt', setup(name='wzl-mqtt',
version='2.5.0', version='2.5.1',
url='', url='',
author='Matthias Bodenbenner, Benjamin Montavon', author='Matthias Bodenbenner, Benjamin Montavon',
author_email='m.bodenbenner@wzl-mq.rwth-aachen.de', author_email='m.bodenbenner@wzl-mq.rwth-aachen.de',
......
import inspect import inspect
import sys
import traceback
import uuid import uuid
import warnings import warnings
from typing import Callable, Union from typing import Callable, Union
import paho.mqtt.client as mqtt import paho.mqtt.client as mqtt
from .logger import Logger
from .exceptions import ConnectionError from .exceptions import ConnectionError
from .exceptions import PublishError from .exceptions import PublishError
from .exceptions import SubscriptionError from .exceptions import SubscriptionError
from .logger import Logger
class MQTTClient: class MQTTClient:
...@@ -126,7 +128,8 @@ class MQTTClient: ...@@ -126,7 +128,8 @@ class MQTTClient:
self._logger.error( self._logger.error(
"MQTT Client {} could not connect to {}:{} : {}".format( "MQTT Client {} could not connect to {}:{} : {}".format(
self.name, broker, port, str(exception))) self.name, broker, port, str(exception)))
raise ConnectionError(str(exception)) tb = sys.exc_info()[2]
raise ConnectionError(str(exception)).with_traceback(tb)
def disconnect(self): def disconnect(self):
"""Disconnects the client and closes the connection to the broker. """Disconnects the client and closes the connection to the broker.
...@@ -138,7 +141,8 @@ class MQTTClient: ...@@ -138,7 +141,8 @@ class MQTTClient:
self._logger.error( self._logger.error(
"MQTT Client {} could not disconnect: {}".format(self.name, "MQTT Client {} could not disconnect: {}".format(self.name,
str(exception))) str(exception)))
raise ConnectionError(str(exception)) tb = sys.exc_info()[2]
raise ConnectionError(str(exception)).with_traceback(tb)
def _on_connect(self, client, userdata, flags, rc): def _on_connect(self, client, userdata, flags, rc):
if rc == 0: if rc == 0:
...@@ -218,7 +222,8 @@ class MQTTPublisher(MQTTClient): ...@@ -218,7 +222,8 @@ class MQTTPublisher(MQTTClient):
"MQTT Client {} could not publish to {}: {}".format(self.name, "MQTT Client {} could not publish to {}: {}".format(self.name,
topic, topic,
str(exception))) str(exception)))
raise PublishError(str(exception)) tb = sys.exc_info()[2]
raise PublishError(str(exception)).with_traceback(tb)
def _on_publish(self, client, userdata, mid): def _on_publish(self, client, userdata, mid):
self._logger.debug( self._logger.debug(
...@@ -280,7 +285,8 @@ class MQTTSubscriber(MQTTClient): ...@@ -280,7 +285,8 @@ class MQTTSubscriber(MQTTClient):
"MQTT Client {} could not subscribe to {}: {}".format(self.name, "MQTT Client {} could not subscribe to {}: {}".format(self.name,
topic, topic,
str(exception))) str(exception)))
raise SubscriptionError(str(exception)) tb = sys.exc_info()[2]
raise SubscriptionError(str(exception)).with_traceback(tb)
def unsubscribe(self, topic: str): def unsubscribe(self, topic: str):
"""Unsubscribes to updates of the given topic. """Unsubscribes to updates of the given topic.
...@@ -306,7 +312,8 @@ class MQTTSubscriber(MQTTClient): ...@@ -306,7 +312,8 @@ class MQTTSubscriber(MQTTClient):
self._logger.error( self._logger.error(
"MQTT Client {} could not unsubscribe from {}: {}".format( "MQTT Client {} could not unsubscribe from {}: {}".format(
self.name, topic, str(exception))) self.name, topic, str(exception)))
raise SubscriptionError(str(exception)) tb = sys.exc_info()[2]
raise SubscriptionError(str(exception)).with_traceback(tb)
def set_callback(self, key: str, function: Callable): def set_callback(self, key: str, function: Callable):
"""Add a callback called at each received message. """Add a callback called at each received message.
...@@ -370,6 +377,7 @@ class MQTTSubscriber(MQTTClient): ...@@ -370,6 +377,7 @@ class MQTTSubscriber(MQTTClient):
try: try:
self._on_message_callbacks[key](message.topic, message.payload) self._on_message_callbacks[key](message.topic, message.payload)
except Exception as exception: except Exception as exception:
self._logger.error(traceback.format_exc())
self._logger.error( self._logger.error(
"Exception while processing callback for topic {}: {}".format( "Exception while processing callback for topic {}: {}".format(
message.topic, str(exception))) message.topic, str(exception)))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment