19 |
19 |
20 from eric7 import Preferences |
20 from eric7 import Preferences |
21 from eric7.EricNetwork.EricNetworkProxyFactory import proxyAuthenticationRequired |
21 from eric7.EricNetwork.EricNetworkProxyFactory import proxyAuthenticationRequired |
22 from eric7.EricWidgets import EricMessageBox |
22 from eric7.EricWidgets import EricMessageBox |
23 from eric7.EricWidgets.EricApplication import ericApp |
23 from eric7.EricWidgets.EricApplication import ericApp |
24 from eric7.SystemUtilities import OSUtilities, PythonUtilities |
24 from eric7.SystemUtilities import FileSystemUtilities, OSUtilities, PythonUtilities |
25 from eric7.UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
25 from eric7.UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
26 |
26 |
27 try: |
27 try: |
28 from eric7.EricNetwork.EricSslErrorHandler import EricSslErrorHandler |
28 from eric7.EricNetwork.EricSslErrorHandler import EricSslErrorHandler |
29 |
29 |
128 else: |
128 else: |
129 process.terminate() |
129 process.terminate() |
130 process.waitForFinished(2000) |
130 process.waitForFinished(2000) |
131 process.kill() |
131 process.kill() |
132 process.waitForFinished(3000) |
132 process.waitForFinished(3000) |
133 return False, self.tr("python did not finish within" " 30 seconds.") |
133 return False, self.tr("python did not finish within 30 seconds.") |
134 |
134 |
135 return False, self.tr("python could not be started.") |
135 return False, self.tr("python could not be started.") |
136 |
136 |
137 def getUserConfig(self): |
137 def getUserConfig(self): |
138 """ |
138 """ |
348 @rtype bool |
348 @rtype bool |
349 """ |
349 """ |
350 ericPackages = [p for p in packages if p.lower() == "eric-ide"] |
350 ericPackages = [p for p in packages if p.lower() == "eric-ide"] |
351 return bool(ericPackages) |
351 return bool(ericPackages) |
352 |
352 |
|
353 def __filterUpgradePackages(self, packages): |
|
354 """ |
|
355 Private method to filter out the packages that cannot be upgraded without |
|
356 stopping eric first. |
|
357 |
|
358 @param packages list of packages to upgrade |
|
359 @type list of str |
|
360 @return list of packages that can be upgraded |
|
361 @rtype list of str |
|
362 """ |
|
363 return [ |
|
364 p |
|
365 for p in packages |
|
366 if p.lower() |
|
367 not in ( |
|
368 "eric-ide", |
|
369 "pyqt6", |
|
370 "pyqt6-sip", |
|
371 "pyqt6-webengine", |
|
372 "pyqt6-charts", |
|
373 "pyqt6-qscintilla", |
|
374 "pyqt6-qt6", |
|
375 "pyqt6-webengine-qt6", |
|
376 "pyqt6-charts-qt6", |
|
377 ) |
|
378 ] |
|
379 |
353 def upgradePackages(self, packages, venvName, userSite=False): |
380 def upgradePackages(self, packages, venvName, userSite=False): |
354 """ |
381 """ |
355 Public method to upgrade the given list of packages. |
382 Public method to upgrade the given list of packages. |
356 |
383 |
357 @param packages list of packages to upgrade |
384 @param packages list of packages to upgrade |
365 @rtype bool |
392 @rtype bool |
366 """ |
393 """ |
367 if not venvName: |
394 if not venvName: |
368 return False |
395 return False |
369 |
396 |
370 if self.getVirtualenvInterpreter(venvName) in ( |
397 interpreter = self.getVirtualenvInterpreter(venvName) |
371 sys.executable, |
398 if not interpreter: |
372 PythonUtilities.getPythonExecutable(), |
399 return False |
|
400 |
|
401 if FileSystemUtilities.samefilepath( |
|
402 interpreter, sys.executable, followSymlinks=False |
373 ): |
403 ): |
374 upgradePyQt = self.__checkUpgradePyQt(packages) |
404 upgradePyQt = self.__checkUpgradePyQt(packages) |
375 upgradeEric = self.__checkUpgradeEric(packages) |
405 upgradeEric = self.__checkUpgradeEric(packages) |
376 if upgradeEric or upgradePyQt: |
406 if upgradeEric or upgradePyQt: |
377 try: |
407 try: |
378 if upgradeEric and upgradePyQt: |
408 if upgradeEric and upgradePyQt: |
379 self.__ui.upgradeEricPyQt() |
409 res = self.__ui.upgradeEricPyQt() |
380 elif upgradeEric: |
410 elif upgradeEric: |
381 self.__ui.upgradeEric() |
411 res = self.__ui.upgradeEric() |
382 elif upgradePyQt: |
412 elif upgradePyQt: |
383 self.__ui.upgradePyQt() |
413 res = self.__ui.upgradePyQt() |
384 return None # should not be reached; play it safe |
414 else: |
|
415 return None # should not be reached; play it safe |
|
416 |
|
417 if not res: |
|
418 # user rejected PyQt6 and/or eric-ide/eric7 update |
|
419 packages = self.__filterUpgradePackages(packages) |
385 except AttributeError: |
420 except AttributeError: |
386 return False |
421 return False |
387 |
|
388 interpreter = self.getVirtualenvInterpreter(venvName) |
|
389 if not interpreter: |
|
390 return False |
|
391 |
422 |
392 if Preferences.getPip("PipSearchIndex"): |
423 if Preferences.getPip("PipSearchIndex"): |
393 indexUrl = Preferences.getPip("PipSearchIndex") + "/simple" |
424 indexUrl = Preferences.getPip("PipSearchIndex") + "/simple" |
394 args = ["-m", "pip", "install", "--index-url", indexUrl, "--upgrade"] |
425 args = ["-m", "pip", "install", "--index-url", indexUrl, "--upgrade"] |
395 else: |
426 else: |
893 dataStr = str( |
924 dataStr = str( |
894 reply.readAll(), Preferences.getSystem("IOEncoding"), "replace" |
925 reply.readAll(), Preferences.getSystem("IOEncoding"), "replace" |
895 ) |
926 ) |
896 with contextlib.suppress(json.JSONDecodeError, KeyError): |
927 with contextlib.suppress(json.JSONDecodeError, KeyError): |
897 data = json.loads(dataStr) |
928 data = json.loads(dataStr) |
898 result = list(data["releases"].keys()) |
929 result = list(data["releases"]) |
899 |
930 |
900 return result |
931 return result |
901 |
932 |
902 def getFrozenPackages( |
933 def getFrozenPackages( |
903 self, envName, localPackages=True, usersite=False, requirement=None |
934 self, envName, localPackages=True, usersite=False, requirement=None |