24 QNetworkRequest, |
24 QNetworkRequest, |
25 ) |
25 ) |
26 from PyQt6.QtWidgets import QDialog, QInputDialog, QLineEdit |
26 from PyQt6.QtWidgets import QDialog, QInputDialog, QLineEdit |
27 |
27 |
28 from eric7 import Preferences |
28 from eric7 import Preferences |
|
29 from eric7.EricCore import EricPreferences |
|
30 from eric7.EricCore.EricProcess import EricProcess |
29 from eric7.EricNetwork.EricNetworkProxyFactory import ( |
31 from eric7.EricNetwork.EricNetworkProxyFactory import ( |
30 EricNetworkProxyFactory, |
32 EricNetworkProxyFactory, |
31 proxyAuthenticationRequired, |
33 proxyAuthenticationRequired, |
32 ) |
34 ) |
33 from eric7.EricWidgets import EricMessageBox |
35 from eric7.EricWidgets import EricMessageBox |
66 super().__init__(parent) |
68 super().__init__(parent) |
67 |
69 |
68 self.__ui = parent |
70 self.__ui = parent |
69 |
71 |
70 # attributes for the network objects |
72 # attributes for the network objects |
71 if Preferences.getUI("UseSystemProxy"): |
73 if EricPreferences.getNetworkProxy("UseSystemProxy"): |
72 QNetworkProxyFactory.setUseSystemConfiguration(True) |
74 QNetworkProxyFactory.setUseSystemConfiguration(True) |
73 else: |
75 else: |
74 self.__proxyFactory = EricNetworkProxyFactory() |
76 self.__proxyFactory = EricNetworkProxyFactory() |
75 QNetworkProxyFactory.setApplicationProxyFactory(self.__proxyFactory) |
77 QNetworkProxyFactory.setApplicationProxyFactory(self.__proxyFactory) |
76 QNetworkProxyFactory.setUseSystemConfiguration(False) |
78 QNetworkProxyFactory.setUseSystemConfiguration(False) |
78 self.__networkManager = QNetworkAccessManager(self) |
80 self.__networkManager = QNetworkAccessManager(self) |
79 self.__networkManager.proxyAuthenticationRequired.connect( |
81 self.__networkManager.proxyAuthenticationRequired.connect( |
80 proxyAuthenticationRequired |
82 proxyAuthenticationRequired |
81 ) |
83 ) |
82 if SSL_AVAILABLE: |
84 if SSL_AVAILABLE: |
83 self.__sslErrorHandler = EricSslErrorHandler(self) |
85 self.__sslErrorHandler = EricSslErrorHandler( |
|
86 Preferences.getSettings(), self |
|
87 ) |
84 self.__networkManager.sslErrors.connect( |
88 self.__networkManager.sslErrors.connect( |
85 self.__sslErrorHandler.sslErrorsReply |
89 self.__sslErrorHandler.sslErrorsReply |
86 ) |
90 ) |
87 self.__replies = [] |
91 self.__replies = [] |
88 |
92 |
|
93 self.__outdatedProc = None |
|
94 |
89 self.__vulnerabilityChecker = PipVulnerabilityChecker(self, self) |
95 self.__vulnerabilityChecker = PipVulnerabilityChecker(self, self) |
90 |
96 |
91 def getNetworkAccessManager(self): |
97 def getNetworkAccessManager(self): |
92 """ |
98 """ |
93 Public method to get a reference to the network access manager object. |
99 Public method to get a reference to the network access manager object. |
103 |
109 |
104 @return reference to the vulnerability checker object |
110 @return reference to the vulnerability checker object |
105 @rtype PipVulnerabilityChecker |
111 @rtype PipVulnerabilityChecker |
106 """ |
112 """ |
107 return self.__vulnerabilityChecker |
113 return self.__vulnerabilityChecker |
|
114 |
|
115 def shutdown(self): |
|
116 """ |
|
117 Public method to perform shutdown actions. |
|
118 """ |
|
119 if self.__outdatedProc is not None: |
|
120 self.__outdatedProc.kill() # end the process forcefully |
|
121 self.__outdatedProc = None |
108 |
122 |
109 ########################################################################## |
123 ########################################################################## |
110 ## Methods below implement some utility functions |
124 ## Methods below implement some utility functions |
111 ########################################################################## |
125 ########################################################################## |
112 |
126 |
923 |
937 |
924 if Preferences.getPip("PipSearchIndex"): |
938 if Preferences.getPip("PipSearchIndex"): |
925 indexUrl = Preferences.getPip("PipSearchIndex") + "/simple" |
939 indexUrl = Preferences.getPip("PipSearchIndex") + "/simple" |
926 args += ["--index-url", indexUrl] |
940 args += ["--index-url", indexUrl] |
927 |
941 |
928 proc = QProcess() |
|
929 if callback: |
942 if callback: |
|
943 if self.__outdatedProc is not None: |
|
944 self.__outdatedProc.kill() # end the process forcefully |
|
945 self.__outdatedProc = None |
|
946 |
|
947 proc = EricProcess(timeout=30000) |
930 self.__outdatedProc = proc |
948 self.__outdatedProc = proc |
931 proc.finished.connect( |
949 proc.finished.connect( |
932 functools.partial(self.__outdatedFinished, callback, proc) |
950 functools.partial(self.__outdatedFinished, callback, proc) |
933 ) |
951 ) |
934 proc.start(interpreter, args) |
952 proc.start(interpreter, args) |
935 return None |
953 return None |
936 |
954 |
|
955 proc = QProcess() |
937 proc.start(interpreter, args) |
956 proc.start(interpreter, args) |
938 if proc.waitForStarted(15000) and proc.waitForFinished(30000): |
957 if proc.waitForStarted(15000) and proc.waitForFinished(30000): |
939 packages = self.__extractOutdatedPackages(proc) |
958 packages = self.__extractOutdatedPackages(proc) |
940 |
959 |
941 return packages |
960 return packages |
987 @param exitStatus exit status of the process |
1006 @param exitStatus exit status of the process |
988 @type QProcess.ExitStatus |
1007 @type QProcess.ExitStatus |
989 """ |
1008 """ |
990 packages = ( |
1009 packages = ( |
991 self.__extractOutdatedPackages(proc) |
1010 self.__extractOutdatedPackages(proc) |
992 if exitStatus == QProcess.ExitStatus.NormalExit and exitCode == 0 |
1011 if ( |
|
1012 not proc.timedOut() |
|
1013 and exitStatus == QProcess.ExitStatus.NormalExit |
|
1014 and exitCode == 0 |
|
1015 ) |
993 else {} |
1016 else {} |
994 ) |
1017 ) |
995 callback(packages) |
1018 callback(packages) |
996 self.__outdatedProc = None |
1019 self.__outdatedProc = None |
997 |
1020 |