From 3a7c80a0f7347671262d2197b4abe80c107c7fc0 Mon Sep 17 00:00:00 2001 From: Zhiwei Date: Fri, 16 Apr 2021 18:54:18 -0700 Subject: [PATCH 1/4] Fix Code in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 411639a..eb5796b 100644 --- a/README.md +++ b/README.md @@ -397,7 +397,7 @@ Publish messages to a topic. ```python from clearblade.ClearBladeCore import System -import random +import random, time # System credentials SystemKey = "9abbd2970baabf8aa6d2a9abcc47" @@ -420,7 +420,7 @@ for i in range(20): payload = "yo" else: payload = "ho" - client.publish("keelhauled", payload) + mqtt.publish("keelhauled", payload) time.sleep(1) mqtt.disconnect() From 0c134165c9edcbbd768cfc2ad0393905a3451fd0 Mon Sep 17 00:00:00 2001 From: skysharma Date: Tue, 14 Jun 2022 13:12:22 -0500 Subject: [PATCH 2/4] MQTT supports publishing messages with string or byte payloads. But our logging module only supports strings. Hence replaced line 37 with code that stringified message when possible. --- clearblade/Messaging.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/clearblade/Messaging.py b/clearblade/Messaging.py index 0c12c63..45ea568 100644 --- a/clearblade/Messaging.py +++ b/clearblade/Messaging.py @@ -134,5 +134,13 @@ def unsubscribe(self, channel): self.__mqttc.unsubscribe(channel) def publish(self, channel, message, qos=0, retain=False): - cbLogs.info("Publishing", message, "to", channel, ".") + msgType = type(message).__name__ + try: + if msgType == "str": + logMsg = message + else: + logMsg = str(message) + except: + logMsg = "unstringifiable object" + cbLogs.info("Publishing", logMsg, "to", channel, ".") self.__mqttc.publish(channel, message, qos, retain) From eb4c8eae1b17d41266645dd8c2c08e52094a3ed3 Mon Sep 17 00:00:00 2001 From: Akash Sharma Date: Tue, 14 Jun 2022 13:16:01 -0500 Subject: [PATCH 3/4] Update README.md Added comment explaining when using Messaging.publish() the type of message can be string or bytes. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eb5796b..380787f 100644 --- a/README.md +++ b/README.md @@ -351,7 +351,7 @@ You can subscribe to as many topics as you like, and subsequently unsubscribe fr > Definition: `Messaging.unsubscribe(topic)` > Returns: Nothing. -Lastly, publishing takes the topic to publish to, and the message to publish as arguments. +Lastly, publishing takes the topic to publish to, and the message to publish as arguments. The type of message can be string or bytes. > Definition: `Messaging.publish(topic, message)` > Returns: Nothing. From a3c998ff8374c3fee4c73293751888bf926f6c64 Mon Sep 17 00:00:00 2001 From: skysharma Date: Tue, 14 Jun 2022 13:22:52 -0500 Subject: [PATCH 4/4] PythonSDK setup.py: 2.4.0 -> 2.4.1 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 2bd2468..3de4b40 100644 --- a/setup.py +++ b/setup.py @@ -4,10 +4,10 @@ name='clearblade', packages=['clearblade'], install_requires=['requests', 'paho-mqtt>=1.3.0'], - version='2.4.0', + version='2.4.1', description='A Python SDK for interacting with the ClearBlade Platform.', url='https://github.com/ClearBlade/ClearBlade-Python-SDK', - download_url='https://github.com/ClearBlade/ClearBlade-Python-SDK/archive/v2.4.0.tar.gz', + download_url='https://github.com/ClearBlade/ClearBlade-Python-SDK/archive/v2.4.1.tar.gz', keywords=['clearblade', 'iot', 'sdk'], maintainer='Aaron Allsbrook', maintainer_email='dev@clearblade.com'