Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Eclipse Foundation
paho.mqtt.python
提交
f364580c
P
paho.mqtt.python
项目概览
镜像
/
Eclipse Foundation
/
paho.mqtt.python
10 个月 前同步成功
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
paho.mqtt.python
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
f364580c
编写于
7月 21, 2021
作者:
R
Roger Light
提交者:
GitHub
7月 21, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #587 from hildogjr/Fix_None_comparation
Fix None comparation as PEP
上级
97bfad04
b7022343
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
26 addition
and
24 deletion
+26
-24
README.rst
README.rst
+12
-10
examples/server_rpc_math.py
examples/server_rpc_math.py
+1
-1
examples/subscribe_callback.py
examples/subscribe_callback.py
+1
-1
examples/subscribe_simple.py
examples/subscribe_simple.py
+1
-1
src/paho/mqtt/client.py
src/paho/mqtt/client.py
+11
-11
未找到文件。
README.rst
浏览文件 @
f364580c
...
...
@@ -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.eclipse
projects.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.eclipse
projects.io
")
connect_async()
'''''''''''''''
...
...
@@ -613,7 +613,7 @@ Loop Start/Stop Example
.. code:: python
mqttc.connect("mqtt.eclipse
.org
")
mqttc.connect("mqtt.eclipse
projects.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.eclipse
projects.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.eclipse
projects.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.eclipse
projects.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.eclipse
projects.io
")
Reporting bugs
...
...
examples/server_rpc_math.py
浏览文件 @
f364580c
...
...
@@ -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.eclipse
projects.io
", 1883, 60)
mqttc
.
connect
(
host
=
"localhost"
,
clean_start
=
False
)
mqttc
.
loop_forever
()
examples/subscribe_callback.py
浏览文件 @
f364580c
...
...
@@ -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.eclipse
projects.io
"
)
examples/subscribe_simple.py
浏览文件 @
f364580c
...
...
@@ -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.eclipse
projects.io
"
,
retained
=
False
,
msg_count
=
2
)
for
a
in
m
:
print
(
a
.
topic
)
print
(
a
.
payload
)
src/paho/mqtt/client.py
浏览文件 @
f364580c
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录