kopia lustrzana https://github.com/Yakifo/amqtt
flake8: Fix all E2xx whitespace warnings
rodzic
4007dcce9f
commit
6f4b306886
|
@ -375,7 +375,7 @@ class Broker:
|
|||
# Get session from cache
|
||||
if client_session.client_id in self._sessions:
|
||||
self.logger.debug("Found old session %s" % repr(self._sessions[client_session.client_id]))
|
||||
(client_session,h) = self._sessions[client_session.client_id]
|
||||
(client_session, h) = self._sessions[client_session.client_id]
|
||||
client_session.parent = 1
|
||||
else:
|
||||
client_session.parent = 0
|
||||
|
@ -587,7 +587,7 @@ class Broker:
|
|||
if a_filter not in self._subscriptions:
|
||||
self._subscriptions[a_filter] = []
|
||||
already_subscribed = next(
|
||||
(s for (s,qos) in self._subscriptions[a_filter] if s.client_id == session.client_id), None)
|
||||
(s for (s, qos) in self._subscriptions[a_filter] if s.client_id == session.client_id), None)
|
||||
if not already_subscribed:
|
||||
self._subscriptions[a_filter].append((session, qos))
|
||||
else:
|
||||
|
|
|
@ -127,7 +127,7 @@ class BrokerProtocolHandler(ProtocolHandler):
|
|||
connect = yield from ConnectPacket.from_stream(reader)
|
||||
yield from plugins_manager.fire_event(EVENT_MQTT_PACKET_RECEIVED, packet=connect)
|
||||
if connect.payload.client_id is None:
|
||||
raise MQTTException('[[MQTT-3.1.3-3]] : Client identifier must be present' )
|
||||
raise MQTTException('[[MQTT-3.1.3-3]] : Client identifier must be present')
|
||||
|
||||
if connect.variable_header.will_flag:
|
||||
if connect.payload.will_topic is None or connect.payload.will_message is None:
|
||||
|
|
|
@ -49,7 +49,7 @@ class PublishPayload(MQTTPayload):
|
|||
def from_stream(cls, reader: asyncio.StreamReader, fixed_header: MQTTFixedHeader,
|
||||
variable_header: MQTTVariableHeader):
|
||||
data = bytearray()
|
||||
data_length = fixed_header.remaining_length-variable_header.bytes_length
|
||||
data_length = fixed_header.remaining_length - variable_header.bytes_length
|
||||
length_read = 0
|
||||
while length_read < data_length:
|
||||
buffer = yield from reader.read(data_length - length_read)
|
||||
|
|
|
@ -46,7 +46,7 @@ class SubscribePacket(MQTTPacket):
|
|||
|
||||
def __init__(self, fixed: MQTTFixedHeader=None, variable_header: PacketIdVariableHeader=None, payload=None):
|
||||
if fixed is None:
|
||||
header = MQTTFixedHeader(SUBSCRIBE, 0x02) # [MQTT-3.8.1-1]
|
||||
header = MQTTFixedHeader(SUBSCRIBE, 0x02) # [MQTT-3.8.1-1]
|
||||
else:
|
||||
if fixed.packet_type is not SUBSCRIBE:
|
||||
raise HBMQTTException("Invalid fixed packet type %s for SubscribePacket init" % fixed.packet_type)
|
||||
|
@ -60,4 +60,4 @@ class SubscribePacket(MQTTPacket):
|
|||
def build(cls, topics, packet_id):
|
||||
v_header = PacketIdVariableHeader(packet_id)
|
||||
payload = SubscribePayload(topics)
|
||||
return SubscribePacket(variable_header=v_header, payload=payload)
|
||||
return SubscribePacket(variable_header=v_header, payload=payload)
|
||||
|
|
|
@ -40,7 +40,7 @@ class UnsubscribePacket(MQTTPacket):
|
|||
|
||||
def __init__(self, fixed: MQTTFixedHeader=None, variable_header: PacketIdVariableHeader=None, payload=None):
|
||||
if fixed is None:
|
||||
header = MQTTFixedHeader(UNSUBSCRIBE, 0x02) # [MQTT-3.10.1-1]
|
||||
header = MQTTFixedHeader(UNSUBSCRIBE, 0x02) # [MQTT-3.10.1-1]
|
||||
else:
|
||||
if fixed.packet_type is not UNSUBSCRIBE:
|
||||
raise HBMQTTException("Invalid fixed packet type %s for UnsubscribePacket init" % fixed.packet_type)
|
||||
|
@ -54,4 +54,4 @@ class UnsubscribePacket(MQTTPacket):
|
|||
def build(cls, topics, packet_id):
|
||||
v_header = PacketIdVariableHeader(packet_id)
|
||||
payload = UnubscribePayload(topics)
|
||||
return UnsubscribePacket(variable_header=v_header, payload=payload)
|
||||
return UnsubscribePacket(variable_header=v_header, payload=payload)
|
||||
|
|
|
@ -69,7 +69,7 @@ def do_sub(client, arguments):
|
|||
capath=arguments['--ca-path'],
|
||||
cadata=arguments['--ca-data'])
|
||||
qos = _get_qos(arguments)
|
||||
filters=[]
|
||||
filters = []
|
||||
for topic in arguments['-t']:
|
||||
filters.append((topic, qos))
|
||||
yield from client.subscribe(filters)
|
||||
|
@ -141,4 +141,4 @@ def main(*args, **kwargs):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
|
2
setup.py
2
setup.py
|
@ -36,7 +36,7 @@ setup(
|
|||
'Topic :: Communications',
|
||||
'Topic :: Internet'
|
||||
],
|
||||
entry_points = {
|
||||
entry_points={
|
||||
'hbmqtt.test.plugins': [
|
||||
'test_plugin = tests.plugins.test_manager:TestPlugin',
|
||||
'event_plugin = tests.plugins.test_manager:EventTestPlugin',
|
||||
|
|
|
@ -158,7 +158,7 @@ class BrokerTest(unittest.TestCase):
|
|||
yield from broker.start()
|
||||
self.assertTrue(broker.transitions.is_started())
|
||||
client = MQTTClient(client_id="", config={'auto_reconnect': False})
|
||||
return_code=None
|
||||
return_code = None
|
||||
try:
|
||||
yield from client.connect('mqtt://localhost/', cleansession=False)
|
||||
except ConnectException as ce:
|
||||
|
|
|
@ -68,7 +68,7 @@ class MQTTClientTest(unittest.TestCase):
|
|||
@asyncio.coroutine
|
||||
def test_coro():
|
||||
try:
|
||||
client = MQTTClient(config={'check_hostname':False})
|
||||
client = MQTTClient(config={'check_hostname': False})
|
||||
ca = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mosquitto.org.crt')
|
||||
ret = yield from client.connect('mqtts://test.mosquitto.org/', cafile=ca)
|
||||
self.assertIsNotNone(client.session)
|
||||
|
|
6
tox.ini
6
tox.ini
|
@ -6,12 +6,6 @@ ignore =
|
|||
E126, # continuation line over-indented for hanging indent (~5 warnings)
|
||||
E127, # continuation line over-indented for visual indent (~5 warnings)
|
||||
E128, # continuation line under-indented for visual indent (~7 warnings)
|
||||
E202, # whitespace before 'x' (~1 warning)
|
||||
E225, # missing whitespace around operator (~2 warnings)
|
||||
E226, # missing whitespace around arithmetic operator (~1 warning)
|
||||
E231, # missing whitespace after 'x' (~3 warnings)
|
||||
E251, # unexpected spaces around keyword / parameter equals (~2 warnings)
|
||||
E261, # at least two spaces before inline comment (~2 warnings)
|
||||
E301, # expected 1 blank line, found 0 (~1 warnings)
|
||||
E302, # expected 2 blank lines, found 1 (~6 warnings)
|
||||
E303, # too many blank lines (2) (~5 warnings)
|
||||
|
|
Ładowanie…
Reference in New Issue