diff -r 772563b2eb0a -r 8cf1c3851b5c CondaInterface/Conda.py --- a/CondaInterface/Conda.py Wed Feb 06 19:35:51 2019 +0100 +++ b/CondaInterface/Conda.py Wed Feb 06 19:52:33 2019 +0100 @@ -167,17 +167,13 @@ return jsonDict["success"] - def getCondaEnvironmentsList(self, listPrefixes=False): + def getCondaEnvironmentsList(self): """ Public method to get a list of all Conda environments. - @param listPrefixes flag indicating to return prefixes instead of names - @type bool - @return list of environment names or prefixes - @rtype list of str + @return list of tuples containing the environment name and prefix + @rtype list of tuples of (str, str) """ - # TODO: return environment name and prefix - # TODO: return root environment only, if writable ('root_prefix', 'root_writable') exe = Preferences.getConda("CondaExecutable") if not exe: exe = "conda" @@ -197,11 +193,16 @@ jsonDict = {} if "envs" in jsonDict: - if listPrefixes: - environmentsList = jsonDict["envs"][:] - else: - environmentsList = [ - os.path.basename(e) for e in jsonDict["envs"]] + for prefix in jsonDict["envs"][:]: + if prefix == jsonDict["root_prefix"]: + if not jsonDict["root_writable"]: + # root prefix is listed but not writable + continue + name = self.tr("<root>") + else: + name = os.path.basename(prefix) + + environmentsList.append((name, prefix)) return environmentsList @@ -250,7 +251,7 @@ proc = QProcess() proc.start(exe, args) if proc.waitForStarted(15000): - if proc.waitForFinished(15000): + if proc.waitForFinished(30000): output = str(proc.readAllStandardOutput(), Preferences.getSystem("IOEncoding"), 'replace').strip() @@ -315,7 +316,7 @@ proc = QProcess() proc.start(exe, args) if proc.waitForStarted(15000): - if proc.waitForFinished(15000): + if proc.waitForFinished(30000): output = str(proc.readAllStandardOutput(), Preferences.getSystem("IOEncoding"), 'replace').strip()