src/eric7/VirtualEnv/VirtualenvManager.py

branch
server
changeset 10764
5915ca2466b2
parent 10746
b8fae72eb04d
child 10765
b0632e55ec9a
diff -r 4b6220e694da -r 5915ca2466b2 src/eric7/VirtualEnv/VirtualenvManager.py
--- a/src/eric7/VirtualEnv/VirtualenvManager.py	Mon Jun 10 10:19:08 2024 +0200
+++ b/src/eric7/VirtualEnv/VirtualenvManager.py	Mon Jun 10 10:19:54 2024 +0200
@@ -85,6 +85,8 @@
         #   is_conda:       a flag indicating an Anaconda environment
         #   is_remote:      a flag indicating a remotely accessed environment
         #   is_eric_server  a flag indicating an eric IDE server environment
+        #   eric_server     a string giving the server name in case of an
+        #                   eric IDE server environment
         #   exec_path:      a string to be prefixed to the PATH environment
         #                   setting
         #   description     a description of the environment
@@ -684,21 +686,6 @@
         except KeyError:
             return False
 
-    def isEricServerEnvironment(self, venvName):
-        """
-        Public method to test, if a given environment is an environment accessed
-        through an eric IDE server.
-
-        @param venvName logical name of the virtual environment
-        @type str
-        @return flag indicating a remotely accessed environment
-        @rtype bool
-        """
-        try:
-            return self.__virtualEnvironments[venvName].is_eric_server
-        except KeyError:
-            return False
-
     def getVirtualenvExecPath(self, venvName):
         """
         Public method to get the search path prefix of a virtual environment.
@@ -731,3 +718,45 @@
         @rtype str
         """
         return self.__virtualEnvironmentsBaseDir
+
+    def isEricServerEnvironment(self, venvName, host=""):
+        """
+        Public method to test, if a given environment is an environment accessed
+        through an eric IDE server.
+
+        @param venvName logical name of the virtual environment
+        @type str
+        @param host name of the host to check for or empty string to just check for
+            an eric IDE server environment
+        @return flag indicating an eric IDE server environment
+        @rtype bool
+        """
+        try:
+            if host:
+                return (
+                    self.__virtualEnvironments[venvName].is_eric_server
+                    and self.__virtualEnvironments[venvName].eric_server.startswith(
+                        f"{host}:"
+                    )
+                )
+            else:
+                return self.__virtualEnvironments[venvName].is_eric_server
+        except KeyError:
+            return False
+
+    def getEricServerEnvironmentNames(self, host=""):
+        """
+        Public method to get a list of defined eric IDE server environments.
+
+        @param host host name to get environment names for (defaults to "")
+        @type str (optional)
+        @return list of defined eric IDE server environments
+        @rtype list of str
+        """
+        environments = [
+            name
+            for name in self.__virtualEnvironments
+            if self.isEricServerEnvironment(name, host=host)
+        ]
+
+        return environments

eric ide

mercurial