From a2025b8749e7b9e7f3be5326eba3ba7201ec0aed Mon Sep 17 00:00:00 2001 From: Anmol Sarma Date: Sun, 14 Feb 2016 17:07:50 +0530 Subject: [PATCH] Replace deprecated python mosquitto library with paho-mqtt --- README.md | 3 +-- beem/listen.py | 6 +++--- beem/load.py | 4 ++-- setup.py | 2 +- tox.ini | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5623d34..7313f36 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,7 @@ of MQTT environments. Contributions welcome! -Requires mosquitto python library 1.x or greater. (1.2 will give arguably -better performance as the "max messages in flight" parameter can be tweaked) +Requires paho-mqtt python library The tools are in multiple layers: diff --git a/beem/listen.py b/beem/listen.py index 43dca05..e7a3554 100644 --- a/beem/listen.py +++ b/beem/listen.py @@ -38,7 +38,7 @@ import time import fuse -import mosquitto +import paho.mqtt.client as paho from beem.trackers import ObservedMessage as MsgStatus @@ -55,7 +55,7 @@ def __init__(self, host, port, opts): self.options = opts self.cid = opts.clientid self.log = logging.getLogger(__name__ + ":" + self.cid) - self.mqttc = mosquitto.Mosquitto(self.cid) + self.mqttc = paho.Mosquitto(self.cid) self.mqttc.on_message = self.msg_handler self.listen_topic = opts.topic self.time_start = None @@ -265,7 +265,7 @@ def init(self, path): print("listener post init init(), path=", path) self.cid = self.options.clientid self.log = logging.getLogger(__name__ + ":" + self.cid) - self.mqttc = mosquitto.Mosquitto(self.cid) + self.mqttc = paho.Mosquitto(self.cid) self.mqttc.on_message = self.msg_handler self.listen_topics = self.options.topic # TODO - you _probably_ want to tweak this diff --git a/beem/load.py b/beem/load.py index 794883f..7fe1173 100644 --- a/beem/load.py +++ b/beem/load.py @@ -33,7 +33,7 @@ import math import time -import mosquitto +import paho.mqtt.client as paho from beem.trackers import SentMessage as MsgStatus @@ -63,7 +63,7 @@ class TrackingSender(): def __init__(self, host, port, cid): self.cid = cid self.log = logging.getLogger(__name__ + ":" + cid) - self.mqttc = mosquitto.Mosquitto(cid) + self.mqttc = paho.Mosquitto(cid) self.mqttc.on_publish = self.publish_handler # TODO - you _probably_ want to tweak this if hasattr(self.mqttc, "max_inflight_messages_set"): diff --git a/setup.py b/setup.py index 89f2989..883caa4 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def read(fname): include_package_data=True, zip_safe=False, install_requires=[ - 'mosquitto>=1.0', + 'paho-mqtt', 'fusepy' ], tests_require=[ diff --git a/tox.ini b/tox.ini index ff42bb2..e6f9eec 100644 --- a/tox.ini +++ b/tox.ini @@ -10,4 +10,4 @@ envlist = py27, py33 [testenv] commands = {envpython} setup.py test deps = - mosquitto>=1.0 + paho-mqtt