CondaInterface/CondaExecDialog.py

branch
conda
changeset 6685
fbaee9890715
parent 6683
aca9d39fbfbd
child 6697
2f5c951bdf14
diff -r 37e280d711af -r fbaee9890715 CondaInterface/CondaExecDialog.py
--- a/CondaInterface/CondaExecDialog.py	Wed Jan 30 18:55:32 2019 +0100
+++ b/CondaInterface/CondaExecDialog.py	Wed Jan 30 18:56:27 2019 +0100
@@ -45,8 +45,13 @@
         super(CondaExecDialog, self).__init__(parent)
         self.setupUi(self)
         
+        self.__finishCommandMethods = {
+            "create": self.__finishCreate,
+        }
+        
         self.__venvName = configuration["logicalName"]
         self.__venvManager = venvManager
+        self.__condaCommand = configuration["command"]
         
         self.__process = None
         self.__condaExe = Preferences.getConda("CondaExecutable")
@@ -142,39 +147,34 @@
                 
                 if "error" in jsonDict:
                     self.__logError(jsonDict["error"])
-                    
                 elif "success" in jsonDict and jsonDict["success"]:
-                    if "actions" in jsonDict and \
-                            "PREFIX" in jsonDict["actions"]:
-                        prefix = jsonDict["actions"]["PREFIX"]
-                    elif "prefix" in jsonDict:
-                        prefix = jsonDict["prefix"]
-                    elif "dst_prefix" in jsonDict:
-                        prefix = jsonDict["dst_prefix"]
-                    else:
-                        prefix = ""
-                    self.__venvManager.addVirtualEnv(self.__venvName,
-                                                     prefix,
-                                                     isConda=True)
+                    self.__finishCommandMethods[self.__condaCommand](jsonDict)
+                else:
+                    self.__logError(
+                        self.tr("Conda command '{0}' did not return success.")
+                        .format(self.__condaCommand))
         elif self.__bufferedStdout:
             self.__logOutput(self.__bufferedStdout)
     
-    def __progressLabelString(self, text):
+    def __finishCreate(self, resultDict):
         """
-        Private method to process a string and format it for the progress
-        label.
+        Private method to finish the 'create' command.
         
-        @param text text to be processed
-        @type str
-        @return formatted progress label string
-        @rtype str
+        @param resultDict dictionary containing the 'create' result data
+        @type dict
         """
-        parts = text.split("|")
-        if len(parts) > 1:
-            return self.tr("{0} (Size: {1})".format(parts[0].strip(),
-                                                    parts[1].strip()))
+        if "actions" in resultDict and \
+                "PREFIX" in resultDict["actions"]:
+            prefix = resultDict["actions"]["PREFIX"]
+        elif "prefix" in resultDict:
+            prefix = resultDict["prefix"]
+        elif "dst_prefix" in resultDict:
+            prefix = resultDict["dst_prefix"]
         else:
-            return parts[0].strip()
+            prefix = ""
+        self.__venvManager.addVirtualEnv(self.__venvName,
+                                         prefix,
+                                         isConda=True)
     
     def __setProgressValues(self, jsonDict, progressType):
         """

eric ide

mercurial