未验证 提交 f364580c 编写于 作者: R Roger Light 提交者: GitHub

Merge pull request #587 from hildogjr/Fix_None_comparation

Fix None comparation as PEP
......@@ -135,7 +135,7 @@ Here is a very simple example that subscribes to the broker $SYS topic tree and
client.on_connect = on_connect
client.on_message = on_message
client.connect("mqtt.eclipse.org", 1883, 60)
client.connect("mqtt.eclipseprojects.io", 1883, 60)
# Blocking call that processes network traffic, dispatches callbacks and
# handles reconnecting.
......@@ -191,7 +191,7 @@ userdata
protocol
the version of the MQTT protocol to use for this client. Can be either
``MQTTv31`` or ``MQTTv311``
``MQTTv31``, ``MQTTv311`` or ``MQTTv5``
transport
set to "websockets" to send MQTT over WebSockets. Leave at the default of
......@@ -476,7 +476,7 @@ Connect Example
.. code:: python
mqttc.connect("mqtt.eclipse.org")
mqttc.connect("mqtt.eclipseprojects.io")
connect_async()
'''''''''''''''
......@@ -613,7 +613,7 @@ Loop Start/Stop Example
.. code:: python
mqttc.connect("mqtt.eclipse.org")
mqttc.connect("mqtt.eclipseprojects.io")
mqttc.loop_start()
while True:
......@@ -1245,7 +1245,8 @@ tls
Defaults to None, which indicates that TLS should not be used.
protocol
choose the version of the MQTT protocol to use. Use either ``MQTTv31`` or ``MQTTv311``.
choose the version of the MQTT protocol to use. Use either ``MQTTv31``,
``MQTTv311``, or ``MQTTv5`.
transport
set to "websockets" to send MQTT over WebSockets. Leave at the default of
......@@ -1258,7 +1259,7 @@ Publish Single Example
import paho.mqtt.publish as publish
publish.single("paho/test/single", "payload", hostname="mqtt.eclipse.org")
publish.single("paho/test/single", "payload", hostname="mqtt.eclipseprojects.io")
Multiple
````````
......@@ -1299,7 +1300,7 @@ Publish Multiple Example
msgs = [{'topic':"paho/test/multiple", 'payload':"multiple 1"},
("paho/test/multiple", "multiple 2", 0, False)]
publish.multiple(msgs, hostname="mqtt.eclipse.org")
publish.multiple(msgs, hostname="mqtt.eclipseprojects.io")
Subscribe
......@@ -1388,7 +1389,8 @@ tls
Defaults to None, which indicates that TLS should not be used.
protocol
choose the version of the MQTT protocol to use. Use either ``MQTTv31`` or ``MQTTv311``.
choose the version of the MQTT protocol to use. Use either ``MQTTv31``,
``MQTTv311``, or ``MQTTv5``.
Simple Example
......@@ -1398,7 +1400,7 @@ Simple Example
import paho.mqtt.subscribe as subscribe
msg = subscribe.simple("paho/test/simple", hostname="mqtt.eclipse.org")
msg = subscribe.simple("paho/test/simple", hostname="mqtt.eclipseprojects.io")
print("%s %s" % (msg.topic, msg.payload))
Using Callback
......@@ -1447,7 +1449,7 @@ Callback Example
def on_message_print(client, userdata, message):
print("%s %s" % (message.topic, message.payload))
subscribe.callback(on_message_print, "paho/test/callback", hostname="mqtt.eclipse.org")
subscribe.callback(on_message_print, "paho/test/callback", hostname="mqtt.eclipseprojects.io")
Reporting bugs
......
......@@ -92,6 +92,6 @@ mqttc.on_connect = on_connect
# Uncomment to enable debug messages
#mqttc.on_log = on_log
#mqttc.connect("mqtt.eclipse.org", 1883, 60)
#mqttc.connect("mqtt.eclipseprojects.io", 1883, 60)
mqttc.connect(host="localhost", clean_start=False)
mqttc.loop_forever()
......@@ -23,4 +23,4 @@ import paho.mqtt.subscribe as subscribe
def print_msg(client, userdata, message):
print("%s : %s" % (message.topic, message.payload))
subscribe.callback(print_msg, "#", hostname="mqtt.eclipse.org")
subscribe.callback(print_msg, "#", hostname="mqtt.eclipseprojects.io")
......@@ -21,7 +21,7 @@ import paho.mqtt.subscribe as subscribe
topics = ['#']
m = subscribe.simple(topics, hostname="mqtt.eclipse.org", retained=False, msg_count=2)
m = subscribe.simple(topics, hostname="mqtt.eclipseprojects.io", retained=False, msg_count=2)
for a in m:
print(a.topic)
print(a.payload)
......@@ -601,10 +601,10 @@ class Client(object):
"""
if protocol == MQTTv5:
if clean_session != None:
if clean_session is not None:
raise ValueError('Clean session is not used for MQTT 5.0')
else:
if clean_session == None:
if clean_session is None:
clean_session = True
if not clean_session and (client_id == "" or client_id is None):
raise ValueError(
......@@ -1514,7 +1514,7 @@ class Client(object):
if qos < 0 or qos > 2:
raise ValueError('Invalid QoS level.')
if self._protocol == MQTTv5:
if options == None:
if options is None:
# if no options are provided, use the QoS passed instead
options = SubscribeOptions(qos=qos)
elif qos != 0:
......@@ -2686,7 +2686,7 @@ class Client(object):
remaining_length += 2
if self._protocol == MQTTv5:
if properties == None:
if properties is None:
packed_properties = b'\x00'
else:
packed_properties = properties.pack()
......@@ -2760,13 +2760,13 @@ class Client(object):
remaining_length += 2 + len(self._password)
if self._protocol == MQTTv5:
if self._connect_properties == None:
if self._connect_properties is None:
packed_connect_properties = b'\x00'
else:
packed_connect_properties = self._connect_properties.pack()
remaining_length += len(packed_connect_properties)
if self._will:
if self._will_properties == None:
if self._will_properties is None:
packed_will_properties = b'\x00'
else:
packed_will_properties = self._will_properties.pack()
......@@ -2848,11 +2848,11 @@ class Client(object):
packet.append(command)
if self._protocol == MQTTv5:
if properties != None or reasoncode != None:
if reasoncode == None:
if properties is not None or reasoncode is not None:
if reasoncode is None:
reasoncode = ReasonCodes(DISCONNECT >> 4, identifier=0)
remaining_length += 1
if properties != None:
if properties is not None:
packed_props = properties.pack()
remaining_length += len(packed_props)
......@@ -2869,7 +2869,7 @@ class Client(object):
def _send_subscribe(self, dup, topics, properties=None):
remaining_length = 2
if self._protocol == MQTTv5:
if properties == None:
if properties is None:
packed_subscribe_properties = b'\x00'
else:
packed_subscribe_properties = properties.pack()
......@@ -2906,7 +2906,7 @@ class Client(object):
def _send_unsubscribe(self, dup, topics, properties=None):
remaining_length = 2
if self._protocol == MQTTv5:
if properties == None:
if properties is None:
packed_unsubscribe_properties = b'\x00'
else:
packed_unsubscribe_properties = properties.pack()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册