mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-08 06:00:51 -07:00
Update paho-mqtt==1.6.1
This commit is contained in:
parent
d981f6e51f
commit
966a6696d1
9 changed files with 680 additions and 502 deletions
|
@ -1,4 +1,4 @@
|
||||||
__version__ = "1.5.1"
|
__version__ = "1.6.1"
|
||||||
|
|
||||||
|
|
||||||
class MQTTException(Exception):
|
class MQTTException(Exception):
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
||||||
Copyright (c) 2017, 2019 IBM Corp.
|
Copyright (c) 2017, 2019 IBM Corp.
|
||||||
|
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are made available under the terms of the Eclipse Public License v1.0
|
are made available under the terms of the Eclipse Public License v2.0
|
||||||
and Eclipse Distribution License v1.0 which accompany this distribution.
|
and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||||
|
|
||||||
The Eclipse Public License is available at
|
The Eclipse Public License is available at
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Copyright (c) 2017, 2019 IBM Corp.
|
Copyright (c) 2017, 2019 IBM Corp.
|
||||||
|
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are made available under the terms of the Eclipse Public License v1.0
|
are made available under the terms of the Eclipse Public License v2.0
|
||||||
and Eclipse Distribution License v1.0 which accompany this distribution.
|
and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||||
|
|
||||||
The Eclipse Public License is available at
|
The Eclipse Public License is available at
|
||||||
|
@ -16,7 +16,8 @@
|
||||||
*******************************************************************
|
*******************************************************************
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys, struct
|
import struct
|
||||||
|
import sys
|
||||||
|
|
||||||
from .packettypes import PacketTypes
|
from .packettypes import PacketTypes
|
||||||
|
|
||||||
|
@ -268,6 +269,30 @@ class Properties(object):
|
||||||
if self.packetType not in self.properties[self.getIdentFromName(name)][1]:
|
if self.packetType not in self.properties[self.getIdentFromName(name)][1]:
|
||||||
raise MQTTException("Property %s does not apply to packet type %s"
|
raise MQTTException("Property %s does not apply to packet type %s"
|
||||||
% (name, PacketTypes.Names[self.packetType]))
|
% (name, PacketTypes.Names[self.packetType]))
|
||||||
|
|
||||||
|
# Check for forbidden values
|
||||||
|
if type(value) != type([]):
|
||||||
|
if name in ["ReceiveMaximum", "TopicAlias"] \
|
||||||
|
and (value < 1 or value > 65535):
|
||||||
|
|
||||||
|
raise MQTTException(
|
||||||
|
"%s property value must be in the range 1-65535" % (name))
|
||||||
|
elif name in ["TopicAliasMaximum"] \
|
||||||
|
and (value < 0 or value > 65535):
|
||||||
|
|
||||||
|
raise MQTTException(
|
||||||
|
"%s property value must be in the range 0-65535" % (name))
|
||||||
|
elif name in ["MaximumPacketSize", "SubscriptionIdentifier"] \
|
||||||
|
and (value < 1 or value > 268435455):
|
||||||
|
|
||||||
|
raise MQTTException(
|
||||||
|
"%s property value must be in the range 1-268435455" % (name))
|
||||||
|
elif name in ["RequestResponseInformation", "RequestProblemInformation", "PayloadFormatIndicator"] \
|
||||||
|
and (value != 0 and value != 1):
|
||||||
|
|
||||||
|
raise MQTTException(
|
||||||
|
"%s property value must be 0 or 1" % (name))
|
||||||
|
|
||||||
if self.allowsMultiple(name):
|
if self.allowsMultiple(name):
|
||||||
if type(value) != type([]):
|
if type(value) != type([]):
|
||||||
value = [value]
|
value = [value]
|
||||||
|
@ -294,7 +319,11 @@ class Properties(object):
|
||||||
for name in self.names.keys():
|
for name in self.names.keys():
|
||||||
compressedName = name.replace(' ', '')
|
compressedName = name.replace(' ', '')
|
||||||
if hasattr(self, compressedName):
|
if hasattr(self, compressedName):
|
||||||
data[compressedName] = getattr(self, compressedName)
|
val = getattr(self, compressedName)
|
||||||
|
if compressedName == 'CorrelationData' and isinstance(val, bytes):
|
||||||
|
data[compressedName] = val.hex()
|
||||||
|
else:
|
||||||
|
data[compressedName] = val
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def isEmpty(self):
|
def isEmpty(self):
|
||||||
|
@ -391,10 +420,10 @@ class Properties(object):
|
||||||
buffer = buffer[VBIlen:] # strip the bytes used by the VBI
|
buffer = buffer[VBIlen:] # strip the bytes used by the VBI
|
||||||
propslenleft = propslen
|
propslenleft = propslen
|
||||||
while propslenleft > 0: # properties length is 0 if there are none
|
while propslenleft > 0: # properties length is 0 if there are none
|
||||||
identifier, VBIlen = VariableByteIntegers.decode(
|
identifier, VBIlen2 = VariableByteIntegers.decode(
|
||||||
buffer) # property identifier
|
buffer) # property identifier
|
||||||
buffer = buffer[VBIlen:] # strip the bytes used by the VBI
|
buffer = buffer[VBIlen2:] # strip the bytes used by the VBI
|
||||||
propslenleft -= VBIlen
|
propslenleft -= VBIlen2
|
||||||
attr_type = self.properties[identifier][0]
|
attr_type = self.properties[identifier][0]
|
||||||
value, valuelen = self.readProperty(
|
value, valuelen = self.readProperty(
|
||||||
buffer, attr_type, propslenleft)
|
buffer, attr_type, propslenleft)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (c) 2014 Roger Light <roger@atchoo.org>
|
# Copyright (c) 2014 Roger Light <roger@atchoo.org>
|
||||||
#
|
#
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are made available under the terms of the Eclipse Public License v1.0
|
# are made available under the terms of the Eclipse Public License v2.0
|
||||||
# and Eclipse Distribution License v1.0 which accompany this distribution.
|
# and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||||
#
|
#
|
||||||
# The Eclipse Public License is available at
|
# The Eclipse Public License is available at
|
||||||
|
@ -21,13 +21,15 @@ broker, then disconnect and nothing else is required.
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from collections.abc import Iterable
|
from collections.abc import Iterable
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from collections import Iterable
|
from collections import Iterable
|
||||||
|
|
||||||
from . import client as paho
|
|
||||||
from .. import mqtt
|
from .. import mqtt
|
||||||
|
from . import client as paho
|
||||||
|
|
||||||
|
|
||||||
def _do_publish(client):
|
def _do_publish(client):
|
||||||
"""Internal function"""
|
"""Internal function"""
|
||||||
|
@ -52,6 +54,9 @@ def _on_connect(client, userdata, flags, rc):
|
||||||
else:
|
else:
|
||||||
raise mqtt.MQTTException(paho.connack_string(rc))
|
raise mqtt.MQTTException(paho.connack_string(rc))
|
||||||
|
|
||||||
|
def _on_connect_v5(client, userdata, flags, rc, properties):
|
||||||
|
"""Internal v5 callback"""
|
||||||
|
_on_connect(client, userdata, flags, rc)
|
||||||
|
|
||||||
def _on_publish(client, userdata, mid):
|
def _on_publish(client, userdata, mid):
|
||||||
"""Internal callback"""
|
"""Internal callback"""
|
||||||
|
@ -131,10 +136,14 @@ def multiple(msgs, hostname="localhost", port=1883, client_id="", keepalive=60,
|
||||||
if not isinstance(msgs, Iterable):
|
if not isinstance(msgs, Iterable):
|
||||||
raise TypeError('msgs must be an iterable')
|
raise TypeError('msgs must be an iterable')
|
||||||
|
|
||||||
|
|
||||||
client = paho.Client(client_id=client_id, userdata=collections.deque(msgs),
|
client = paho.Client(client_id=client_id, userdata=collections.deque(msgs),
|
||||||
protocol=protocol, transport=transport)
|
protocol=protocol, transport=transport)
|
||||||
|
|
||||||
client.on_publish = _on_publish
|
client.on_publish = _on_publish
|
||||||
|
if protocol == mqtt.client.MQTTv5:
|
||||||
|
client.on_connect = _on_connect_v5
|
||||||
|
else:
|
||||||
client.on_connect = _on_connect
|
client.on_connect = _on_connect
|
||||||
|
|
||||||
if proxy_args is not None:
|
if proxy_args is not None:
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Copyright (c) 2017, 2019 IBM Corp.
|
Copyright (c) 2017, 2019 IBM Corp.
|
||||||
|
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are made available under the terms of the Eclipse Public License v1.0
|
are made available under the terms of the Eclipse Public License v2.0
|
||||||
and Eclipse Distribution License v1.0 which accompany this distribution.
|
and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||||
|
|
||||||
The Eclipse Public License is available at
|
The Eclipse Public License is available at
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from .packettypes import PacketTypes
|
from .packettypes import PacketTypes
|
||||||
|
|
||||||
|
|
||||||
|
@ -153,7 +154,7 @@ class ReasonCodes:
|
||||||
if self.packetType in self.names[code][name]:
|
if self.packetType in self.names[code][name]:
|
||||||
identifier = code
|
identifier = code
|
||||||
break
|
break
|
||||||
assert identifier != None, name
|
assert identifier is not None, name
|
||||||
return identifier
|
return identifier
|
||||||
|
|
||||||
def set(self, name):
|
def set(self, name):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (c) 2016 Roger Light <roger@atchoo.org>
|
# Copyright (c) 2016 Roger Light <roger@atchoo.org>
|
||||||
#
|
#
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are made available under the terms of the Eclipse Public License v1.0
|
# are made available under the terms of the Eclipse Public License v2.0
|
||||||
# and Eclipse Distribution License v1.0 which accompany this distribution.
|
# and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||||
#
|
#
|
||||||
# The Eclipse Public License is available at
|
# The Eclipse Public License is available at
|
||||||
|
@ -20,10 +20,11 @@ you to pass a callback for processing of messages.
|
||||||
"""
|
"""
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from . import client as paho
|
|
||||||
from .. import mqtt
|
from .. import mqtt
|
||||||
|
from . import client as paho
|
||||||
|
|
||||||
def _on_connect(client, userdata, flags, rc):
|
|
||||||
|
def _on_connect_v5(client, userdata, flags, rc, properties):
|
||||||
"""Internal callback"""
|
"""Internal callback"""
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
raise mqtt.MQTTException(paho.connack_string(rc))
|
raise mqtt.MQTTException(paho.connack_string(rc))
|
||||||
|
@ -34,6 +35,10 @@ def _on_connect(client, userdata, flags, rc):
|
||||||
else:
|
else:
|
||||||
client.subscribe(userdata['topics'], userdata['qos'])
|
client.subscribe(userdata['topics'], userdata['qos'])
|
||||||
|
|
||||||
|
def _on_connect(client, userdata, flags, rc):
|
||||||
|
"""Internal v5 callback"""
|
||||||
|
_on_connect_v5(client, userdata, flags, rc, None)
|
||||||
|
|
||||||
|
|
||||||
def _on_message_callback(client, userdata, message):
|
def _on_message_callback(client, userdata, message):
|
||||||
"""Internal callback"""
|
"""Internal callback"""
|
||||||
|
@ -142,6 +147,9 @@ def callback(callback, topics, qos=0, userdata=None, hostname="localhost",
|
||||||
protocol=protocol, transport=transport,
|
protocol=protocol, transport=transport,
|
||||||
clean_session=clean_session)
|
clean_session=clean_session)
|
||||||
client.on_message = _on_message_callback
|
client.on_message = _on_message_callback
|
||||||
|
if protocol == mqtt.client.MQTTv5:
|
||||||
|
client.on_connect = _on_connect_v5
|
||||||
|
else:
|
||||||
client.on_connect = _on_connect
|
client.on_connect = _on_connect
|
||||||
|
|
||||||
if proxy_args is not None:
|
if proxy_args is not None:
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Copyright (c) 2017, 2019 IBM Corp.
|
Copyright (c) 2017, 2019 IBM Corp.
|
||||||
|
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are made available under the terms of the Eclipse Public License v1.0
|
are made available under the terms of the Eclipse Public License v2.0
|
||||||
and Eclipse Distribution License v1.0 which accompany this distribution.
|
and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||||
|
|
||||||
The Eclipse Public License is available at
|
The Eclipse Public License is available at
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue