rename HBMQTT base exception to AMQTT

pull/80/head
Florian Ludwig 2021-07-31 19:52:13 +02:00
rodzic 4faf762292
commit f0cf7be59f
19 zmienionych plików z 43 dodań i 43 usunięć

Wyświetl plik

@ -15,7 +15,7 @@ from functools import partial
from transitions import Machine, MachineError
from amqtt.session import Session
from amqtt.mqtt.protocol.broker_handler import BrokerProtocolHandler
from amqtt.errors import HBMQTTException, MQTTException
from amqtt.errors import AMQTTException, MQTTException
from amqtt.utils import format_client_message, gen_client_id
from amqtt.adapters import (
StreamReaderAdapter,
@ -422,7 +422,7 @@ class Broker:
handler, client_session = await BrokerProtocolHandler.init_from_connect(
reader, writer, self.plugins_manager, loop=self._loop
)
except HBMQTTException as exc:
except AMQTTException as exc:
self.logger.warning(
"[MQTT-3.1.0-1] %s: Can't read first packet an CONNECT: %s"
% (format_client_message(address=remote_address, port=remote_port), exc)

Wyświetl plik

@ -3,9 +3,9 @@
# See the file license.txt for copying permission.
class HBMQTTException(Exception):
class AMQTTException(Exception):
"""
HBMQTT base exception
aMQTT base exception
"""
pass

Wyświetl plik

@ -1,7 +1,7 @@
# Copyright (c) 2015 Nicolas JOUANIN
#
# See the file license.txt for copying permission.
from amqtt.errors import HBMQTTException
from amqtt.errors import AMQTTException
from amqtt.mqtt.packet import (
CONNECT,
CONNACK,
@ -57,4 +57,4 @@ def packet_class(fixed_header: MQTTFixedHeader):
cls = packet_dict[fixed_header.packet_type]
return cls
except KeyError:
raise HBMQTTException("Unexpected packet Type '%s'" % fixed_header.packet_type)
raise AMQTTException("Unexpected packet Type '%s'" % fixed_header.packet_type)

Wyświetl plik

@ -3,7 +3,7 @@
# See the file license.txt for copying permission.
from amqtt.mqtt.packet import CONNACK, MQTTPacket, MQTTFixedHeader, MQTTVariableHeader
from amqtt.codecs import read_or_raise, bytes_to_int
from amqtt.errors import HBMQTTException
from amqtt.errors import AMQTTException
from amqtt.adapters import ReaderAdapter
CONNECTION_ACCEPTED = 0x00
@ -78,7 +78,7 @@ class ConnackPacket(MQTTPacket):
header = MQTTFixedHeader(CONNACK, 0x00)
else:
if fixed.packet_type is not CONNACK:
raise HBMQTTException(
raise AMQTTException(
"Invalid fixed packet type %s for ConnackPacket init"
% fixed.packet_type
)

Wyświetl plik

@ -18,7 +18,7 @@ from amqtt.mqtt.packet import (
MQTTVariableHeader,
MQTTPayload,
)
from amqtt.errors import HBMQTTException, NoDataException
from amqtt.errors import AMQTTException, NoDataException
from amqtt.adapters import ReaderAdapter
from amqtt.utils import gen_client_id
@ -390,7 +390,7 @@ class ConnectPacket(MQTTPacket):
header = MQTTFixedHeader(CONNECT, 0x00)
else:
if fixed.packet_type is not CONNECT:
raise HBMQTTException(
raise AMQTTException(
"Invalid fixed packet type %s for ConnectPacket init"
% fixed.packet_type
)

Wyświetl plik

@ -2,7 +2,7 @@
#
# See the file license.txt for copying permission.
from amqtt.mqtt.packet import MQTTPacket, MQTTFixedHeader, DISCONNECT
from amqtt.errors import HBMQTTException
from amqtt.errors import AMQTTException
class DisconnectPacket(MQTTPacket):
@ -14,7 +14,7 @@ class DisconnectPacket(MQTTPacket):
header = MQTTFixedHeader(DISCONNECT, 0x00)
else:
if fixed.packet_type is not DISCONNECT:
raise HBMQTTException(
raise AMQTTException(
"Invalid fixed packet type %s for DisconnectPacket init"
% fixed.packet_type
)

Wyświetl plik

@ -2,7 +2,7 @@
#
# See the file license.txt for copying permission.
from amqtt.mqtt.packet import MQTTPacket, MQTTFixedHeader, PINGREQ
from amqtt.errors import HBMQTTException
from amqtt.errors import AMQTTException
class PingReqPacket(MQTTPacket):
@ -14,7 +14,7 @@ class PingReqPacket(MQTTPacket):
header = MQTTFixedHeader(PINGREQ, 0x00)
else:
if fixed.packet_type is not PINGREQ:
raise HBMQTTException(
raise AMQTTException(
"Invalid fixed packet type %s for PingReqPacket init"
% fixed.packet_type
)

Wyświetl plik

@ -2,7 +2,7 @@
#
# See the file license.txt for copying permission.
from amqtt.mqtt.packet import MQTTPacket, MQTTFixedHeader, PINGRESP
from amqtt.errors import HBMQTTException
from amqtt.errors import AMQTTException
class PingRespPacket(MQTTPacket):
@ -14,7 +14,7 @@ class PingRespPacket(MQTTPacket):
header = MQTTFixedHeader(PINGRESP, 0x00)
else:
if fixed.packet_type is not PINGRESP:
raise HBMQTTException(
raise AMQTTException(
"Invalid fixed packet type %s for PingRespPacket init"
% fixed.packet_type
)

Wyświetl plik

@ -52,7 +52,7 @@ from amqtt.session import (
)
from amqtt.mqtt.constants import QOS_0, QOS_1, QOS_2
from amqtt.plugins.manager import PluginManager
from amqtt.errors import HBMQTTException, MQTTException, NoDataException
from amqtt.errors import AMQTTException, MQTTException, NoDataException
EVENT_MQTT_PACKET_SENT = "mqtt_packet_sent"
@ -204,7 +204,7 @@ class ProtocolHandler:
if qos in (QOS_1, QOS_2):
packet_id = self.session.next_packet_id
if packet_id in self.session.inflight_out:
raise HBMQTTException(
raise AMQTTException(
"A message with the same packet ID '%d' is already in flight"
% packet_id
)
@ -236,7 +236,7 @@ class ProtocolHandler:
elif app_message.qos == QOS_2:
await self._handle_qos2_message_flow(app_message)
else:
raise HBMQTTException("Unexcepted QOS value '%d" % str(app_message.qos))
raise AMQTTException("Unexcepted QOS value '%d" % str(app_message.qos))
async def _handle_qos0_message_flow(self, app_message):
"""
@ -276,7 +276,7 @@ class ProtocolHandler:
"""
assert app_message.qos == QOS_1
if app_message.puback_packet:
raise HBMQTTException(
raise AMQTTException(
"Message '%d' has already been acknowledged" % app_message.packet_id
)
if app_message.direction == OUTGOING:
@ -322,7 +322,7 @@ class ProtocolHandler:
assert app_message.qos == QOS_2
if app_message.direction == OUTGOING:
if app_message.pubrel_packet and app_message.pubcomp_packet:
raise HBMQTTException(
raise AMQTTException(
"Message '%d' has already been acknowledged" % app_message.packet_id
)
if not app_message.pubrel_packet:
@ -330,7 +330,7 @@ class ProtocolHandler:
if app_message.publish_packet is not None:
# This is a retry flow, no need to store just check the message exists in session
if app_message.packet_id not in self.session.inflight_out:
raise HBMQTTException(
raise AMQTTException(
"Unknown inflight message '%d' in session"
% app_message.packet_id
)
@ -350,7 +350,7 @@ class ProtocolHandler:
% app_message.packet_id
)
self.logger.warning(message)
raise HBMQTTException(message)
raise AMQTTException(message)
waiter = asyncio.Future(loop=self._loop)
self._pubrec_waiters[app_message.packet_id] = waiter
await waiter

Wyświetl plik

@ -7,7 +7,7 @@ from amqtt.mqtt.packet import (
PUBACK,
PacketIdVariableHeader,
)
from amqtt.errors import HBMQTTException
from amqtt.errors import AMQTTException
class PubackPacket(MQTTPacket):
@ -31,7 +31,7 @@ class PubackPacket(MQTTPacket):
header = MQTTFixedHeader(PUBACK, 0x00)
else:
if fixed.packet_type is not PUBACK:
raise HBMQTTException(
raise AMQTTException(
"Invalid fixed packet type %s for PubackPacket init"
% fixed.packet_type
)

Wyświetl plik

@ -7,7 +7,7 @@ from amqtt.mqtt.packet import (
PUBCOMP,
PacketIdVariableHeader,
)
from amqtt.errors import HBMQTTException
from amqtt.errors import AMQTTException
class PubcompPacket(MQTTPacket):
@ -31,7 +31,7 @@ class PubcompPacket(MQTTPacket):
header = MQTTFixedHeader(PUBCOMP, 0x00)
else:
if fixed.packet_type is not PUBCOMP:
raise HBMQTTException(
raise AMQTTException(
"Invalid fixed packet type %s for PubcompPacket init"
% fixed.packet_type
)

Wyświetl plik

@ -10,7 +10,7 @@ from amqtt.mqtt.packet import (
MQTTVariableHeader,
MQTTPayload,
)
from amqtt.errors import HBMQTTException, MQTTException
from amqtt.errors import AMQTTException, MQTTException
from amqtt.codecs import decode_packet_id, decode_string, encode_string, int_to_bytes
@ -103,7 +103,7 @@ class PublishPacket(MQTTPacket):
header = MQTTFixedHeader(PUBLISH, 0x00)
else:
if fixed.packet_type is not PUBLISH:
raise HBMQTTException(
raise AMQTTException(
"Invalid fixed packet type %s for PublishPacket init"
% fixed.packet_type
)

Wyświetl plik

@ -7,7 +7,7 @@ from amqtt.mqtt.packet import (
PUBREC,
PacketIdVariableHeader,
)
from amqtt.errors import HBMQTTException
from amqtt.errors import AMQTTException
class PubrecPacket(MQTTPacket):
@ -31,7 +31,7 @@ class PubrecPacket(MQTTPacket):
header = MQTTFixedHeader(PUBREC, 0x00)
else:
if fixed.packet_type is not PUBREC:
raise HBMQTTException(
raise AMQTTException(
"Invalid fixed packet type %s for PubrecPacket init"
% fixed.packet_type
)

Wyświetl plik

@ -7,7 +7,7 @@ from amqtt.mqtt.packet import (
PUBREL,
PacketIdVariableHeader,
)
from amqtt.errors import HBMQTTException
from amqtt.errors import AMQTTException
class PubrelPacket(MQTTPacket):
@ -31,7 +31,7 @@ class PubrelPacket(MQTTPacket):
header = MQTTFixedHeader(PUBREL, 0x02) # [MQTT-3.6.1-1]
else:
if fixed.packet_type is not PUBREL:
raise HBMQTTException(
raise AMQTTException(
"Invalid fixed packet type %s for PubrelPacket init"
% fixed.packet_type
)

Wyświetl plik

@ -9,7 +9,7 @@ from amqtt.mqtt.packet import (
MQTTPayload,
MQTTVariableHeader,
)
from amqtt.errors import HBMQTTException, NoDataException
from amqtt.errors import AMQTTException, NoDataException
from amqtt.adapters import ReaderAdapter
from amqtt.codecs import bytes_to_int, int_to_bytes, read_or_raise
@ -71,7 +71,7 @@ class SubackPacket(MQTTPacket):
header = MQTTFixedHeader(SUBACK, 0x00)
else:
if fixed.packet_type is not SUBACK:
raise HBMQTTException(
raise AMQTTException(
"Invalid fixed packet type %s for SubackPacket init"
% fixed.packet_type
)

Wyświetl plik

@ -11,7 +11,7 @@ from amqtt.mqtt.packet import (
MQTTPayload,
MQTTVariableHeader,
)
from amqtt.errors import HBMQTTException, NoDataException
from amqtt.errors import AMQTTException, NoDataException
from amqtt.codecs import (
bytes_to_int,
decode_string,
@ -77,7 +77,7 @@ class SubscribePacket(MQTTPacket):
header = MQTTFixedHeader(SUBSCRIBE, 0x02) # [MQTT-3.8.1-1]
else:
if fixed.packet_type is not SUBSCRIBE:
raise HBMQTTException(
raise AMQTTException(
"Invalid fixed packet type %s for SubscribePacket init"
% fixed.packet_type
)

Wyświetl plik

@ -7,7 +7,7 @@ from amqtt.mqtt.packet import (
UNSUBACK,
PacketIdVariableHeader,
)
from amqtt.errors import HBMQTTException
from amqtt.errors import AMQTTException
class UnsubackPacket(MQTTPacket):
@ -24,7 +24,7 @@ class UnsubackPacket(MQTTPacket):
header = MQTTFixedHeader(UNSUBACK, 0x00)
else:
if fixed.packet_type is not UNSUBACK:
raise HBMQTTException(
raise AMQTTException(
"Invalid fixed packet type %s for UnsubackPacket init"
% fixed.packet_type
)

Wyświetl plik

@ -11,7 +11,7 @@ from amqtt.mqtt.packet import (
MQTTPayload,
MQTTVariableHeader,
)
from amqtt.errors import HBMQTTException, NoDataException
from amqtt.errors import AMQTTException, NoDataException
from amqtt.codecs import decode_string, encode_string
@ -65,7 +65,7 @@ class UnsubscribePacket(MQTTPacket):
header = MQTTFixedHeader(UNSUBSCRIBE, 0x02) # [MQTT-3.10.1-1]
else:
if fixed.packet_type is not UNSUBSCRIBE:
raise HBMQTTException(
raise AMQTTException(
"Invalid fixed packet type %s for UnsubscribePacket init"
% fixed.packet_type
)

Wyświetl plik

@ -6,7 +6,7 @@ from transitions import Machine
from asyncio import Queue
from collections import OrderedDict
from amqtt.mqtt.publish import PublishPacket
from amqtt.errors import HBMQTTException
from amqtt.errors import AMQTTException
OUTGOING = 0
INCOMING = 1
@ -172,7 +172,7 @@ class Session:
):
self._packet_id += 1
if self._packet_id > 65535:
raise HBMQTTException(
raise AMQTTException(
"More than 65525 messages pending. No free packet ID"
)