@@ -93,7 +93,6 @@ def set_socket(sock, iface=None):
93
93
global _the_interface # pylint: disable=invalid-name, global-statement
94
94
_the_interface = iface
95
95
_the_sock .set_interface (iface )
96
- print (_the_sock )
97
96
98
97
def unpretty_ip (ip ): # pylint: disable=no-self-use, invalid-name
99
98
"""Converts a dotted-quad string to a bytearray IP address"""
@@ -200,7 +199,7 @@ def last_will(self, topic=None, message=None, qos=0, retain=False):
200
199
self ._lw_msg = message
201
200
self ._lw_retain = retain
202
201
203
- # pylint: disable=too-many-branches, too-many-statements
202
+ # pylint: disable=too-many-branches, too-many-statements, too-many-locals
204
203
def connect (self , clean_session = True ):
205
204
"""Initiates connection with the MQTT Broker.
206
205
:param bool clean_session: Establishes a persistent session.
@@ -380,7 +379,7 @@ def publish(self, topic, msg, retain=False, qos=0):
380
379
# check msg/qos kwargs
381
380
if msg is None :
382
381
raise MMQTTException ('Message can not be None.' )
383
- elif isinstance (msg , (int , float )):
382
+ if isinstance (msg , (int , float )):
384
383
msg = str (msg ).encode ('ascii' )
385
384
elif isinstance (msg , str ):
386
385
msg = str (msg ).encode ('utf-8' )
@@ -588,7 +587,7 @@ def loop_forever(self):
588
587
"""Starts a blocking message loop. Use this
589
588
method if you want to run a program forever.
590
589
Code below a call to this method will NOT execute.
591
-
590
+
592
591
NOTE: Network reconnection is not handled within this call and
593
592
must be handled by your code for each interface.
594
593
@@ -608,7 +607,8 @@ def loop(self):
608
607
if current_time - self ._timestamp >= self .keep_alive :
609
608
# Handle KeepAlive by expecting a PINGREQ/PINGRESP from the server
610
609
if self .logger is not None :
611
- self .logger .debug ('KeepAlive period elapsed - requesting a PINGRESP from the server...' )
610
+ self .logger .debug ('KeepAlive period elapsed - \
611
+ requesting a PINGRESP from the server...' )
612
612
self .ping ()
613
613
self ._timestamp = 0
614
614
self ._sock .settimeout (0.1 )
@@ -677,7 +677,7 @@ def _check_topic(topic):
677
677
if topic is None :
678
678
raise MMQTTException ('Topic may not be NoneType' )
679
679
# [MQTT-4.7.3-1]
680
- elif not topic :
680
+ if not topic :
681
681
raise MMQTTException ('Topic may not be empty.' )
682
682
# [MQTT-4.7.3-3]
683
683
elif len (topic .encode ('utf-8' )) > MQTT_TOPIC_LENGTH_LIMIT :
0 commit comments