CondaInterface/CondaExecDialog.py

branch
conda
changeset 6685
fbaee9890715
parent 6683
aca9d39fbfbd
child 6697
2f5c951bdf14
equal deleted inserted replaced
6684:37e280d711af 6685:fbaee9890715
43 @type QWidget 43 @type QWidget
44 """ 44 """
45 super(CondaExecDialog, self).__init__(parent) 45 super(CondaExecDialog, self).__init__(parent)
46 self.setupUi(self) 46 self.setupUi(self)
47 47
48 self.__finishCommandMethods = {
49 "create": self.__finishCreate,
50 }
51
48 self.__venvName = configuration["logicalName"] 52 self.__venvName = configuration["logicalName"]
49 self.__venvManager = venvManager 53 self.__venvManager = venvManager
54 self.__condaCommand = configuration["command"]
50 55
51 self.__process = None 56 self.__process = None
52 self.__condaExe = Preferences.getConda("CondaExecutable") 57 self.__condaExe = Preferences.getConda("CondaExecutable")
53 if not self.__condaExe: 58 if not self.__condaExe:
54 self.__condaExe = "conda" 59 self.__condaExe = "conda"
140 self.__logError(str(error)) 145 self.__logError(str(error))
141 return 146 return
142 147
143 if "error" in jsonDict: 148 if "error" in jsonDict:
144 self.__logError(jsonDict["error"]) 149 self.__logError(jsonDict["error"])
145
146 elif "success" in jsonDict and jsonDict["success"]: 150 elif "success" in jsonDict and jsonDict["success"]:
147 if "actions" in jsonDict and \ 151 self.__finishCommandMethods[self.__condaCommand](jsonDict)
148 "PREFIX" in jsonDict["actions"]: 152 else:
149 prefix = jsonDict["actions"]["PREFIX"] 153 self.__logError(
150 elif "prefix" in jsonDict: 154 self.tr("Conda command '{0}' did not return success.")
151 prefix = jsonDict["prefix"] 155 .format(self.__condaCommand))
152 elif "dst_prefix" in jsonDict:
153 prefix = jsonDict["dst_prefix"]
154 else:
155 prefix = ""
156 self.__venvManager.addVirtualEnv(self.__venvName,
157 prefix,
158 isConda=True)
159 elif self.__bufferedStdout: 156 elif self.__bufferedStdout:
160 self.__logOutput(self.__bufferedStdout) 157 self.__logOutput(self.__bufferedStdout)
161 158
162 def __progressLabelString(self, text): 159 def __finishCreate(self, resultDict):
163 """ 160 """
164 Private method to process a string and format it for the progress 161 Private method to finish the 'create' command.
165 label. 162
166 163 @param resultDict dictionary containing the 'create' result data
167 @param text text to be processed 164 @type dict
168 @type str 165 """
169 @return formatted progress label string 166 if "actions" in resultDict and \
170 @rtype str 167 "PREFIX" in resultDict["actions"]:
171 """ 168 prefix = resultDict["actions"]["PREFIX"]
172 parts = text.split("|") 169 elif "prefix" in resultDict:
173 if len(parts) > 1: 170 prefix = resultDict["prefix"]
174 return self.tr("{0} (Size: {1})".format(parts[0].strip(), 171 elif "dst_prefix" in resultDict:
175 parts[1].strip())) 172 prefix = resultDict["dst_prefix"]
176 else: 173 else:
177 return parts[0].strip() 174 prefix = ""
175 self.__venvManager.addVirtualEnv(self.__venvName,
176 prefix,
177 isConda=True)
178 178
179 def __setProgressValues(self, jsonDict, progressType): 179 def __setProgressValues(self, jsonDict, progressType):
180 """ 180 """
181 Private method to set the value of the progress bar. 181 Private method to set the value of the progress bar.
182 182

eric ide

mercurial