diff --git a/dist/wzl_mqtt-1.1.3-py3-none-any.whl b/dist/wzl_mqtt-1.1.3-py3-none-any.whl deleted file mode 100644 index 3ea642156f20c9403dfda8372234194de6bacd44..0000000000000000000000000000000000000000 Binary files a/dist/wzl_mqtt-1.1.3-py3-none-any.whl and /dev/null differ diff --git a/dist/wzl_mqtt-1.2.0-py3-none-any.whl b/dist/wzl_mqtt-1.2.0-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..28d6ffd23e342e7972e8316012e5d24e42df39af Binary files /dev/null and b/dist/wzl_mqtt-1.2.0-py3-none-any.whl differ diff --git a/setup.py b/setup.py index d76d6b68a2b47fa5048f382f54721f6762c938ce..ce0e0eefb2cd66cde3069e53d22fa30f93f358cb 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup, find_packages setup(name='wzl-mqtt', - version='1.1.3', + version='1.2.0', url='', author='Benjamin Montavon, Matthias Bodenbenner', author_email='m.bodenbenner@wzl.rwth-aachen.de', diff --git a/wzl/mqtt/__init__.py b/wzl/mqtt/__init__.py index 221ffbd9e538d999e16582123aa8c990a8ce9ca5..f4795829a732babec5a31ae88bc4ed1e084fa615 100644 --- a/wzl/mqtt/__init__.py +++ b/wzl/mqtt/__init__.py @@ -11,4 +11,3 @@ from .exceptions import PublishError as PublishError from .client import MQTTPublisher from .client import MQTTReceiver -from .specialized import ScheduledMQTTPublisher diff --git a/wzl/mqtt/specialized.py b/wzl/mqtt/specialized.py deleted file mode 100644 index d6c68fa1540b296b7737834424f722e4feae3e98..0000000000000000000000000000000000000000 --- a/wzl/mqtt/specialized.py +++ /dev/null @@ -1,45 +0,0 @@ -import datetime -import json -from typing import Dict - -from .client import MQTTPublisher - - -class ScheduledMQTTPublisher(MQTTPublisher): - - def __init__(self, loop, duid, schedule: Dict, *args, **kwargs): - MQTTPublisher.__init__(self, duid, *args, **kwargs) - self._loop = loop - self._schedule = schedule - if len(self._schedule.keys()) > 0: - self._update() - - def _update(self): - now = datetime.datetime.now() - next = None - for luid in self._schedule: - data = self._schedule[luid] - if data['next'] is not None and data['next'] <= now: - try: - value = data['method']() - ret = {'uuid': luid, 'value': value} - self.publish(luid, json.dumps(ret), 1) - except Exception as e: - pass - - try: - if callable(data['interval']): - data['next'] = now + datetime.timedelta(seconds=data['interval']()) - else: - data['next'] = now + datetime.timedelta(seconds=data['interval']) - except Exception as e: - # if the next time for publishing can not be set, deactivate publising by setting 'next' to None - data['next'] = None - - if next is None or (data['next'] is not None and data['next'] < next): - next = data['next'] - - if next is None: - next = now + datetime.timedelta(seconds=10) - - self._loop.call_later((next - now).seconds + (next - now).microseconds / 1e6, self._update) \ No newline at end of file