mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 12:59:42 -07:00
Bump paho-mqtt from 1.6.1 to 2.0.0 (#2288)
* Bump paho-mqtt from 1.6.1 to 2.0.0 Bumps [paho-mqtt](https://github.com/eclipse/paho.mqtt.python) from 1.6.1 to 2.0.0. - [Release notes](https://github.com/eclipse/paho.mqtt.python/releases) - [Changelog](https://github.com/eclipse/paho.mqtt.python/blob/master/ChangeLog.txt) - [Commits](https://github.com/eclipse/paho.mqtt.python/compare/v1.6.1...v2.0.0) --- updated-dependencies: - dependency-name: paho-mqtt dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Update paho-mqtt==2.0.0 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
This commit is contained in:
parent
75a1750a4e
commit
f82aecb88c
12 changed files with 2643 additions and 1443 deletions
|
@ -7,7 +7,7 @@
|
|||
and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||
|
||||
The Eclipse Public License is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
http://www.eclipse.org/legal/epl-v20.html
|
||||
and the Eclipse Distribution License is available at
|
||||
http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
|
||||
|
@ -16,14 +16,13 @@
|
|||
*******************************************************************
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
class MQTTException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class SubscribeOptions(object):
|
||||
class SubscribeOptions:
|
||||
"""The MQTT v5.0 subscribe options class.
|
||||
|
||||
The options are:
|
||||
|
@ -42,7 +41,13 @@ class SubscribeOptions(object):
|
|||
RETAIN_SEND_ON_SUBSCRIBE, RETAIN_SEND_IF_NEW_SUB, RETAIN_DO_NOT_SEND = range(
|
||||
0, 3)
|
||||
|
||||
def __init__(self, qos=0, noLocal=False, retainAsPublished=False, retainHandling=RETAIN_SEND_ON_SUBSCRIBE):
|
||||
def __init__(
|
||||
self,
|
||||
qos: int = 0,
|
||||
noLocal: bool = False,
|
||||
retainAsPublished: bool = False,
|
||||
retainHandling: int = RETAIN_SEND_ON_SUBSCRIBE,
|
||||
):
|
||||
"""
|
||||
qos: 0, 1 or 2. 0 is the default.
|
||||
noLocal: True or False. False is the default and corresponds to MQTT v3.1.1 behavior.
|
||||
|
@ -56,29 +61,27 @@ class SubscribeOptions(object):
|
|||
self.noLocal = noLocal # bit 2
|
||||
self.retainAsPublished = retainAsPublished # bit 3
|
||||
self.retainHandling = retainHandling # bits 4 and 5: 0, 1 or 2
|
||||
assert self.QoS in [0, 1, 2]
|
||||
assert self.retainHandling in [
|
||||
0, 1, 2], "Retain handling should be 0, 1 or 2"
|
||||
if self.retainHandling not in (0, 1, 2):
|
||||
raise AssertionError(f"Retain handling should be 0, 1 or 2, not {self.retainHandling}")
|
||||
if self.QoS not in (0, 1, 2):
|
||||
raise AssertionError(f"QoS should be 0, 1 or 2, not {self.QoS}")
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if name not in self.names:
|
||||
raise MQTTException(
|
||||
name + " Attribute name must be one of "+str(self.names))
|
||||
f"{name} Attribute name must be one of {self.names}")
|
||||
object.__setattr__(self, name, value)
|
||||
|
||||
def pack(self):
|
||||
assert self.QoS in [0, 1, 2]
|
||||
assert self.retainHandling in [
|
||||
0, 1, 2], "Retain handling should be 0, 1 or 2"
|
||||
if self.retainHandling not in (0, 1, 2):
|
||||
raise AssertionError(f"Retain handling should be 0, 1 or 2, not {self.retainHandling}")
|
||||
if self.QoS not in (0, 1, 2):
|
||||
raise AssertionError(f"QoS should be 0, 1 or 2, not {self.QoS}")
|
||||
noLocal = 1 if self.noLocal else 0
|
||||
retainAsPublished = 1 if self.retainAsPublished else 0
|
||||
data = [(self.retainHandling << 4) | (retainAsPublished << 3) |
|
||||
(noLocal << 2) | self.QoS]
|
||||
if sys.version_info[0] >= 3:
|
||||
buffer = bytes(data)
|
||||
else:
|
||||
buffer = bytearray(data)
|
||||
return buffer
|
||||
return bytes(data)
|
||||
|
||||
def unpack(self, buffer):
|
||||
b0 = buffer[0]
|
||||
|
@ -86,10 +89,10 @@ class SubscribeOptions(object):
|
|||
self.retainAsPublished = True if ((b0 >> 3) & 0x01) == 1 else False
|
||||
self.noLocal = True if ((b0 >> 2) & 0x01) == 1 else False
|
||||
self.QoS = (b0 & 0x03)
|
||||
assert self.retainHandling in [
|
||||
0, 1, 2], "Retain handling should be 0, 1 or 2, not %d" % self.retainHandling
|
||||
assert self.QoS in [
|
||||
0, 1, 2], "QoS should be 0, 1 or 2, not %d" % self.QoS
|
||||
if self.retainHandling not in (0, 1, 2):
|
||||
raise AssertionError(f"Retain handling should be 0, 1 or 2, not {self.retainHandling}")
|
||||
if self.QoS not in (0, 1, 2):
|
||||
raise AssertionError(f"QoS should be 0, 1 or 2, not {self.QoS}")
|
||||
return 1
|
||||
|
||||
def __repr__(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue