src/eric7/PipInterface/Pip.py

branch
eric7-maintenance
changeset 10941
07cad049002c
parent 10814
ba20efe10336
parent 10928
46651e194fbe
child 11019
27cd57e98461
diff -r ea32acb9764c -r 07cad049002c src/eric7/PipInterface/Pip.py
--- a/src/eric7/PipInterface/Pip.py	Sat Aug 31 10:54:50 2024 +0200
+++ b/src/eric7/PipInterface/Pip.py	Tue Oct 01 11:27:52 2024 +0200
@@ -26,6 +26,8 @@
 from PyQt6.QtWidgets import QDialog, QInputDialog, QLineEdit
 
 from eric7 import Preferences
+from eric7.EricCore import EricPreferences
+from eric7.EricCore.EricProcess import EricProcess
 from eric7.EricNetwork.EricNetworkProxyFactory import (
     EricNetworkProxyFactory,
     proxyAuthenticationRequired,
@@ -68,7 +70,7 @@
         self.__ui = parent
 
         # attributes for the network objects
-        if Preferences.getUI("UseSystemProxy"):
+        if EricPreferences.getNetworkProxy("UseSystemProxy"):
             QNetworkProxyFactory.setUseSystemConfiguration(True)
         else:
             self.__proxyFactory = EricNetworkProxyFactory()
@@ -80,12 +82,16 @@
             proxyAuthenticationRequired
         )
         if SSL_AVAILABLE:
-            self.__sslErrorHandler = EricSslErrorHandler(self)
+            self.__sslErrorHandler = EricSslErrorHandler(
+                Preferences.getSettings(), self
+            )
             self.__networkManager.sslErrors.connect(
                 self.__sslErrorHandler.sslErrorsReply
             )
         self.__replies = []
 
+        self.__outdatedProc = None
+
         self.__vulnerabilityChecker = PipVulnerabilityChecker(self, self)
 
     def getNetworkAccessManager(self):
@@ -106,6 +112,14 @@
         """
         return self.__vulnerabilityChecker
 
+    def shutdown(self):
+        """
+        Public method to perform shutdown actions.
+        """
+        if self.__outdatedProc is not None:
+            self.__outdatedProc.kill()  # end the process forcefully
+            self.__outdatedProc = None
+
     ##########################################################################
     ## Methods below implement some utility functions
     ##########################################################################
@@ -925,8 +939,12 @@
                     indexUrl = Preferences.getPip("PipSearchIndex") + "/simple"
                     args += ["--index-url", indexUrl]
 
-                proc = QProcess()
                 if callback:
+                    if self.__outdatedProc is not None:
+                        self.__outdatedProc.kill()  # end the process forcefully
+                        self.__outdatedProc = None
+
+                    proc = EricProcess(timeout=30000)
                     self.__outdatedProc = proc
                     proc.finished.connect(
                         functools.partial(self.__outdatedFinished, callback, proc)
@@ -934,6 +952,7 @@
                     proc.start(interpreter, args)
                     return None
 
+                proc = QProcess()
                 proc.start(interpreter, args)
                 if proc.waitForStarted(15000) and proc.waitForFinished(30000):
                     packages = self.__extractOutdatedPackages(proc)
@@ -989,7 +1008,11 @@
         """
         packages = (
             self.__extractOutdatedPackages(proc)
-            if exitStatus == QProcess.ExitStatus.NormalExit and exitCode == 0
+            if (
+                not proc.timedOut()
+                and exitStatus == QProcess.ExitStatus.NormalExit
+                and exitCode == 0
+            )
             else {}
         )
         callback(packages)

eric ide

mercurial