diff --git a/amqtt/broker.py b/amqtt/broker.py index 0ea461e..c4f937a 100644 --- a/amqtt/broker.py +++ b/amqtt/broker.py @@ -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) diff --git a/amqtt/errors.py b/amqtt/errors.py index c36d745..40f011c 100644 --- a/amqtt/errors.py +++ b/amqtt/errors.py @@ -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 diff --git a/amqtt/mqtt/__init__.py b/amqtt/mqtt/__init__.py index 808c971..24bf6fc 100644 --- a/amqtt/mqtt/__init__.py +++ b/amqtt/mqtt/__init__.py @@ -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) diff --git a/amqtt/mqtt/connack.py b/amqtt/mqtt/connack.py index 3e67d7e..7af0b53 100644 --- a/amqtt/mqtt/connack.py +++ b/amqtt/mqtt/connack.py @@ -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 ) diff --git a/amqtt/mqtt/connect.py b/amqtt/mqtt/connect.py index ca20fee..3f7debe 100644 --- a/amqtt/mqtt/connect.py +++ b/amqtt/mqtt/connect.py @@ -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 ) diff --git a/amqtt/mqtt/disconnect.py b/amqtt/mqtt/disconnect.py index 686caa9..42fe16f 100644 --- a/amqtt/mqtt/disconnect.py +++ b/amqtt/mqtt/disconnect.py @@ -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 ) diff --git a/amqtt/mqtt/pingreq.py b/amqtt/mqtt/pingreq.py index a1f1ab9..89c4852 100644 --- a/amqtt/mqtt/pingreq.py +++ b/amqtt/mqtt/pingreq.py @@ -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 ) diff --git a/amqtt/mqtt/pingresp.py b/amqtt/mqtt/pingresp.py index c2d5697..a6846c1 100644 --- a/amqtt/mqtt/pingresp.py +++ b/amqtt/mqtt/pingresp.py @@ -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 ) diff --git a/amqtt/mqtt/protocol/handler.py b/amqtt/mqtt/protocol/handler.py index a4bdd8c..37991d5 100644 --- a/amqtt/mqtt/protocol/handler.py +++ b/amqtt/mqtt/protocol/handler.py @@ -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 diff --git a/amqtt/mqtt/puback.py b/amqtt/mqtt/puback.py index 809cedf..d2b99e8 100644 --- a/amqtt/mqtt/puback.py +++ b/amqtt/mqtt/puback.py @@ -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 ) diff --git a/amqtt/mqtt/pubcomp.py b/amqtt/mqtt/pubcomp.py index d5bc49b..2356c01 100644 --- a/amqtt/mqtt/pubcomp.py +++ b/amqtt/mqtt/pubcomp.py @@ -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 ) diff --git a/amqtt/mqtt/publish.py b/amqtt/mqtt/publish.py index c47b465..d082811 100644 --- a/amqtt/mqtt/publish.py +++ b/amqtt/mqtt/publish.py @@ -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 ) diff --git a/amqtt/mqtt/pubrec.py b/amqtt/mqtt/pubrec.py index 5a29200..8d7b0bc 100644 --- a/amqtt/mqtt/pubrec.py +++ b/amqtt/mqtt/pubrec.py @@ -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 ) diff --git a/amqtt/mqtt/pubrel.py b/amqtt/mqtt/pubrel.py index af4f0f1..34a8c11 100644 --- a/amqtt/mqtt/pubrel.py +++ b/amqtt/mqtt/pubrel.py @@ -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 ) diff --git a/amqtt/mqtt/suback.py b/amqtt/mqtt/suback.py index 6aa9141..83a1a7f 100644 --- a/amqtt/mqtt/suback.py +++ b/amqtt/mqtt/suback.py @@ -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 ) diff --git a/amqtt/mqtt/subscribe.py b/amqtt/mqtt/subscribe.py index b5bfd1c..fdff840 100644 --- a/amqtt/mqtt/subscribe.py +++ b/amqtt/mqtt/subscribe.py @@ -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 ) diff --git a/amqtt/mqtt/unsuback.py b/amqtt/mqtt/unsuback.py index 0484509..bd6155a 100644 --- a/amqtt/mqtt/unsuback.py +++ b/amqtt/mqtt/unsuback.py @@ -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 ) diff --git a/amqtt/mqtt/unsubscribe.py b/amqtt/mqtt/unsubscribe.py index 1600c6f..4ca1942 100644 --- a/amqtt/mqtt/unsubscribe.py +++ b/amqtt/mqtt/unsubscribe.py @@ -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 ) diff --git a/amqtt/session.py b/amqtt/session.py index b717536..2cc381f 100644 --- a/amqtt/session.py +++ b/amqtt/session.py @@ -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" )