243 ), |
243 ), |
244 ) |
244 ) |
245 |
245 |
246 return interpreter |
246 return interpreter |
247 |
247 |
248 def getVirtualenvNames(self, noRemote=False, noConda=False): |
248 def getVirtualenvNames( |
|
249 self, noRemote=False, noConda=False, noGlobals=False, noServer=False |
|
250 ): |
249 """ |
251 """ |
250 Public method to get a sorted list of virtual environment names. |
252 Public method to get a sorted list of virtual environment names. |
251 |
253 |
252 @param noRemote flag indicating to exclude environments for remote |
254 @param noRemote flag indicating to exclude environments for remote |
253 debugging |
255 debugging (defaults to False) |
254 @type bool |
256 @type bool (optional) |
255 @param noConda flag indicating to exclude Conda environments |
257 @param noConda flag indicating to exclude Conda environments (defaults to False) |
256 @type bool |
258 @type bool (optional) |
|
259 @param noGlobals flag indicating to exclude global environments |
|
260 (defaults to False) |
|
261 @type bool (optional) |
|
262 @param noServer flag indicating to exclued eric-ide server environments |
|
263 (defaults to False) |
|
264 @type bool (optional) |
257 @return sorted list of virtual environment names |
265 @return sorted list of virtual environment names |
258 @rtype list of str |
266 @rtype list of str |
259 """ |
267 """ |
260 return sorted( |
268 return sorted( |
261 ericApp() |
269 ericApp() |
262 .getObject("VirtualEnvManager") |
270 .getObject("VirtualEnvManager") |
263 .getVirtualenvNames(noRemote=noRemote, noConda=noConda) |
271 .getVirtualenvNames( |
|
272 noRemote=noRemote, |
|
273 noConda=noConda, |
|
274 noGlobals=noGlobals, |
|
275 noServer=noServer, |
|
276 ) |
264 ) |
277 ) |
265 |
278 |
266 def installPip(self, venvName, userSite=False): |
279 def installPip(self, venvName, userSite=False): |
267 """ |
280 """ |
268 Public method to install pip. |
281 Public method to install pip. |
882 None, it will override the given environment name (defaults to None) |
895 None, it will override the given environment name (defaults to None) |
883 @type str (optional) |
896 @type str (optional) |
884 @param callback method accepting a list of tuples containing the |
897 @param callback method accepting a list of tuples containing the |
885 package name, installed version and available version |
898 package name, installed version and available version |
886 @type function |
899 @type function |
887 @return list of tuples containing the package name, installed version |
900 @return dictionary with the package name as key and a tuple containing the |
888 and available version |
901 installed and available version as the value |
889 @rtype list of tuple of (str, str, str) |
902 @rtype dict of [str: (str, str)] |
890 """ |
903 """ |
891 packages = [] |
904 packages = [] |
892 |
905 |
893 if envName: |
906 if envName: |
894 if interpreter is None: |
907 if interpreter is None: |
931 """ |
944 """ |
932 Private method to extract the outdated packages list out of the process output. |
945 Private method to extract the outdated packages list out of the process output. |
933 |
946 |
934 @param proc reference to the process |
947 @param proc reference to the process |
935 @type QProcess |
948 @type QProcess |
936 @return list of tuples containing the package name, installed version |
949 @return dictionary with the package name as key and a tuple containing the |
937 and available version |
950 installed and available version as the value |
938 @rtype list of tuple of (str, str, str) |
951 @rtype dict of [str: (str, str)] |
939 """ |
952 """ |
940 packages = [] |
953 packages = {} |
941 |
954 |
942 output = str( |
955 output = str( |
943 proc.readAllStandardOutput(), |
956 proc.readAllStandardOutput(), |
944 Preferences.getSystem("IOEncoding"), |
957 Preferences.getSystem("IOEncoding"), |
945 "replace", |
958 "replace", |
951 except Exception: |
964 except Exception: |
952 jsonList = [] |
965 jsonList = [] |
953 |
966 |
954 for package in jsonList: |
967 for package in jsonList: |
955 if isinstance(package, dict): |
968 if isinstance(package, dict): |
956 packages.append( |
969 packages[package["name"]] = ( |
957 ( |
970 package["version"], |
958 package["name"], |
971 package["latest_version"], |
959 package["version"], |
|
960 package["latest_version"], |
|
961 ) |
|
962 ) |
972 ) |
963 |
973 |
964 return packages |
974 return packages |
965 |
975 |
966 def __outdatedFinished(self, callback, proc, exitCode, exitStatus): |
976 def __outdatedFinished(self, callback, proc, exitCode, exitStatus): |
978 @type QProcess.ExitStatus |
988 @type QProcess.ExitStatus |
979 """ |
989 """ |
980 packages = ( |
990 packages = ( |
981 self.__extractOutdatedPackages(proc) |
991 self.__extractOutdatedPackages(proc) |
982 if exitStatus == QProcess.ExitStatus.NormalExit and exitCode == 0 |
992 if exitStatus == QProcess.ExitStatus.NormalExit and exitCode == 0 |
983 else [] |
993 else {} |
984 ) |
994 ) |
985 callback(packages) |
995 callback(packages) |
986 self.__outdatedProc = None |
996 self.__outdatedProc = None |
987 |
997 |
988 def checkPackagesOutdated(self, packageStarts, envName, interpreter=None): |
998 def checkPackagesOutdated(self, packageStarts, envName, interpreter=None): |
1005 packages = self.getOutdatedPackages(envName, interpreter=interpreter) |
1015 packages = self.getOutdatedPackages(envName, interpreter=interpreter) |
1006 filterStrings = tuple( |
1016 filterStrings = tuple( |
1007 start.lower() for start in packageStarts if bool(start) |
1017 start.lower() for start in packageStarts if bool(start) |
1008 ) |
1018 ) |
1009 filteredPackages = [ |
1019 filteredPackages = [ |
1010 p for p in packages if p[0].lower().startswith(filterStrings) |
1020 (p, packages[p][0], packages[p][1]) |
|
1021 for p in packages |
|
1022 if p.lower().startswith(filterStrings) |
1011 ] |
1023 ] |
1012 else: |
1024 else: |
1013 filteredPackages = [] |
1025 filteredPackages = [] |
1014 |
1026 |
1015 return filteredPackages |
1027 return filteredPackages |