MqttMonitor/MqttClient.py

changeset 3
82845c0fd550
parent 2
d439c5109829
child 9
f75a385e9127
--- a/MqttMonitor/MqttClient.py	Sun Aug 26 19:40:15 2018 +0200
+++ b/MqttMonitor/MqttClient.py	Mon Aug 27 19:26:27 2018 +0200
@@ -174,106 +174,118 @@
         return self.__mqttClient.publish(topic, payload=payload, qos=qos,
                                          retain=retain)
 
+
 def mqttConnackMessage(connackCode):
     """
     Public method to get the string associated with a CONNACK result.
+    
+    @param connackCode result code of the connection request
+    @type int
+    @return textual representation for the result code
+    @rtype str
     """
     if connackCode == mqtt.CONNACK_ACCEPTED:
         return QCoreApplication.translate(
-            "MqttConnackMessage", 
+            "MqttConnackMessage",
             "Connection Accepted.")
     elif connackCode == mqtt.CONNACK_REFUSED_PROTOCOL_VERSION:
         return QCoreApplication.translate(
-            "MqttConnackMessage", 
+            "MqttConnackMessage",
             "Connection Refused: unacceptable protocol version.")
     elif connackCode == mqtt.CONNACK_REFUSED_IDENTIFIER_REJECTED:
         return QCoreApplication.translate(
-            "MqttConnackMessage", 
+            "MqttConnackMessage",
             "Connection Refused: identifier rejected.")
     elif connackCode == mqtt.CONNACK_REFUSED_SERVER_UNAVAILABLE:
         return QCoreApplication.translate(
-            "MqttConnackMessage", 
+            "MqttConnackMessage",
             "Connection Refused: broker unavailable.")
     elif connackCode == mqtt.CONNACK_REFUSED_BAD_USERNAME_PASSWORD:
         return QCoreApplication.translate(
-            "MqttConnackMessage", 
+            "MqttConnackMessage",
             "Connection Refused: bad user name or password.")
     elif connackCode == mqtt.CONNACK_REFUSED_NOT_AUTHORIZED:
         return QCoreApplication.translate(
-            "MqttConnackMessage", 
+            "MqttConnackMessage",
             "Connection Refused: not authorised.")
     else:
         return QCoreApplication.translate(
-            "MqttConnackMessage", 
+            "MqttConnackMessage",
             "Connection Refused: unknown reason.")
 
+
 def mqttErrorMessage(self, mqttErrno):
     """
     Public method to get the error string associated with an MQTT error
     number.
+    
+    @param mqttErrno result code of a MQTT request
+    @type int
+    @return textual representation of the result code
+    @rtype str
     """
     if mqttErrno == mqtt.MQTT_ERR_SUCCESS:
         return QCoreApplication.translate(
-            "MqttErrorMessage", 
+            "MqttErrorMessage",
             "No error.")
     elif mqttErrno == mqtt.MQTT_ERR_NOMEM:
         return QCoreApplication.translate(
-            "MqttErrorMessage", 
+            "MqttErrorMessage",
             "Out of memory.")
     elif mqttErrno == mqtt.MQTT_ERR_PROTOCOL:
         return QCoreApplication.translate(
-            "MqttErrorMessage", 
+            "MqttErrorMessage",
             "A network protocol error occurred when communicating with"
             " the broker.")
     elif mqttErrno == mqtt.MQTT_ERR_INVAL:
         return QCoreApplication.translate(
-            "MqttErrorMessage", 
+            "MqttErrorMessage",
             "Invalid function arguments provided.")
     elif mqttErrno == mqtt.MQTT_ERR_NO_CONN:
         return QCoreApplication.translate(
-            "MqttErrorMessage", 
+            "MqttErrorMessage",
             "The client is not currently connected.")
     elif mqttErrno == mqtt.MQTT_ERR_CONN_REFUSED:
         return QCoreApplication.translate(
-            "MqttErrorMessage", 
+            "MqttErrorMessage",
             "The connection was refused.")
     elif mqttErrno == mqtt.MQTT_ERR_NOT_FOUND:
         return QCoreApplication.translate(
-            "MqttErrorMessage", 
+            "MqttErrorMessage",
             "Message not found (internal error).")
     elif mqttErrno == mqtt.MQTT_ERR_CONN_LOST:
         return QCoreApplication.translate(
-            "MqttErrorMessage", 
+            "MqttErrorMessage",
             "The connection was lost.")
     elif mqttErrno == mqtt.MQTT_ERR_TLS:
         return QCoreApplication.translate(
-            "MqttErrorMessage", 
+            "MqttErrorMessage",
             "A TLS error occurred.")
     elif mqttErrno == mqtt.MQTT_ERR_PAYLOAD_SIZE:
         return QCoreApplication.translate(
-            "MqttErrorMessage", 
+            "MqttErrorMessage",
             "Payload too large.")
     elif mqttErrno == mqtt.MQTT_ERR_NOT_SUPPORTED:
         return QCoreApplication.translate(
-            "MqttErrorMessage", 
+            "MqttErrorMessage",
             "This feature is not supported.")
     elif mqttErrno == mqtt.MQTT_ERR_AUTH:
         return QCoreApplication.translate(
-            "MqttErrorMessage", 
+            "MqttErrorMessage",
             "Authorisation failed.")
     elif mqttErrno == mqtt.MQTT_ERR_ACL_DENIED:
         return QCoreApplication.translate(
-            "MqttErrorMessage", 
+            "MqttErrorMessage",
             "Access denied by ACL.")
     elif mqttErrno == mqtt.MQTT_ERR_UNKNOWN:
         return QCoreApplication.translate(
-            "MqttErrorMessage", 
+            "MqttErrorMessage",
             "Unknown error.")
     elif mqttErrno == mqtt.MQTT_ERR_ERRNO:
         return QCoreApplication.translate(
-            "MqttErrorMessage", 
+            "MqttErrorMessage",
             "Error defined by errno.")
     else:
         return QCoreApplication.translate(
-            "MqttErrorMessage", 
+            "MqttErrorMessage",
             "Unknown error.")

eric ide

mercurial