Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Eclipse Foundation
paho.mqtt.python
提交
2488554a
P
paho.mqtt.python
项目概览
镜像
/
Eclipse Foundation
/
paho.mqtt.python
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
2488554a
编写于
5月 02, 2017
作者:
P
Pierre Fersing
提交者:
GitHub
5月 02, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #189 from Nzbuu/tidy-develop
Tidy develop branch
上级
c8efe1ba
5f29f370
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
24 addition
and
34 deletion
+24
-34
ChangeLog.txt
ChangeLog.txt
+3
-2
src/paho/mqtt/__init__.py
src/paho/mqtt/__init__.py
+2
-1
src/paho/mqtt/client.py
src/paho/mqtt/client.py
+8
-22
test/paho_test.py
test/paho_test.py
+4
-2
tests/test_client.py
tests/test_client.py
+7
-7
未找到文件。
ChangeLog.txt
浏览文件 @
2488554a
v
2
.x - 2017-xx-xx
v
1.3
.x - 2017-xx-xx
=================
- **BREAKING** Requires Python 2.7 or 3.4+. Closes #163.
- Allow username and password to be zero length (as opposed to not being
present). Closes #80.
- Allow zero length client ids when using MQTT v3.1.1.
- Add SSLContext support, including SNI. Closes #11.
- Remove support for SSL without SSLContext (Requires Python 2.7.9+ or 3.2+).
Closes #115.
- Move unit tests to pytest (#164)
- Move unit tests to pytest (#164)
and tox (#187)
v1.2.2 - 2017-04-11
===================
...
...
src/paho/mqtt/__init__.py
浏览文件 @
2488554a
__version__
=
"1.2.2"
__version__
=
"1.3.0.dev0"
class
MQTTException
(
Exception
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
src/paho/mqtt/client.py
浏览文件 @
2488554a
...
...
@@ -59,17 +59,9 @@ if platform.system() == 'Windows':
else
:
EAGAIN
=
errno
.
EAGAIN
VERSION_MAJOR
=
1
VERSION_MINOR
=
2
VERSION_REVISION
=
2
VERSION_NUMBER
=
(
VERSION_MAJOR
*
1000000
+
VERSION_MINOR
*
1000
+
VERSION_REVISION
)
MQTTv31
=
3
MQTTv311
=
4
PROTOCOL_NAMEv31
=
"MQIsdp"
PROTOCOL_NAMEv311
=
"MQTT"
if
sys
.
version_info
[
0
]
>=
3
:
# define some alias for python2 compatibility
unicode
=
str
...
...
@@ -150,10 +142,7 @@ MQTT_ERR_UNKNOWN = 13
MQTT_ERR_ERRNO
=
14
MQTT_ERR_QUEUE_SIZE
=
15
if
sys
.
version_info
[
0
]
<
3
:
sockpair_data
=
"0"
else
:
sockpair_data
=
b
"0"
sockpair_data
=
b
"0"
class
WebsocketConnectionError
(
ValueError
):
...
...
@@ -263,7 +252,7 @@ def _socketpair_compat():
return
(
sock1
,
sock2
)
class
MQTTMessageInfo
:
class
MQTTMessageInfo
(
object
)
:
"""This is a class returned from Client.publish() and can be used to find
out the mid of the message that was published, and to determine whether the
message has been published, and/or wait until it is published.
...
...
@@ -324,7 +313,7 @@ class MQTTMessageInfo:
return
self
.
_published
class
MQTTMessage
:
class
MQTTMessage
(
object
)
:
""" This is a class that describes an incoming or outgoing message. It is
passed to the on_message callback as the message parameter.
...
...
@@ -2046,14 +2035,11 @@ class Client(object):
return
self
.
_packet_queue
(
command
,
packet
,
0
,
0
)
def
_send_connect
(
self
,
keepalive
,
clean_session
):
if
self
.
_protocol
==
MQTTv31
:
protocol
=
PROTOCOL_NAMEv31
proto_ver
=
3
else
:
protocol
=
PROTOCOL_NAMEv311
proto_ver
=
4
protocol
=
protocol
.
encode
(
'utf-8'
)
proto_ver
=
self
.
_protocol
protocol
=
b
"MQTT"
if
proto_ver
>=
MQTTv311
else
b
"MQIsdp"
# hard-coded UTF-8 encoded string
remaining_length
=
2
+
len
(
protocol
)
+
1
+
1
+
2
+
2
+
len
(
self
.
_client_id
)
connect_flags
=
0
if
clean_session
:
connect_flags
|=
0x02
...
...
@@ -2583,7 +2569,7 @@ class Mosquitto(Client):
super
(
Mosquitto
,
self
).
__init__
(
client_id
,
clean_session
,
userdata
)
class
WebsocketWrapper
:
class
WebsocketWrapper
(
object
)
:
OPCODE_CONTINUATION
=
0x0
OPCODE_TEXT
=
0x1
OPCODE_BINARY
=
0x2
...
...
test/paho_test.py
浏览文件 @
2488554a
...
...
@@ -248,7 +248,9 @@ def to_string(packet):
def
gen_connect
(
client_id
,
clean_session
=
True
,
keepalive
=
60
,
username
=
None
,
password
=
None
,
will_topic
=
None
,
will_qos
=
0
,
will_retain
=
False
,
will_payload
=
""
,
proto_name
=
"MQTT"
,
proto_ver
=
4
):
will_retain
=
False
,
will_payload
=
""
,
proto_name
=
None
,
proto_ver
=
4
):
proto_name
=
b
"MQTT"
if
proto_ver
>=
4
else
b
"MQIsdp"
if
client_id
is
None
:
remaining_length
=
12
else
:
...
...
@@ -277,7 +279,7 @@ def gen_connect(client_id, clean_session=True, keepalive=60, username=None, pass
rl
=
pack_remaining_length
(
remaining_length
)
packet
=
struct
.
pack
(
"!B"
+
str
(
len
(
rl
))
+
"s"
,
0x10
,
rl
)
packet
=
packet
+
struct
.
pack
(
"!H"
+
str
(
len
(
proto_name
))
+
"sBBH"
,
len
(
proto_name
),
proto_name
.
encode
(
'utf-8'
)
,
len
(
proto_name
),
proto_name
,
proto_ver
,
connect_flags
,
keepalive
)
if
client_id
is
not
None
:
packet
=
packet
+
struct
.
pack
(
"!H"
+
str
(
len
(
client_id
))
+
"s"
,
len
(
client_id
),
client_id
)
...
...
tests/test_client.py
浏览文件 @
2488554a
...
...
@@ -20,16 +20,16 @@ import paho_test
from
testsupport.broker
import
fake_broker
@
pytest
.
mark
.
parametrize
(
"proto_ver
,proto_name
"
,
[
(
client
.
MQTTv31
,
"MQIsdp"
),
(
client
.
MQTTv311
,
"MQTT"
),
@
pytest
.
mark
.
parametrize
(
"proto_ver"
,
[
(
client
.
MQTTv31
),
(
client
.
MQTTv311
),
])
class
Test_connect
(
object
):
"""
Tests on connect/disconnect behaviour of the client
"""
def
test_01_con_discon_success
(
self
,
proto_ver
,
proto_name
,
fake_broker
):
def
test_01_con_discon_success
(
self
,
proto_ver
,
fake_broker
):
mqttc
=
client
.
Client
(
"01-con-discon-success"
,
protocol
=
proto_ver
)
...
...
@@ -47,7 +47,7 @@ class Test_connect(object):
connect_packet
=
paho_test
.
gen_connect
(
"01-con-discon-success"
,
keepalive
=
60
,
proto_
name
=
proto_name
,
proto_
ver
=
proto_ver
)
proto_ver
=
proto_ver
)
packet_in
=
fake_broker
.
receive_packet
(
1000
)
assert
packet_in
# Check connection was not closed
assert
packet_in
==
connect_packet
...
...
@@ -68,7 +68,7 @@ class Test_connect(object):
packet_in
=
fake_broker
.
receive_packet
(
1
)
assert
not
packet_in
# Check connection is closed
def
test_01_con_failure_rc
(
self
,
proto_ver
,
proto_name
,
fake_broker
):
def
test_01_con_failure_rc
(
self
,
proto_ver
,
fake_broker
):
mqttc
=
client
.
Client
(
"01-con-failure-rc"
,
protocol
=
proto_ver
)
...
...
@@ -85,7 +85,7 @@ class Test_connect(object):
connect_packet
=
paho_test
.
gen_connect
(
"01-con-failure-rc"
,
keepalive
=
60
,
proto_
name
=
proto_name
,
proto_
ver
=
proto_ver
)
proto_ver
=
proto_ver
)
packet_in
=
fake_broker
.
receive_packet
(
1000
)
assert
packet_in
# Check connection was not closed
assert
packet_in
==
connect_packet
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录