src/eric7/EricNetwork/EricJsonServer.py

branch
eric7
changeset 10928
46651e194fbe
parent 10697
8a609e4c71b6
child 11090
f5f5f5803935
--- a/src/eric7/EricNetwork/EricJsonServer.py	Thu Sep 26 09:48:49 2024 +0200
+++ b/src/eric7/EricNetwork/EricJsonServer.py	Thu Sep 26 15:49:36 2024 +0200
@@ -9,6 +9,7 @@
 
 import contextlib
 import json
+import shutil
 import struct
 import time
 import zlib
@@ -24,9 +25,8 @@
 )
 from PyQt6.QtNetwork import QHostAddress, QTcpServer
 
-from eric7 import Preferences, Utilities
+from eric7 import EricUtilities
 from eric7.EricWidgets import EricMessageBox
-from eric7.SystemUtilities import FileSystemUtilities
 
 
 class EricJsonServer(QTcpServer):
@@ -34,16 +34,19 @@
     Class implementing a JSON based server base class.
     """
 
-    def __init__(self, name="", multiplex=False, parent=None):
+    def __init__(self, name="", interface="127.0.0.1", multiplex=False, parent=None):
         """
         Constructor
 
-        @param name name of the server (used for output only)
-        @type str
-        @param multiplex flag indicating a multiplexing server
-        @type bool
-        @param parent parent object
-        @type QObject
+        @param name name of the server (used for output only) (defaults to "")
+        @type str (optional)
+        @param interface network interface to be used (IP address or one of "all",
+            "allv4", "allv6", "localv4" or "localv6") (defaults to "127.0.0.1")
+        @type str (optional)
+        @param multiplex flag indicating a multiplexing server (defaults to False)
+        @type bool (optional)
+        @param parent reference to the parent object (defaults to None)
+        @type QObject (optional)
         """
         super().__init__(parent)
 
@@ -57,15 +60,14 @@
             self.__connection = None
 
         # setup the network interface
-        networkInterface = Preferences.getDebugger("NetworkInterface")
-        if networkInterface in ("allv4", "localv4") or "." in networkInterface:
+        if interface in ("allv4", "localv4") or "." in interface:
             # IPv4
             self.__hostAddress = "127.0.0.1"
-        elif networkInterface in ("all", "allv6", "localv6"):
+        elif interface in ("all", "allv6", "localv6"):
             # IPv6
             self.__hostAddress = "::1"
         else:
-            self.__hostAddress = networkInterface
+            self.__hostAddress = interface
         self.listen(QHostAddress(self.__hostAddress))
 
         self.newConnection.connect(self.handleNewConnection)
@@ -204,7 +206,7 @@
                         """ eric bugs email address.</p>"""
                         """<p>Error: {0}</p>"""
                         """<p>Data:<br/>{1}</p>"""
-                    ).format(str(err), Utilities.html_encode(jsonString.strip())),
+                    ).format(str(err), EricUtilities.html_encode(jsonString.strip())),
                     EricMessageBox.Ok,
                 )
                 return
@@ -267,7 +269,7 @@
             in case of an issue
         @rtype bool, int
         """
-        if interpreter == "" or not FileSystemUtilities.isinpath(interpreter):
+        if interpreter == "" or not bool(shutil.which(interpreter)):
             return False, -1
 
         exitCode = None

eric ide

mercurial