def doSuccessActionCCP4i(self, _edPlugin=None):
     EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.doSuccessActionCCP4i...")
     self.retrieveSuccessMessages(self.__edPluginControlCCP4i, "EDPluginControlInterfaceToMXCuBEv1_2.doSuccessActionCCP4i")
     # Retrieve the results from the CCP4 plugin execution
     xsDataResultCCP4i = self.__edPluginControlCCP4i.getDataOutput()
     self.__xsDataResultMXCuBE = XSDataResultMXCuBE()
     xsDataStringListOfOutputFiles = xsDataResultCCP4i.getListOfOutputFiles()
     self.__xsDataResultMXCuBE.setListOfOutputFiles(xsDataStringListOfOutputFiles)
     # Retrieve the characterisation output object
     xsDataResultCharacterisation = self.getXSDataResultCharacterisation(xsDataStringListOfOutputFiles.getValue())
     # For the moment, create "DNA" style output directory
     strPathToDNAFileDirectory = self.createDNAFileDirectoryPath(xsDataResultCharacterisation)
     xsDataDictionaryLogFile = None
     if (self.createDNAFileDirectory(strPathToDNAFileDirectory)):
         xsDataDictionaryLogFile = self.createOutputFileDictionary(xsDataStringListOfOutputFiles, xsDataResultCharacterisation, strPathToDNAFileDirectory)
     strPyArchPathToDNAFileDirectory = self.createPyArchDNAFilePath(strPathToDNAFileDirectory)
     if (self.createDNAFileDirectory(strPyArchPathToDNAFileDirectory)):
         xsDataDictionaryLogFile = self.createOutputFileDictionary(xsDataStringListOfOutputFiles, xsDataResultCharacterisation, strPyArchPathToDNAFileDirectory)
     self.__xsDataResultMXCuBE.setOutputFileDictionary(xsDataDictionaryLogFile)
     # Send success email message (MXSUP-183):
     strSubject = "%s : SUCCESS!" % EDUtilsPath.getEdnaSite()
     strMessage = "Success!"
     if xsDataDictionaryLogFile != None:
         for xsDataKeyValuePair in xsDataDictionaryLogFile.getKeyValuePair():
             strKey = xsDataKeyValuePair.getKey().getValue()
             if strKey == "executiveSummary":
                 strPathToExecutiveSummary = xsDataKeyValuePair.getValue().getValue()
                 strMessage = EDUtilsFile.readFile(strPathToExecutiveSummary)
     self.sendEmail(strSubject, strMessage)
     # Fix for bug EDNA-55 : If burning strategy EDNA2html shouldn't be run
     bRunExecOutputHTML = True
     xsDataInputMXCuBE = self.getDataInput()
     xsDataDiffractionPlan = xsDataInputMXCuBE.getDiffractionPlan()
     if xsDataDiffractionPlan.getStrategyOption() is not None:
         strStrategyOption = xsDataDiffractionPlan.getStrategyOption().getValue()
         if strStrategyOption.find("-DamPar") != -1:
             bRunExecOutputHTML = False
     if (self.__edPluginExecOutputHTML is not None) and bRunExecOutputHTML:
         self.__edPluginExecOutputHTML.executeSynchronous()
         if not self.__edPluginExecOutputHTML.isFailure() and self.__edPluginExecOutputHTML.hasDataOutput("htmlFile"):
             strPathToHTMLFile = self.__edPluginExecOutputHTML.getDataOutput("htmlFile")[0].getPath().getValue()
             strPathToHTMLDir = self.__edPluginExecOutputHTML.getDataOutput("htmlDir")[0].getPath().getValue()
             strPathToDNAIndexDirectory = os.path.join(strPathToDNAFileDirectory, "index")
             if os.path.exists(strPathToHTMLFile):
                 try:
                     os.mkdir(strPathToDNAIndexDirectory)
                     shutil.copy(strPathToHTMLFile, os.path.join(strPathToDNAIndexDirectory, "index.html"))
                     shutil.copytree(strPathToHTMLDir, os.path.join(strPathToDNAIndexDirectory, os.path.basename(strPathToHTMLDir)))
                     if strPyArchPathToDNAFileDirectory is not None:
                         strPathToPyArchIndexDirectory = os.path.join(strPyArchPathToDNAFileDirectory, "index")
                         os.mkdir(strPathToPyArchIndexDirectory)
                         shutil.copy(strPathToHTMLFile, os.path.join(strPathToPyArchIndexDirectory, "index.html"))
                         shutil.copytree(strPathToHTMLDir, os.path.join(strPathToPyArchIndexDirectory, os.path.basename(strPathToHTMLDir)))
                 except Exception, e:
                     EDVerbose.DEBUG("Exception caught: %r" % e)
 def doFailureActionCCP4i(self, _edPlugin=None):
     EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.doFailureActionCCP4i...")
     self.setFailure()
     xsDataResultMXCuBE = XSDataResultMXCuBE()
     self.setDataOutput(xsDataResultMXCuBE)
     self.writeDataOutput()
     # Send failure email message (MXSUP-183):
     strSubject = "%s : FAILURE!" % EDUtilsPath.getEdnaSite()
     strMessage = "CCP4I FAILURE!"
     self.sendEmail(strSubject, strMessage)
 def doSuccessActionCCP4i(self, _edPlugin=None):
     EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.doSuccessActionCCP4i...")
     self.retrieveSuccessMessages(self.__edPluginControlCCP4i, "EDPluginControlInterfaceToMXCuBEv1_2.doSuccessActionCCP4i")
     # Retrieve the results from the CCP4 plugin execution
     xsDataResultCCP4i = self.__edPluginControlCCP4i.getDataOutput()
     self.__xsDataResultMXCuBE = XSDataResultMXCuBE()
     xsDataStringListOfOutputFiles = xsDataResultCCP4i.getListOfOutputFiles()
     self.__xsDataResultMXCuBE.setListOfOutputFiles(xsDataStringListOfOutputFiles)
     # Retrieve the characterisation output object
     xsDataResultCharacterisation = self.getXSDataResultCharacterisation(xsDataStringListOfOutputFiles.getValue())
     # For the moment, create "DNA" style output directory
     strPathToDNAFileDirectory = self.createDNAFileDirectoryPath(xsDataResultCharacterisation)
     xsDataDictionaryLogFile = None
     if (self.createDNAFileDirectory(strPathToDNAFileDirectory)):
         xsDataDictionaryLogFile = self.createOutputFileDictionary(xsDataStringListOfOutputFiles, xsDataResultCharacterisation, strPathToDNAFileDirectory)
     strPyArchPathToDNAFileDirectory = self.createPyArchDNAFilePath(strPathToDNAFileDirectory)
     if (self.createDNAFileDirectory(strPyArchPathToDNAFileDirectory)):
         xsDataDictionaryLogFile = self.createOutputFileDictionary(xsDataStringListOfOutputFiles, xsDataResultCharacterisation, strPyArchPathToDNAFileDirectory)
     self.__xsDataResultMXCuBE.setOutputFileDictionary(xsDataDictionaryLogFile)
     # Send success email message (MXSUP-183):
     strSubject = "%s : SUCCESS!" % EDUtilsPath.getEdnaSite()
     strMessage = "Success!"
     if xsDataDictionaryLogFile != None:
         for xsDataKeyValuePair in xsDataDictionaryLogFile.getKeyValuePair():
             strKey = xsDataKeyValuePair.getKey().getValue()
             if strKey == "executiveSummary":
                 strPathToExecutiveSummary = xsDataKeyValuePair.getValue().getValue()
                 strMessage = EDUtilsFile.readFile(strPathToExecutiveSummary)
     self.sendEmail(strSubject, strMessage)
     # Fix for bug EDNA-55 : If burning strategy EDNA2html shouldn't be run
     bRunExecOutputHTML = True
     xsDataInputMXCuBE = self.getDataInput()
     xsDataDiffractionPlan = xsDataInputMXCuBE.getDiffractionPlan()
     if xsDataDiffractionPlan.getStrategyOption() is not None:
         strStrategyOption = xsDataDiffractionPlan.getStrategyOption().getValue()
         if strStrategyOption.find("-DamPar") != -1:
             bRunExecOutputHTML = False
     if (self.__edPluginExecOutputHTML is not None) and bRunExecOutputHTML:
         self.__edPluginExecOutputHTML.executeSynchronous()
         if not self.__edPluginExecOutputHTML.isFailure() and self.__edPluginExecOutputHTML.hasDataOutput("htmlFile"):
             strPathToHTMLFile = self.__edPluginExecOutputHTML.getDataOutput("htmlFile")[0].getPath().getValue()
             strPathToHTMLDir = self.__edPluginExecOutputHTML.getDataOutput("htmlDir")[0].getPath().getValue()
             strPathToDNAIndexDirectory = os.path.join(strPathToDNAFileDirectory, "index")
             if os.path.exists(strPathToHTMLFile):
                 try:
                     os.mkdir(strPathToDNAIndexDirectory)
                     shutil.copy(strPathToHTMLFile, os.path.join(strPathToDNAIndexDirectory, "index.html"))
                     shutil.copytree(strPathToHTMLDir, os.path.join(strPathToDNAIndexDirectory, os.path.basename(strPathToHTMLDir)))
                     if strPyArchPathToDNAFileDirectory is not None:
                         strPathToPyArchIndexDirectory = os.path.join(strPyArchPathToDNAFileDirectory, "index")
                         os.mkdir(strPathToPyArchIndexDirectory)
                         shutil.copy(strPathToHTMLFile, os.path.join(strPathToPyArchIndexDirectory, "index.html"))
                         shutil.copytree(strPathToHTMLDir, os.path.join(strPathToPyArchIndexDirectory, os.path.basename(strPathToHTMLDir)))
                 except Exception, e:
                     EDVerbose.DEBUG("Exception caught: %r" % e)
