src/eric7/VirtualEnv/VirtualenvManager.py

branch
eric7
changeset 10931
56f41b1e163a
parent 10770
8b4ff92221da
child 10971
b9d883f73dff
--- a/src/eric7/VirtualEnv/VirtualenvManager.py	Fri Sep 27 10:28:32 2024 +0200
+++ b/src/eric7/VirtualEnv/VirtualenvManager.py	Fri Sep 27 10:59:59 2024 +0200
@@ -166,17 +166,19 @@
                 venvPath = venvItem.path
                 if venvPath:
                     if venvItem.is_eric_server:
-                        # It is an eric-ide server environment; check it is still valid.
-                        ericServer = ericApp().getObject("EricServer")
-                        if (
-                            ericServer.isServerConnected()
-                            and ericServer.getHost() == venvItem.eric_server
-                            and not ericServer.getServiceInterface("FileSystem").exists(
-                                venvPath
-                            )
-                        ):
-                            del self.__virtualEnvironments[venvName]
-                            removed = True
+                        with contextlib.suppress(KeyError):
+                            # It is an eric-ide server environment; check it is
+                            # still valid.
+                            ericServer = ericApp().getObject("EricServer")
+                            if (
+                                ericServer.isServerConnected()
+                                and ericServer.getHost() == venvItem.eric_server
+                                and not ericServer.getServiceInterface(
+                                    "FileSystem"
+                                ).exists(venvPath)
+                            ):
+                                del self.__virtualEnvironments[venvName]
+                                removed = True
                     else:
                         # It is a local environment; check it is still valid.
                         if not os.path.exists(venvPath):

eric ide

mercurial