src/eric7/Toolbox/SingleApplication.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
--- a/src/eric7/Toolbox/SingleApplication.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/Toolbox/SingleApplication.py	Wed Jul 13 14:55:47 2022 +0200
@@ -21,20 +21,21 @@
     """
     Class implementing the single application server base class.
     """
+
     def __init__(self, name):
         """
         Constructor
-        
+
         @param name name this server is listening to (string)
         """
         super().__init__()
-        
+
         res = self.listen(name)
         if not res:
             # maybe it crashed last time
             self.removeServer(name)
             self.listen(name)
-        
+
         self.newConnection.connect(self.__newConnection)
 
         self.qsock = None
@@ -61,36 +62,38 @@
         """
         while self.qsock and self.qsock.canReadLine():
             line = bytes(self.qsock.readLine()).decode()
-            
-##            print(line)          ## debug         # __IGNORE_WARNING_M891__
-            
+
+            ##print(line)          ## debug         # __IGNORE_WARNING_M891__
+
             try:
                 commandDict = json.loads(line.strip())
             except (TypeError, ValueError) as err:
                 EricMessageBox.critical(
                     None,
                     self.tr("Single Application Protocol Error"),
-                    self.tr("""<p>The response received from the single"""
-                            """ application client could not be decoded."""
-                            """ Please report this issue with the received"""
-                            """ data to the eric bugs email address.</p>"""
-                            """<p>Error: {0}</p>"""
-                            """<p>Data:<br/>{1}</p>""").format(
-                        str(err), Utilities.html_encode(line.strip())),
-                    EricMessageBox.Ok)
+                    self.tr(
+                        """<p>The response received from the single"""
+                        """ application client could not be decoded."""
+                        """ Please report this issue with the received"""
+                        """ data to the eric bugs email address.</p>"""
+                        """<p>Error: {0}</p>"""
+                        """<p>Data:<br/>{1}</p>"""
+                    ).format(str(err), Utilities.html_encode(line.strip())),
+                    EricMessageBox.Ok,
+                )
                 return
-            
+
             command = commandDict["command"]
             arguments = commandDict["arguments"]
-            
+
             self.handleCommand(command, arguments)
-    
+
     def __disconnected(self):
         """
         Private method to handle the closure of the socket.
         """
         self.qsock = None
-    
+
     def shutdown(self):
         """
         Public method used to shut down the server.
@@ -98,17 +101,17 @@
         if self.qsock is not None:
             self.qsock.readyRead.disconnect(self.__parseLine)
             self.qsock.disconnected.disconnect(self.__disconnected)
-        
+
         self.qsock = None
-        
+
         self.close()
 
     def handleCommand(self, command, arguments):
         """
         Public slot to handle the command sent by the client.
-        
+
         <b>Note</b>: This method must be overridden by subclasses.
-        
+
         @param command command sent by the client
         @type str
         @param arguments list of command arguments
@@ -123,19 +126,20 @@
     """
     Class implementing the single application client base class.
     """
+
     def __init__(self, name):
         """
         Constructor
-        
+
         @param name name of the local server to connect to (string)
         """
         self.name = name
         self.connected = False
-        
+
     def connect(self, timeout=10000):
         """
         Public method to connect the single application client to its server.
-        
+
         @param timeout connection timeout value in milliseconds
         @type int
         @return value indicating success or an error number. Value is one of:
@@ -155,30 +159,30 @@
                 return 0
             else:
                 return -err.value
-        
+
     def disconnect(self):
         """
         Public method to disconnect from the Single Appliocation server.
         """
         self.sock.disconnectFromServer()
         self.connected = False
-    
+
     def processArgs(self, args):
         """
         Public method to process the command line args passed to the UI.
-        
+
         <b>Note</b>: This method must be overridden by subclasses.
-        
+
         @param args command line args (list of strings)
         @exception RuntimeError raised to indicate that this method must be
             implemented by a subclass
         """
         raise RuntimeError("'processArgs' must be overridden")
-    
+
     def sendCommand(self, command, arguments):
         """
         Public method to send the command to the application server.
-        
+
         @param command command to be sent to the server
         @type str
         @param arguments list of command arguments
@@ -189,15 +193,15 @@
                 "command": command,
                 "arguments": arguments,
             }
-            self.sock.write(QByteArray(
-                "{0}\n".format(json.dumps(commandDict)).encode()
-            ))
+            self.sock.write(
+                QByteArray("{0}\n".format(json.dumps(commandDict)).encode())
+            )
             self.sock.flush()
-        
+
     def errstr(self):
         """
         Public method to return a meaningful error string for the last error.
-        
+
         @return error string for the last error (string)
         """
         return self.sock.errorString()

eric ide

mercurial