class EDPluginControlInterfaceToMXCuBEv1_2(EDPluginControl):
    """
    This is the plugin interface to launch the MXv1 characterisation from an MXCuBE gui.
    It is for the moment a wrapper for the EDPluginControlCCP4iv1_1 plugin, which also
    runs the ISPyB control plugin if a data collection id is available.
    """

    __EDNA_CONTACT_EMAIL = "contactEmail"
    __EDNA_EMAIL_SENDER = "emailSender"

    def __init__ (self):
        """
        Initialisation of EDPluginControlInterfaceToMXCuBEv1_2:
        - Input data type class : XSDataInputMXCuBE
        - Name of default characterisation plugin : EDPluginControlCharacterisationv1_1
        """
        EDPluginControl.__init__(self)
        self.setXSDataInputClass(XSDataInputMXCuBE)
        self.__strPluginControlCCP4i = "EDPluginControlCCP4iv1_1"
        self.__edPluginControlCCP4i = None
        self.__strPluginControlISPyB = "EDPluginControlISPyBv1_0"
        self.__edPluginControlISPyB = None
        self.__xsDataResultMXCuBE = None
        self.__xsDataIntegerDataCollectionId = None
        self.__strPluginExecOutputHTMLName = "EDPluginExecOutputHTMLv1_0"
        self.__edPluginExecOutputHTML = None
        self.__strEDNAContactEmail = None
        self.__strEDNAEmailSender = "*****@*****.**"


    def checkParameters(self):
        """
        Checks the mandatory input parameters :
        - dataSet
        - outputFileDirectory
        """
        self.verboseDebug("EDPluginControlInterfaceToMXCuBEv1_2.checkParameters")
        self.checkMandatoryParameters(self.getDataInput(), "Data Input is None")
        self.checkMandatoryParameters(self.getDataInput().getDataSet(), "dataSet")
        #self.checkMandatoryParameters( self.getDataInput().getOutputFileDirectory(), "outputFileDirectory" )


    def configure(self):
        EDPluginControl.configure(self)
        EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.configure")
        xsPluginItem = self.getConfiguration()
        if xsPluginItem == None:
            EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.configure: No plugin item defined.")
        else:
            self.__strEDNAContactEmail = EDConfiguration.getStringParamValue(xsPluginItem, EDPluginControlInterfaceToMXCuBEv1_2.__EDNA_CONTACT_EMAIL)
            EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.configure: EDNAContactEmail = %s" % self.__strEDNAContactEmail)
            strEDNAEmailSender = EDConfiguration.getStringParamValue(xsPluginItem, self.__EDNA_EMAIL_SENDER)
            if strEDNAEmailSender:
                self.__strEDNAEmailSender = strEDNAEmailSender


    def preProcess(self, _edPlugin=None):
        """
        This method prepares the input for the CCP4i plugin and loads it.
        """
        EDPluginControl.preProcess(self, _edPlugin)
        EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.preProcess...")

        EDFactoryPluginStatic.loadModule("XSDataCCP4iv1_1")
        from XSDataCCP4iv1_1 import XSDataInputCCP4i
        xsDataInputCCP4i = XSDataInputCCP4i()
        xsDataInputMXCuBE = self.getDataInput()
        xsDataInputCCP4i.setDataSet(xsDataInputMXCuBE.getDataSet())
        #xsDataInputCCP4i.setDataFile( xsDataInputMXCuBE.getDataFile() )
        xsDataInputCCP4i.setExperimentalCondition(xsDataInputMXCuBE.getExperimentalCondition())
        xsDataInputCCP4i.setDiffractionPlan(xsDataInputMXCuBE.getDiffractionPlan())
        xsDataInputCCP4i.setSample(xsDataInputMXCuBE.getSample())

        self.__edPluginControlCCP4i = self.loadPlugin(self.__strPluginControlCCP4i, "CCP4i")
        self.__edPluginControlCCP4i.setDataInput(xsDataInputCCP4i)

        self.__xsDataIntegerDataCollectionId = xsDataInputMXCuBE.getDataCollectionId()
        if (self.__xsDataIntegerDataCollectionId is not None):
            self.__edPluginControlISPyB = self.loadPlugin(self.__strPluginControlISPyB, "ISPyB")

        self.__edPluginExecOutputHTML = self.loadPlugin(self.__strPluginExecOutputHTMLName, "OutputHTML")


    def process(self, _edPlugin=None):
        EDPluginControl.process(self, _edPlugin)
        EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.process...")

        if self.__edPluginControlCCP4i is not None:
            self.connectProcess(self.__edPluginControlCCP4i.executeSynchronous)
            self.__edPluginControlCCP4i.connectSUCCESS(self.doSuccessActionCCP4i)
            self.__edPluginControlCCP4i.connectFAILURE(self.doFailureActionCCP4i)
            if self.__edPluginControlISPyB is not None:
                self.__edPluginControlISPyB.connectSUCCESS(self.doSuccessActionISPyB)
                self.__edPluginControlISPyB.connectFAILURE(self.doFailureActionISPyB)


    def postProcess(self, _edPlugin=None):
        EDPluginControl.postProcess(self, _edPlugin)
        EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.postProcess...")
        self.setDataOutput(self.__xsDataResultMXCuBE)


    def doSuccessActionCCP4i(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.doSuccessActionCCP4i...")
        self.retrieveSuccessMessages(self.__edPluginControlCCP4i, "EDPluginControlInterfaceToMXCuBEv1_2.doSuccessActionCCP4i")
        # Retrieve the results from the CCP4 plugin execution
        xsDataResultCCP4i = self.__edPluginControlCCP4i.getDataOutput()
        self.__xsDataResultMXCuBE = XSDataResultMXCuBE()
        xsDataStringListOfOutputFiles = xsDataResultCCP4i.getListOfOutputFiles()
        self.__xsDataResultMXCuBE.setListOfOutputFiles(xsDataStringListOfOutputFiles)
        # Retrieve the characterisation output object
        xsDataResultCharacterisation = self.getXSDataResultCharacterisation(xsDataStringListOfOutputFiles.getValue())
        # For the moment, create "DNA" style output directory
        strPathToDNAFileDirectory = self.createDNAFileDirectoryPath(xsDataResultCharacterisation)
        xsDataDictionaryLogFile = None
        if (self.createDNAFileDirectory(strPathToDNAFileDirectory)):
            xsDataDictionaryLogFile = self.createOutputFileDictionary(xsDataStringListOfOutputFiles, xsDataResultCharacterisation, strPathToDNAFileDirectory)
        strPyArchPathToDNAFileDirectory = self.createPyArchDNAFilePath(strPathToDNAFileDirectory)
        if (self.createDNAFileDirectory(strPyArchPathToDNAFileDirectory)):
            xsDataDictionaryLogFile = self.createOutputFileDictionary(xsDataStringListOfOutputFiles, xsDataResultCharacterisation, strPyArchPathToDNAFileDirectory)
        self.__xsDataResultMXCuBE.setOutputFileDictionary(xsDataDictionaryLogFile)
        # Send success email message (MXSUP-183):
        strSubject = "%s : SUCCESS!" % EDUtilsPath.getEdnaSite()
        strMessage = "Success!"
        if xsDataDictionaryLogFile != None:
            for xsDataKeyValuePair in xsDataDictionaryLogFile.getKeyValuePair():
                strKey = xsDataKeyValuePair.getKey().getValue()
                if strKey == "executiveSummary":
                    strPathToExecutiveSummary = xsDataKeyValuePair.getValue().getValue()
                    strMessage = EDUtilsFile.readFile(strPathToExecutiveSummary)
        self.sendEmail(strSubject, strMessage)
        # Fix for bug EDNA-55 : If burning strategy EDNA2html shouldn't be run
        bRunExecOutputHTML = True
        xsDataInputMXCuBE = self.getDataInput()
        xsDataDiffractionPlan = xsDataInputMXCuBE.getDiffractionPlan()
        if xsDataDiffractionPlan.getStrategyOption() is not None:
            strStrategyOption = xsDataDiffractionPlan.getStrategyOption().getValue()
            if strStrategyOption.find("-DamPar") != -1:
                bRunExecOutputHTML = False
        if (self.__edPluginExecOutputHTML is not None) and bRunExecOutputHTML:
            self.__edPluginExecOutputHTML.executeSynchronous()
            if not self.__edPluginExecOutputHTML.isFailure() and self.__edPluginExecOutputHTML.hasDataOutput("htmlFile"):
                strPathToHTMLFile = self.__edPluginExecOutputHTML.getDataOutput("htmlFile")[0].getPath().getValue()
                strPathToHTMLDir = self.__edPluginExecOutputHTML.getDataOutput("htmlDir")[0].getPath().getValue()
                strPathToDNAIndexDirectory = os.path.join(strPathToDNAFileDirectory, "index")
                if os.path.exists(strPathToHTMLFile):
                    try:
                        os.mkdir(strPathToDNAIndexDirectory)
                        shutil.copy(strPathToHTMLFile, os.path.join(strPathToDNAIndexDirectory, "index.html"))
                        shutil.copytree(strPathToHTMLDir, os.path.join(strPathToDNAIndexDirectory, os.path.basename(strPathToHTMLDir)))
                        if strPyArchPathToDNAFileDirectory is not None:
                            strPathToPyArchIndexDirectory = os.path.join(strPyArchPathToDNAFileDirectory, "index")
                            os.mkdir(strPathToPyArchIndexDirectory)
                            shutil.copy(strPathToHTMLFile, os.path.join(strPathToPyArchIndexDirectory, "index.html"))
                            shutil.copytree(strPathToHTMLDir, os.path.join(strPathToPyArchIndexDirectory, os.path.basename(strPathToHTMLDir)))
                    except Exception, e:
                        EDVerbose.DEBUG("Exception caught: %r" % e)
        if (self.__edPluginControlISPyB is not None):
            # Execute the ISPyB control plugin
            xsDataInputControlISPyB = XSDataInputControlISPyB()
            xsDataInputControlISPyB.setCharacterisationResult(xsDataResultCharacterisation)
            xsDataInputControlISPyB.setDataCollectionId(self.__xsDataIntegerDataCollectionId)
            self.__edPluginControlISPyB.setDataInput(xsDataInputControlISPyB)
            self.__edPluginControlISPyB.executeSynchronous()
class EDPluginControlInterfaceToMXCuBEv1_2(EDPluginControl):
    """
    This is the plugin interface to launch the MXv1 characterisation from an MXCuBE gui.
    It is for the moment a wrapper for the EDPluginControlCCP4iv1_1 plugin, which also
    runs the ISPyB control plugin if a data collection id is available.
    """

    __EDNA_CONTACT_EMAIL = "contactEmail"
    __EDNA_EMAIL_SENDER = "emailSender"

    def __init__ (self):
        """
        Initialisation of EDPluginControlInterfaceToMXCuBEv1_2:
        - Input data type class : XSDataInputMXCuBE
        - Name of default characterisation plugin : EDPluginControlCharacterisationv1_1
        """
        EDPluginControl.__init__(self)
        self.setXSDataInputClass(XSDataInputMXCuBE)
        self.__strPluginControlCCP4i = "EDPluginControlCCP4iv1_1"
        self.__edPluginControlCCP4i = None
        self.__strPluginControlISPyB = "EDPluginControlISPyBv1_0"
        self.__edPluginControlISPyB = None
        self.__xsDataResultMXCuBE = None
        self.__xsDataIntegerDataCollectionId = None
        self.__strPluginExecOutputHTMLName = "EDPluginExecOutputHTMLv1_0"
        self.__edPluginExecOutputHTML = None
        self.__strEDNAContactEmail = None
        self.__strEDNAEmailSender = "*****@*****.**"


    def checkParameters(self):
        """
        Checks the mandatory input parameters :
        - dataSet
        - outputFileDirectory
        """
        self.verboseDebug("EDPluginControlInterfaceToMXCuBEv1_2.checkParameters")
        self.checkMandatoryParameters(self.getDataInput(), "Data Input is None")
        self.checkMandatoryParameters(self.getDataInput().getDataSet(), "dataSet")
        #self.checkMandatoryParameters( self.getDataInput().getOutputFileDirectory(), "outputFileDirectory" )


    def configure(self):
        EDPluginControl.configure(self)
        EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.configure")
        xsPluginItem = self.getConfiguration()
        if xsPluginItem == None:
            EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.configure: No plugin item defined.")
        else:
            self.__strEDNAContactEmail = EDConfiguration.getStringParamValue(xsPluginItem, EDPluginControlInterfaceToMXCuBEv1_2.__EDNA_CONTACT_EMAIL)
            EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.configure: EDNAContactEmail = %s" % self.__strEDNAContactEmail)
            strEDNAEmailSender = EDConfiguration.getStringParamValue(xsPluginItem, self.__EDNA_EMAIL_SENDER)
            if strEDNAEmailSender:
                self.__strEDNAEmailSender = strEDNAEmailSender


    def preProcess(self, _edPlugin=None):
        """
        This method prepares the input for the CCP4i plugin and loads it.
        """
        EDPluginControl.preProcess(self, _edPlugin)
        EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.preProcess...")

        EDFactoryPluginStatic.loadModule("XSDataCCP4iv1_1")
        from XSDataCCP4iv1_1 import XSDataInputCCP4i
        xsDataInputCCP4i = XSDataInputCCP4i()
        xsDataInputMXCuBE = self.getDataInput()
        xsDataInputCCP4i.setDataSet(xsDataInputMXCuBE.getDataSet())
        #xsDataInputCCP4i.setDataFile( xsDataInputMXCuBE.getDataFile() )
        xsDataInputCCP4i.setExperimentalCondition(xsDataInputMXCuBE.getExperimentalCondition())
        xsDataInputCCP4i.setDiffractionPlan(xsDataInputMXCuBE.getDiffractionPlan())
        xsDataInputCCP4i.setSample(xsDataInputMXCuBE.getSample())

        self.__edPluginControlCCP4i = self.loadPlugin(self.__strPluginControlCCP4i, "CCP4i")
        self.__edPluginControlCCP4i.setDataInput(xsDataInputCCP4i)

        self.__xsDataIntegerDataCollectionId = xsDataInputMXCuBE.getDataCollectionId()
        if (self.__xsDataIntegerDataCollectionId is not None):
            self.__edPluginControlISPyB = self.loadPlugin(self.__strPluginControlISPyB, "ISPyB")

        self.__edPluginExecOutputHTML = self.loadPlugin(self.__strPluginExecOutputHTMLName, "OutputHTML")


    def process(self, _edPlugin=None):
        EDPluginControl.process(self, _edPlugin)
        EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.process...")

        if self.__edPluginControlCCP4i is not None:
            self.connectProcess(self.__edPluginControlCCP4i.executeSynchronous)
            self.__edPluginControlCCP4i.connectSUCCESS(self.doSuccessActionCCP4i)
            self.__edPluginControlCCP4i.connectFAILURE(self.doFailureActionCCP4i)
            if self.__edPluginControlISPyB is not None:
                self.__edPluginControlISPyB.connectSUCCESS(self.doSuccessActionISPyB)
                self.__edPluginControlISPyB.connectFAILURE(self.doFailureActionISPyB)


    def postProcess(self, _edPlugin=None):
        EDPluginControl.postProcess(self, _edPlugin)
        EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.postProcess...")
        self.setDataOutput(self.__xsDataResultMXCuBE)


    def doSuccessActionCCP4i(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.doSuccessActionCCP4i...")
        self.retrieveSuccessMessages(self.__edPluginControlCCP4i, "EDPluginControlInterfaceToMXCuBEv1_2.doSuccessActionCCP4i")
        # Retrieve the results from the CCP4 plugin execution
        xsDataResultCCP4i = self.__edPluginControlCCP4i.getDataOutput()
        self.__xsDataResultMXCuBE = XSDataResultMXCuBE()
        xsDataStringListOfOutputFiles = xsDataResultCCP4i.getListOfOutputFiles()
        self.__xsDataResultMXCuBE.setListOfOutputFiles(xsDataStringListOfOutputFiles)
        # Retrieve the characterisation output object
        xsDataResultCharacterisation = self.getXSDataResultCharacterisation(xsDataStringListOfOutputFiles.getValue())
        # For the moment, create "DNA" style output directory
        strPathToDNAFileDirectory = self.createDNAFileDirectoryPath(xsDataResultCharacterisation)
        xsDataDictionaryLogFile = None
        if (self.createDNAFileDirectory(strPathToDNAFileDirectory)):
            xsDataDictionaryLogFile = self.createOutputFileDictionary(xsDataStringListOfOutputFiles, xsDataResultCharacterisation, strPathToDNAFileDirectory)
        strPyArchPathToDNAFileDirectory = self.createPyArchDNAFilePath(strPathToDNAFileDirectory)
        if (self.createDNAFileDirectory(strPyArchPathToDNAFileDirectory)):
            xsDataDictionaryLogFile = self.createOutputFileDictionary(xsDataStringListOfOutputFiles, xsDataResultCharacterisation, strPyArchPathToDNAFileDirectory)
        self.__xsDataResultMXCuBE.setOutputFileDictionary(xsDataDictionaryLogFile)
        # Send success email message (MXSUP-183):
        strSubject = "%s : SUCCESS!" % EDUtilsPath.getEdnaSite()
        strMessage = "Success!"
        if xsDataDictionaryLogFile != None:
            for xsDataKeyValuePair in xsDataDictionaryLogFile.getKeyValuePair():
                strKey = xsDataKeyValuePair.getKey().getValue()
                if strKey == "executiveSummary":
                    strPathToExecutiveSummary = xsDataKeyValuePair.getValue().getValue()
                    strMessage = EDUtilsFile.readFile(strPathToExecutiveSummary)
        self.sendEmail(strSubject, strMessage)
        # Fix for bug EDNA-55 : If burning strategy EDNA2html shouldn't be run
        bRunExecOutputHTML = True
        xsDataInputMXCuBE = self.getDataInput()
        xsDataDiffractionPlan = xsDataInputMXCuBE.getDiffractionPlan()
        if xsDataDiffractionPlan.getStrategyOption() is not None:
            strStrategyOption = xsDataDiffractionPlan.getStrategyOption().getValue()
            if strStrategyOption.find("-DamPar") != -1:
                bRunExecOutputHTML = False
        if (self.__edPluginExecOutputHTML is not None) and bRunExecOutputHTML:
            self.__edPluginExecOutputHTML.executeSynchronous()
            if not self.__edPluginExecOutputHTML.isFailure() and self.__edPluginExecOutputHTML.hasDataOutput("htmlFile"):
                strPathToHTMLFile = self.__edPluginExecOutputHTML.getDataOutput("htmlFile")[0].getPath().getValue()
                strPathToHTMLDir = self.__edPluginExecOutputHTML.getDataOutput("htmlDir")[0].getPath().getValue()
                strPathToDNAIndexDirectory = os.path.join(strPathToDNAFileDirectory, "index")
                if os.path.exists(strPathToHTMLFile):
                    try:
                        os.mkdir(strPathToDNAIndexDirectory)
                        shutil.copy(strPathToHTMLFile, os.path.join(strPathToDNAIndexDirectory, "index.html"))
                        shutil.copytree(strPathToHTMLDir, os.path.join(strPathToDNAIndexDirectory, os.path.basename(strPathToHTMLDir)))
                        if strPyArchPathToDNAFileDirectory is not None:
                            strPathToPyArchIndexDirectory = os.path.join(strPyArchPathToDNAFileDirectory, "index")
                            os.mkdir(strPathToPyArchIndexDirectory)
                            shutil.copy(strPathToHTMLFile, os.path.join(strPathToPyArchIndexDirectory, "index.html"))
                            shutil.copytree(strPathToHTMLDir, os.path.join(strPathToPyArchIndexDirectory, os.path.basename(strPathToHTMLDir)))
                    except Exception, e:
                        EDVerbose.DEBUG("Exception caught: %r" % e)
        if (self.__edPluginControlISPyB is not None):
            # Execute the ISPyB control plugin
            xsDataInputControlISPyB = XSDataInputControlISPyB()
            xsDataInputControlISPyB.setCharacterisationResult(xsDataResultCharacterisation)
            xsDataInputControlISPyB.setDataCollectionId(self.__xsDataIntegerDataCollectionId)
            self.__edPluginControlISPyB.setDataInput(xsDataInputControlISPyB)
            self.__edPluginControlISPyB.executeSynchronous()