Browse Source

Added a lot more logging to debug the not-authenticated issue

Jaime van Kessel 7 years ago
parent
commit
826773ae42
1 changed files with 10 additions and 7 deletions
  1. 10 7
      plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py

+ 10 - 7
plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py

@@ -205,16 +205,16 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
         self._authentication_requested_message.setProgress(self._authentication_counter / self._max_authentication_counter * 100)
         if self._authentication_counter > self._max_authentication_counter:
             self._authentication_timer.stop()
-            Logger.log("i", "Authentication timer ended. Setting authentication to denied")
+            Logger.log("i", "Authentication timer ended. Setting authentication to denied for printer: %s" % self._key)
             self.setAuthenticationState(AuthState.AuthenticationDenied)
 
     def _onAuthenticationRequired(self, reply, authenticator):
         if self._authentication_id is not None and self._authentication_key is not None:
-            Logger.log("d", "Authentication was required. Setting up authenticator with ID %s and key %s", self._authentication_id, self._getSafeAuthKey())
+            Logger.log("d", "Authentication was required for printer: %s. Setting up authenticator with ID %s and key %s", self._key, self._authentication_id, self._getSafeAuthKey())
             authenticator.setUser(self._authentication_id)
             authenticator.setPassword(self._authentication_key)
         else:
-            Logger.log("d", "No authentication is available to use, but we did got a request for it.")
+            Logger.log("d", "No authentication is available to use for %s, but we did got a request for it.", self._key)
 
     def getProperties(self):
         return self._properties
@@ -369,6 +369,8 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
         if auth_state == self._authentication_state:
             return  # Nothing to do here.
 
+        Logger.log("d", "Attempting to update auth state from %s to %s for printer %s" % (self._authentication_state, auth_state, self._key))
+
         if auth_state == AuthState.AuthenticationRequested:
             Logger.log("d", "Authentication state changed to authentication requested.")
             self.setAcceptsCommands(False)
@@ -421,6 +423,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
     @pyqtSlot()
     def requestAuthentication(self, message_id = None, action_id = "Retry"):
         if action_id == "Request" or action_id == "Retry":
+            Logger.log("d", "Requestion authentication for %s due to action %s" % (self._key, action_id))
             self._authentication_failed_message.hide()
             self._not_authenticated_message.hide()
             self._authentication_state = AuthState.NotAuthenticated
@@ -652,7 +655,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
             return
         elif self._authentication_state != AuthState.Authenticated:
             self._not_authenticated_message.show()
-            Logger.log("d", "Attempting to perform an action without authentication. Auth state is %s", self._authentication_state)
+            Logger.log("d", "Attempting to perform an action without authentication for printer %s. Auth state is %s", self._key, self._authentication_state)
             return
 
         Application.getInstance().showPrintMonitor.emit(True)
@@ -780,7 +783,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
         if self._authentication_id is None and self._authentication_key is None:
             Logger.log("d", "No authentication found in metadata.")
         else:
-            Logger.log("d", "Loaded authentication id %s and key %s from the metadata entry", self._authentication_id, self._getSafeAuthKey())
+            Logger.log("d", "Loaded authentication id %s and key %s from the metadata entry for printer %s", self._authentication_id, self._getSafeAuthKey(), self._key)
 
         self._update_timer.start()
 
@@ -1084,7 +1087,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
                 if status_code == 401:
                     if self._authentication_state != AuthState.AuthenticationRequested:
                         # Only request a new authentication when we have not already done so.
-                        Logger.log("i", "Not authenticated (Current auth state is %s). Attempting to request authentication",  self._authentication_state )
+                        Logger.log("i", "Not authenticated (Current auth state is %s). Attempting to request authentication for printer %s",  self._authentication_state, self._key )
                         self._requestAuthentication()
                 elif status_code == 403:
                     # If we already had an auth (eg; didn't request one), we only need a single 403 to see it as denied.
@@ -1139,7 +1142,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
                     return
                 global_container_stack = Application.getInstance().getGlobalContainerStack()
                 if global_container_stack:  # Remove any old data.
-                    Logger.log("d", "Removing old network authentication data as a new one was requested.")
+                    Logger.log("d", "Removing old network authentication data for %s as a new one was requested.", self._key)
                     global_container_stack.removeMetaDataEntry("network_authentication_key")
                     global_container_stack.removeMetaDataEntry("network_authentication_id")
                     Application.getInstance().saveStack(global_container_stack)  # Force saving so we don't keep wrong auth data.