def appendPath(self, _strPluginTestLocation):
        """
        For the tests, both the plugin directory and its corresponding "src" directory must
        be on the python path (see the class documentation for EDFactoryPluginTest).
        This method appends the plugin "src" directory to the system path, if it's not already present.

        @param _strModuleLocation: Path to the module location
        @type _strModuleLocation: python string
        """
        EDFactoryPlugin.appendPath(self, _strPluginTestLocation)

        strSrcDirectory = EDUtilsPath.appendListOfPaths(
            _strPluginTestLocation, ["..", "..", "..", "..", "src"])
        if os.path.exists(strSrcDirectory):
            if (not strSrcDirectory in sys.path):
                sys.path.append(strSrcDirectory)

        strSrcDirectory = EDUtilsPath.appendListOfPaths(
            _strPluginTestLocation, ["..", "..", "src"])
        if os.path.exists(strSrcDirectory):
            if (not strSrcDirectory in sys.path):
                sys.path.append(strSrcDirectory)

        strPluginDirectory = EDUtilsPath.appendListOfPaths(
            _strPluginTestLocation, ["..", "..", "plugins"])
        if os.path.exists(strPluginDirectory):
            if (not strPluginDirectory in sys.path):
                sys.path.append(strPluginDirectory)
 def finallyProcess(self, _edPlugin=None):
     EDPluginExec.finallyProcess(self, _edPlugin)
     self.DEBUG("EDPluginExecSimpleHTMLPagev1_1.finallyProcess...")
     xsDataResultSimpleHTMLPage = XSDataResultSimpleHTMLPage()
     xsDataResultSimpleHTMLPage.setPathToHTMLFile(XSDataFile(XSDataString(os.path.join(self.getWorkingDirectory(), self.strHtmlFileName))))
     xsDataResultSimpleHTMLPage.setPathToHTMLDirectory(XSDataFile(XSDataString(self.getWorkingDirectory())))
     # Write workflowStepReport HTML page
     pathToIndexFile = self.workflowStepReport.renderHtml(self.getWorkingDirectory(), nameOfIndexFile=self.strHtmlFileName)
     pathToJsonFile = self.workflowStepReport.renderJson(self.getWorkingDirectory())
     # Store in Pyarch
     if EDUtilsPath.isESRF() or EDUtilsPath.isEMBL():
         strPyarchPath = None
         if self.xsDataResultCharacterisation is not None:
             strPyarchPath = EDHandlerESRFPyarchv1_0.createPyarchHtmlDirectoryPath(self.xsDataResultCharacterisation.getDataCollection())
         if strPyarchPath is None:
             # For debugging purposes
             strPyarchPath = EDUtilsPath.getEdnaUserTempFolder()
         EDHandlerESRFPyarchv1_0.copyHTMLDir(_strPathToHTMLDir=os.path.dirname(self.strPath), _strPathToPyarchDirectory=strPyarchPath)
         xsDataResultSimpleHTMLPage.setPathToHTMLDirectory(XSDataFile(XSDataString(strPyarchPath)))
         if not os.path.exists(strPyarchPath):
             os.makedirs(strPyarchPath, 0o755)
         shutil.copy(pathToJsonFile, strPyarchPath)
         pathToJsonFile = os.path.join(strPyarchPath, os.path.basename(pathToJsonFile))
     # Write json file
     xsDataResultSimpleHTMLPage.pathToJsonFile = XSDataFile(XSDataString(pathToJsonFile))
     self.setDataOutput(xsDataResultSimpleHTMLPage)
    def preProcess(self, _edObject=None):
        """
        """
        EDPluginExecProcessScript.preProcess(self)

        self.setFileBestDat(EDUtilsPath.mergePath(self.getWorkingDirectory(), "bestfile.dat"))
        self.setFileBestPar(EDUtilsPath.mergePath(self.getWorkingDirectory(), "bestfile.par"))

        EDUtilsFile.writeFile(self.getFileBestDat(), self.getDataInput().getBestFileContentDat().getValue())
        EDUtilsFile.writeFile(self.getFileBestPar(), self.getDataInput().getBestFileContentPar().getValue())

        listBestFileContentHKL = self.getDataInput().getBestFileContentHKL()

        iterator = 0
        for bestFileContentHKL in listBestFileContentHKL:
            iterator = iterator + 1
            bestFileHKL = os.path.join(self.getWorkingDirectory(), "bestfile" + str(iterator) + ".hkl")
            self.listFileBestHKL.append(bestFileHKL)
            EDUtilsFile.writeFile(bestFileHKL, bestFileContentHKL.getValue())


        if(self.getDataInput().getComplexity() is not None):
            self.setComplexity(self.getDataInput().getComplexity().getValue())

        self.initializeCommands()
    def appendPath(self, _strPluginTestLocation):
        """
        For the tests, both the plugin directory and its corresponding "src" directory must
        be on the python path (see the class documentation for EDFactoryPluginTest).
        This method appends the plugin "src" directory to the system path, if it's not already present.

        @param _strModuleLocation: Path to the module location
        @type _strModuleLocation: python string
        """
        EDFactoryPlugin.appendPath(self, _strPluginTestLocation)

        strSrcDirectory = EDUtilsPath.appendListOfPaths(_strPluginTestLocation, [ "..", "..", "..", "..", "src" ])
        if os.path.exists(strSrcDirectory):
            if (not strSrcDirectory in sys.path):
                sys.path.append(strSrcDirectory)

        strSrcDirectory = EDUtilsPath.appendListOfPaths(_strPluginTestLocation, [ "..", "..", "src" ])
        if os.path.exists(strSrcDirectory):
            if (not strSrcDirectory in sys.path):
                sys.path.append(strSrcDirectory)

        strPluginDirectory = EDUtilsPath.appendListOfPaths(_strPluginTestLocation, [ "..", "..", "plugins" ])
        if os.path.exists(strPluginDirectory):
            if (not strPluginDirectory in sys.path):
                sys.path.append(strPluginDirectory)
    def sendEmail(self, _strSubject, _strMessage):
        """Sends an email to the EDNA contact person (if configured)."""

        self.DEBUG("EDPluginControlInterfaceToMXCuBEv1_3.sendEmail: Subject = %s" % _strSubject)
        self.DEBUG("EDPluginControlInterfaceToMXCuBEv1_3.sendEmail: Message:")
        self.DEBUG(_strMessage)
        if self.strEDNAContactEmail == None:
            self.DEBUG("EDPluginControlInterfaceToMXCuBEv1_3.sendEmail: No email address configured!")
        elif not EDUtilsPath.getEdnaSite().startswith("ESRF"):
            self.DEBUG("EDPluginControlInterfaceToMXCuBEv1_3.sendEmail: Not executed at the ESRF! EDNA_SITE=%s" % EDUtilsPath.getEdnaSite())
        else:
            try:
                self.DEBUG("Sending message to %s." % self.strEDNAContactEmail)
                self.DEBUG("Message: %s" % _strMessage)
                strMessage = """
EDNA_HOME = %s
EDNA_SITE = %s
PLUGIN_NAME = %s
working_dir = %s
%s

""" % (EDUtilsPath.getEdnaHome(), EDUtilsPath.getEdnaSite(), self.getPluginName(), self.getWorkingDirectory(), _strMessage)
                strEmailMsg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s" % (self.strEDNAEmailSender, \
                                                                                self.strEDNAContactEmail, \
                                                                                _strSubject, strMessage))
                server = smtplib.SMTP("localhost")
                server.sendmail(self.strEDNAEmailSender, self.strEDNAContactEmail, strEmailMsg)
                server.quit()
            except:
                self.ERROR("Error when sending email message!")
                self.writeErrorTrace()
    def sendEmail(self, _strSubject, _strMessage):
        """Sends an email to the EDNA contact person (if configured)."""

        EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.sendEmail: Subject = %s" % _strSubject)
        EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.sendEmail: Message:")
        EDVerbose.DEBUG(_strMessage)
        if self.__strEDNAContactEmail == None:
            EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.sendEmail: No email address configured!")
        elif not EDUtilsPath.getEdnaSite().startswith("ESRF"):
            EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.sendEmail: Not executed at the ESRF! EDNA_SITE=%s" % EDUtilsPath.getEdnaSite())
        else:
            try:
                EDVerbose.DEBUG("Sending message to %s." % self.__strEDNAContactEmail)
                EDVerbose.DEBUG("Message: %s" % _strMessage)
                strMessage = """
EDNA_HOME = %s
EDNA_SITE = %s
PLUGIN_NAME = %s
working_dir = %s
%s

""" % (EDUtilsPath.getEdnaHome(), EDUtilsPath.getEdnaSite(), self.getPluginName(), self.getWorkingDirectory(), _strMessage)
                strEmailMsg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s" % (self.__strEDNAEmailSender, \
                                                                                self.__strEDNAContactEmail, \
                                                                                _strSubject, strMessage))
                server = smtplib.SMTP("localhost")
                server.sendmail(self.__strEDNAEmailSender, self.__strEDNAContactEmail, strEmailMsg)
                server.quit()
            except:
                EDVerbose.DEBUG("Error when sending email message!")
                EDVerbose.writeErrorTrace()
Exemple #7
0
 def createApplicationWorkingDirectory(self):
     """
     Created the working directory of the application (<date>-<application name>)
     First tries to retrieve the base dir from --basedir option or related parameter from constructor
     Otherwise tries to retrieve it from EDNA_BASE_DIRECTORY environment variable
     Otherwise put the base dir as the current directory
     """
     EDVerbose.DEBUG("EDApplication.createApplicationWorkingDirectory")
     strBaseDirectory = self.getBaseDir()
     strDateTime = time.strftime("%Y%m%d-%H%M%S", time.localtime(time.time()))
     self._strFullApplicationWorkingDirectory = os.path.join(strBaseDirectory, self._strWorkingDir)
     # Check that a folder / file with the same name already exists
     if(os.path.exists(self._strFullApplicationWorkingDirectory) or \
         os.path.exists(self._strFullApplicationWorkingDirectory)):
         # It does exist so we have to modify the name of the working directory
         iIndex = 1
         bContinueFlag = True
         while (bContinueFlag):
             self._strFullApplicationWorkingDirectory = os.path.join(strBaseDirectory,
                                                                                     "%s_%d" % \
                                                                                     (strDateTime, \
                                                                                       iIndex))
             if(os.path.isdir(self._strFullApplicationWorkingDirectory) or \
                 os.path.exists(self._strFullApplicationWorkingDirectory)):
                 iIndex += 1
             else:
                 bContinueFlag = False
     # Add _nobackup suffix if run at the ESRF
     strEdnSite = EDUtilsPath.getEdnaSite()
     if EDUtilsPath.isESRF():
         self._strFullApplicationWorkingDirectory += "_nobackup"
     # Make the directory
     os.mkdir(self._strFullApplicationWorkingDirectory)
     # Change it to be the current working directory
     os.chdir(self._strFullApplicationWorkingDirectory)
Exemple #8
0
 def testGenerateXSDataInputISPyB(self):
     """
     This method is testing the generation of the XSDataInputISPyB object given a XSDataIndexingInput object.
     """
     strReferenceInputControlISPyBFile = EDUtilsPath.mergePath(
         self.strDataPath, "XSDataInputControlISPyB_reference.xml")
     strPath = os.path.join(self.strDataPath,
                            strReferenceInputControlISPyBFile)
     strXMLIndexingInput = self.readAndParseFile(strPath)
     from XSDataMXv1 import XSDataInputControlISPyB
     xsDataInputControlISPyB = XSDataInputControlISPyB.parseString(
         strXMLIndexingInput)
     from EDHandlerXSDataISPyBv1_1 import EDHandlerXSDataISPyBv1_1
     xsDataInputISPyB = EDHandlerXSDataISPyBv1_1.generateXSDataInputISPyB(
         xsDataInputControlISPyB)
     strReferenceInputISPyBFile = EDUtilsPath.mergePath(
         self.strDataPath, "XSDataInputISPyB_reference.xml")
     strReferencePath = os.path.join(self.strDataPath,
                                     strReferenceInputISPyBFile)
     strXMLInputISPyBReference = self.readAndParseFile(strReferencePath)
     EDFactoryPluginStatic.loadModule("XSDataISPyBv1_1")
     from XSDataISPyBv1_1 import XSDataInputISPyB
     xsDataInputISPyBReference = XSDataInputISPyB.parseString(
         strXMLInputISPyBReference)
     # Remove the time strings since they otherwise make the test fail
     xsDataInputISPyBReference.getScreening().setTimeStamp(None)
     xsDataInputISPyB.getScreening().setTimeStamp(None)
     EDAssert.equal(xsDataInputISPyBReference.marshal(),
                    xsDataInputISPyB.marshal())
 def testCopyHTMLFilesAndDir(self):
     if not os.path.exists(EDUtilsPath.getEdnaUserTempFolder()):
         os.mkdir(EDUtilsPath.getEdnaUserTempFolder())
     strTestFromDir = os.path.join(EDUtilsPath.getEdnaUserTempFolder(), "TestFromDir")
     shutil.rmtree(strTestFromDir, ignore_errors=True)
     os.mkdir(strTestFromDir)
     strTestHtmlFilePath = os.path.join(strTestFromDir, "index.html")
     strTestHtmlDirPath = os.path.join(strTestFromDir, "index")
     EDUtilsFile.writeFile(strTestHtmlFilePath, "Test content")
     if not os.path.exists(strTestHtmlDirPath):
         os.mkdir(strTestHtmlDirPath)
     strTestHtmlDirFilePath = os.path.join(strTestHtmlDirPath, "test.txt")
     EDUtilsFile.writeFile(strTestHtmlDirFilePath, "Test content")
     #
     strTestToDir = os.path.join(EDUtilsPath.getEdnaUserTempFolder(), "TestToDir")
     shutil.rmtree(strTestToDir, ignore_errors=True)
     os.mkdir(strTestToDir)
     EDHandlerESRFPyarchv1_0.copyHTMLDir(strTestFromDir, strTestToDir)
     #
     # Check that files exist in strTestToDir:
     EDAssert.isFile(os.path.join(strTestToDir, "index", "index.html"))
     EDAssert.isFile(os.path.join(strTestToDir, "index", "index", "test.txt"))
     #
     shutil.rmtree(strTestFromDir, ignore_errors=True)
     shutil.rmtree(strTestToDir, ignore_errors=True)
 def testCopyHTMLFilesAndDir(self):
     if not os.path.exists(EDUtilsPath.getEdnaUserTempFolder()):
         os.mkdir(EDUtilsPath.getEdnaUserTempFolder())
     strTestFromDir = os.path.join(EDUtilsPath.getEdnaUserTempFolder(),
                                   "TestFromDir")
     shutil.rmtree(strTestFromDir, ignore_errors=True)
     os.mkdir(strTestFromDir)
     strTestHtmlFilePath = os.path.join(strTestFromDir, "index.html")
     strTestHtmlDirPath = os.path.join(strTestFromDir, "index")
     EDUtilsFile.writeFile(strTestHtmlFilePath, "Test content")
     if not os.path.exists(strTestHtmlDirPath):
         os.mkdir(strTestHtmlDirPath)
     strTestHtmlDirFilePath = os.path.join(strTestHtmlDirPath, "test.txt")
     EDUtilsFile.writeFile(strTestHtmlDirFilePath, "Test content")
     #
     strTestToDir = os.path.join(EDUtilsPath.getEdnaUserTempFolder(),
                                 "TestToDir")
     shutil.rmtree(strTestToDir, ignore_errors=True)
     os.mkdir(strTestToDir)
     EDHandlerESRFPyarchv1_0.copyHTMLDir(strTestFromDir, strTestToDir)
     #
     # Check that files exist in strTestToDir:
     EDAssert.isFile(os.path.join(strTestToDir, "index", "index.html"))
     EDAssert.isFile(
         os.path.join(strTestToDir, "index", "index", "test.txt"))
     #
     shutil.rmtree(strTestFromDir, ignore_errors=True)
     shutil.rmtree(strTestToDir, ignore_errors=True)
    def __init__(self, _edStringTestName=None):

        EDTestCasePluginExecute.__init__(
            self, 'EDPluginControlDIMPLEPrepareMTZFileForRefinementv10',
            'EDPluginControlDIMPLEPrepareMTZFileForRefinement-v1.0',
            _edStringTestName)

        self.setConfigurationFile(
            EDUtilsPath.mergePath(
                self.getPluginTestsDataHome(),
                'XSConfiguration_DIMPLEPrepareMTZFileForRefinement.xml'))

        self.setDataInputFile(
            EDUtilsPath.mergePath(
                self.getPluginTestsDataHome(),
                'XSDataInputDIMPLEPrepareMTZFileForRefinement_reference.xml'))

        self.setReferenceDataOutputFile(
            EDUtilsPath.mergePath(
                self.getPluginTestsDataHome(),
                'XSDataResultDIMPLEPrepareMTZFileForRefinement_reference.xml'))

        self.m_edObtainedOutputDataFile = self.getPluginName() + '_output.xml'

        self.m_iNoErrorMessages = 0
        self.m_iNoWarningMessages = 0
 def __init__(self, _pyStrTestName=None):
     EDTestCase.__init__(self, _pyStrTestName)
     strKernelDataHome = EDUtilsTest.getPluginTestDataDirectory(self.getClassName())
     strDataDir = "EDHandlerRaddosev10"
     self.strDataPath = EDUtilsPath.mergePath(strKernelDataHome, strDataDir)
     self.strReferenceInputFile2 = EDUtilsPath.mergePath(self.strDataPath, "XSDataRaddosev10Input_reference_02.xml")
     self.strObtainedInputFile2 = "XSDataInputRaddosev10FromObject_02.xml"
Exemple #13
0
 def __init__(self, _strTestName=None):
     EDTestCase.__init__(self, "EDTestCaseEDConfiguration")
     strKernelDataHome = EDUtilsTest.getPluginTestDataDirectory(
         self.getClassName())
     strDataDir = "EDConfiguration"
     self.strDataPath = EDUtilsPath.mergePath(strKernelDataHome, strDataDir)
     self.strEdnaSiteOrig = EDUtilsPath.getEdnaSite()
 def preparePythonWrapperScript(self):
     listScript = ["#!%s" % sys.executable, ""]
     listScript += ["import os, sys, xmlrpclib"]
     listScript += [
         """pyXmlrcplibProxy = xmlrpclib.ServerProxy('http://%s:%d')"""
         % (self.__edServerXMLRCP.getHost(), self.__edServerXMLRCP.getPort())
     ]
     listScript += ["""os.chdir("%s")""" % self.getWorkingDirectory()]
     listScript += ["""os.environ['EDNA_HOME']="%s" """ % EDUtilsPath.getEdnaHome()]
     listScript += ["""os.environ['EDNA_SITE']="%s" """ % EDUtilsPath.getEdnaSite()]
     listScript += ["""sys.path.append(os.path.join(os.environ["EDNA_HOME"], "kernel", "src"))"""]
     listScript += ["""from EDFactoryPluginStatic import EDFactoryPluginStatic"""]
     listScript += ["""from EDUtilsFile import EDUtilsFile"""]
     listScript += ["""edPlugin = EDFactoryPluginStatic.loadPlugin("%s")""" % self.__strNameOfPlugin]
     for strValue in self.__dictXMLDataInput:
         if strValue == self.getDefaultInputDataKey():
             listScript += ['edPlugin.setDataInput("""%s""")' "" % self.__dictXMLDataInput[strValue]]
         else:
             listScript += ['edPlugin.setDataInput("""%s""", "%s")' % (self.__dictXMLDataInput[strValue], strValue)]
     listScript += ["""def actionSuccessFile(_edPlugin=None):"""]
     listScript += ["""    strSuccessMessage = "" """]
     listScript += ["""    for strKey in _edPlugin.getListOfDataOutputKeys():"""]
     listScript += ["""        if strKey == _edPlugin.getDefaultOutputDataKey():"""]
     listScript += ["""            strXMLOutput = _edPlugin.getDataOutput().marshal()"""]
     listScript += ["""            strSuccessMessage += strKey + "\\n" """]
     listScript += [
         """            EDUtilsFile.writeFile(os.path.join("%s", "XSDataResult_"+strKey+".xml"), strXMLOutput)"""
         % self.getWorkingDirectory()
     ]
     listScript += ["""        else:"""]
     listScript += ["""            iIndex = 1"""]
     listScript += ["""            for xsDataResult in _edPlugin.getDataOutput(strKey):"""]
     listScript += ["""                strXMLOutput = xsDataResult.marshal()"""]
     listScript += ["""                strSuccessMessage += "%s_%d\\n" % (strKey, iIndex) """]
     listScript += [
         """                EDUtilsFile.writeFile(os.path.join("%s", "XSDataResult_"+strKey+"_%%d.xml") %% iIndex, strXMLOutput)"""
         % self.getWorkingDirectory()
     ]
     listScript += ["""                 """]
     listScript += [
         """    EDUtilsFile.writeFile(os.path.join("%s", "SUCCESS.txt"), strSuccessMessage)"""
         % self.getWorkingDirectory()
     ]
     listScript += ["""def actionSuccessXMLRCP(_edPlugin=None):"""]
     listScript += ["""    pyXmlrcplibProxy.callbackSUCCESS("%d", [])""" % self.getId()]
     listScript += ["""    for strKey in _edPlugin.getListOfDataOutputKeys():"""]
     listScript += ["""        strXMLOutput = _edPlugin.getDataOutput().marshal()"""]
     listScript += ["""        pyXmlrcplibProxy.setDataOutput("%d", strXMLOutput)""" % self.getId()]
     listScript += ["""def actionFailure(_edObject=None):"""]
     listScript += ["""    pyXmlrcplibProxy.callbackFAILURE("%d", [])""" % self.getId()]
     listScript += ["""#edPlugin.connectSUCCESS(actionSuccessFile)"""]
     listScript += ["""edPlugin.connectSUCCESS(actionSuccessXMLRCP)"""]
     listScript += ["""edPlugin.connectFAILURE(actionFailure)"""]
     listScript += ["""edPlugin.executeSynchronous()"""]
     listScript += [""]
     listScript += [""]
     strPythonWrapper = ""
     for strLine in listScript:
         strPythonWrapper = strPythonWrapper + strLine + "\n"
     return strPythonWrapper
Exemple #15
0
 def finallyProcess(self, _edPlugin=None):
     EDPluginExec.finallyProcess(self, _edPlugin)
     self.DEBUG("EDPluginExecSimpleHTMLPagev1_1.finallyProcess...")
     xsDataResultSimpleHTMLPage = XSDataResultSimpleHTMLPage()
     xsDataResultSimpleHTMLPage.setPathToHTMLFile(XSDataFile(XSDataString(os.path.join(self.getWorkingDirectory(), self.strHtmlFileName))))
     xsDataResultSimpleHTMLPage.setPathToHTMLDirectory(XSDataFile(XSDataString(self.getWorkingDirectory())))
     # Write workflowStepReport HTML page
     pathToIndexFile = self.workflowStepReport.renderHtml(self.getWorkingDirectory(), nameOfIndexFile=self.strHtmlFileName)
     pathToJsonFile = self.workflowStepReport.renderJson(self.getWorkingDirectory())
     # Store in Pyarch
     if EDUtilsPath.isESRF() or EDUtilsPath.isEMBL() or EDUtilsPath.isMAXIV() or EDUtilsPath.isALBA:
         strPyarchPath = None
         if self.xsDataResultCharacterisation is not None:
             strPyarchPath = EDHandlerESRFPyarchv1_0.createPyarchHtmlDirectoryPath(self.xsDataResultCharacterisation.getDataCollection())
         if strPyarchPath is None:
             # For debugging purposes
             strPyarchPath = EDUtilsPath.getEdnaUserTempFolder()
         EDHandlerESRFPyarchv1_0.copyHTMLDir(_strPathToHTMLDir=os.path.dirname(self.strPath), _strPathToPyarchDirectory=strPyarchPath)
         xsDataResultSimpleHTMLPage.setPathToHTMLDirectory(XSDataFile(XSDataString(strPyarchPath)))
         if not os.path.exists(strPyarchPath):
             os.makedirs(strPyarchPath, 0o755)
         shutil.copy(pathToJsonFile, strPyarchPath)
         pathToJsonFile = os.path.join(strPyarchPath, os.path.basename(pathToJsonFile))
     # Write json file
     xsDataResultSimpleHTMLPage.pathToJsonFile = XSDataFile(XSDataString(pathToJsonFile))
     self.setDataOutput(xsDataResultSimpleHTMLPage)
    def postProcess(self, _edObject=None):
        """
        postProcess of the plugin EDPluginSPDCorrectv10.py:
        - convert to HDF if needed (to be implemented)
        - move images (if needed)
        - set result XML   
        """
        EDPluginExecProcess.postProcess(self)
        self.DEBUG("EDPluginSPDCorrectv10.postProcess")
        EDUtilsPath.createFolder(self.dictGeometry["OutputDir"])

        if self.getClassName() == "EDPluginSPDCorrectv10":

            strInputImagePathNoSfx = os.path.splitext(os.path.basename(self.pathToInputFile))[0]
            destFileBaseName = strInputImagePathNoSfx + self.dictGeometry["OutputFileType"]
            strOutputFilePath = os.path.join(self.dictGeometry["OutputDir"], destFileBaseName)
            if not self._bFireAndForget:
                if "corrected" in self.dictRes:
                    strTempFilePath = self.dictRes["corrected"]
                else:
                    strTempFilePath = os.path.join(self.getWorkingDirectory(), destFileBaseName)
                if self.dictGeometry["OutputFileType"].lower() in [".hdf5", ".nexus", ".h5", ".nx"]:
                    self.WARNING("HDF5/Nexus output is not yet implemented in the SPD plugin.")
                if os.path.exists(strOutputFilePath):
                    self.WARNING("Destination file exists, I will leave result file in %s." % strTempFilePath)
                    strOutputFilePath = strTempFilePath
                else:
                    shutil.move(strTempFilePath, strOutputFilePath)
            #        # Create the output data
            xsDataFile = XSDataFile()
            xsDataFile.setPath(XSDataString(strOutputFilePath))

            xsDataResultSPD = XSDataResultSPD()
            xsDataResultSPD.setCorrectedFile(xsDataFile)
            self.setDataOutput(xsDataResultSPD)
    def __init__(self, _oalStringTestName=None):
        """
        """
        EDTestCasePluginExecuteBestv1_2.__init__(self, "EDPluginBestv1_2")

        self.setConfigurationFile(self.getRefConfigFile())
        self.setDataInputFile(EDUtilsPath.mergePath(self.getPluginTestsDataHome(), "XSDataInputBest_withDamPar.xml"))
        self.setReferenceDataOutputFile(EDUtilsPath.mergePath(self.getPluginTestsDataHome(), "XSDataResultBest_withDamPar.xml"))
 def testGetProjectRootDirectory(self):
     edFactoryPluginTest = EDFactoryPluginTest()
     strEdnaHome = EDUtilsPath.getEdnaHome()
     strTestProjectRootDirectoryReference = EDUtilsPath.appendListOfPaths(strEdnaHome, [ "edna-kernel", "tests", "data", "EDFactoryPlugin", "testProject" ])
     strTestProjectRootDirectory1 = edFactoryPluginTest.getProjectRootDirectory("EDTestCasePluginUnitTestPluginFactory")
     EDAssert.equal(strTestProjectRootDirectoryReference, strTestProjectRootDirectory1)
     strTestProjectRootDirectory2 = edFactoryPluginTest.getProjectRootDirectory("EDTestSuitePluginUnitTestProject")
     EDAssert.equal(strTestProjectRootDirectoryReference, strTestProjectRootDirectory2)
    def testSetDataModelInput(self):
        edPluginBest = self.createPlugin()
        xsPluginItemGood01 = self.getPluginConfiguration(EDUtilsPath.mergePath(self.m_pyStrDataPath, "XSConfiguration.xml"))
        edPluginBest.setConfiguration(xsPluginItemGood01)
        edPluginBest.setScriptExecutable("cat")
        edPluginBest.configure()

        from XSDataBestv1_2 import XSDataInputBest
        xsDataInputBest = XSDataInputBest()

        from XSDataCommon import XSDataAbsorbedDoseRate
        from XSDataCommon import XSDataDouble
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataTime
        from XSDataCommon import XSDataFile
        from XSDataCommon import XSDataSpeed
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataAngle
        from XSDataCommon import XSDataBoolean

        xsDataInputBest.setCrystalAbsorbedDoseRate(XSDataAbsorbedDoseRate(0.22E+06))
        xsDataInputBest.setCrystalShape(XSDataDouble(1))
        xsDataInputBest.setCrystalSusceptibility(XSDataDouble(1.5))
        xsDataInputBest.setDetectorType(XSDataString("q210-2x"))
        xsDataInputBest.setBeamExposureTime(XSDataTime(1))
        xsDataInputBest.setBeamMaxExposureTime(XSDataTime(10000))
        xsDataInputBest.setBeamMinExposureTime(XSDataTime(0.1))
        xsDataInputBest.setGoniostatMinRotationWidth(XSDataAngle(0.1))
        xsDataInputBest.setGoniostatMaxRotationSpeed(XSDataSpeed(10))
        xsDataInputBest.setAimedResolution(XSDataDouble(2))
        xsDataInputBest.setAimedRedundancy(XSDataDouble(6.5))
        xsDataInputBest.setAimedCompleteness(XSDataDouble(0.9))
        xsDataInputBest.setAimedIOverSigma(XSDataDouble(3))
        xsDataInputBest.setComplexity(XSDataString("min"))
        xsDataInputBest.setAnomalousData(XSDataBoolean(False))
        fileDirectory = edPluginBest.getWorkingDirectory()

        bestFileContentDat = EDUtilsFile.readFile(EDUtilsPath.mergePath(self.m_pyStrDataPath, "bestfile.dat"))
        xsDataInputBest.setBestFileContentDat(XSDataString(bestFileContentDat))

        bestFileContentPar = EDUtilsFile.readFile(EDUtilsPath.mergePath(self.m_pyStrDataPath, "bestfile.par"))
        xsDataInputBest.setBestFileContentPar(XSDataString(bestFileContentPar))

        bestFileContentHKL = EDUtilsFile.readFile(EDUtilsPath.mergePath(self.m_pyStrDataPath, "bestfile1.hkl"))
        xsDataInputBest.addBestFileContentHKL(XSDataString(bestFileContentHKL))

        xsDataInputBest.outputFile(self.m_edObtainedInputFile)

        pyStrExpectedInput = self.readAndParseFile (self.m_edReferenceInputFile)
        pyStrObtainedInput = self.readAndParseFile (self.m_edObtainedInputFile)

        xsDataInputExpected = XSDataInputBest.parseString(pyStrExpectedInput)
        xsDataInputObtained = XSDataInputBest.parseString(pyStrObtainedInput)

        EDAssert.equal(xsDataInputExpected.marshal(), xsDataInputObtained.marshal())
        EDUtilsFile.deleteFile(self.m_edObtainedInputFile)

        self.cleanUp(edPluginBest)
    def __init__(self, _pyStrTestName=None):
        EDTestCasePluginUnit.__init__(self, "EDPluginBestv1_2")
        self.m_pyStrDataPath = self.getPluginTestsDataHome()

        self.m_edObtainedInputFile = "XSDataInputBest_test.xml"
        self.m_edReferenceInputFile = EDUtilsPath.mergePath(self.m_pyStrDataPath, "XSDataInputBest_reference.xml")
        self.m_edReferenceResultFile = EDUtilsPath.mergePath(self.m_pyStrDataPath, "XSDataResultBest_reference.xml")

        self.m_edReferenceScriptLogFileName = EDUtilsPath.mergePath(self.m_pyStrDataPath, "EDPluginBestv1_2.log")
 def __init__(self, _pyStrTestName=None):
     EDTestCase.__init__(self, _pyStrTestName)
     strKernelDataHome = EDUtilsTest.getPluginTestDataDirectory(
         self.getClassName())
     strDataDir = "EDHandlerRaddosev10"
     self.strDataPath = EDUtilsPath.mergePath(strKernelDataHome, strDataDir)
     self.strReferenceInputFile2 = EDUtilsPath.mergePath(
         self.strDataPath, "XSDataRaddosev10Input_reference_02.xml")
     self.strObtainedInputFile2 = "XSDataInputRaddosev10FromObject_02.xml"
 def testStaticEDConfiguration(self):
     # This test make sure that changing an instatiation of EDConfiguration does not change the
     # corresponding plugin configuration for EDConfigurationStatic
     strPathToTestConfigFile = os.path.join(self.strDataPath, "XSConfiguration_testNonStatic.xml")
     edConfiguration = EDConfiguration(strPathToTestConfigFile)
     strParam1 = edConfiguration.getStringValue("EDPluginTestPluginFactory", "testItemName")
     EDUtilsPath.setEdnaSite("TestStaticConfiguration") 
     strParam2 = EDConfigurationStatic.getStringValue("EDPluginTestPluginFactory", "testItemName")
     EDAssert.equal(False, strParam1 == strParam2, "Static config is not equal to local config")
    def __init__(self, _oalStringTestName=None):
        EDTestCasePluginExecuteBestv1_2.__init__(self, "EDPluginBestv1_2")

        self.setConfigurationFile(self.getRefConfigFile())
        self.setDataInputFile(EDUtilsPath.mergePath(self.getPluginTestsDataHome(), "XSDataInputBest_withMinTransmissionInput.xml"))
        if (self.m_bRunOnIntel):
            self.setReferenceDataOutputFile(EDUtilsPath.mergePath(self.getPluginTestsDataHome(), "XSDataResultBest_withTransmissionInputForIntel.xml"))
        else:
            self.setReferenceDataOutputFile(EDUtilsPath.mergePath(self.getPluginTestsDataHome(), "XSDataResultBest_withTransmissionInput.xml"))
 def testGetProjectRootDirectory(self):
     edFactoryPlugin = EDFactoryPlugin()
     strEdnaHome = EDUtilsPath.getEdnaHome()
     strTestProjectRootDirectoryReference = EDUtilsPath.appendListOfPaths(strEdnaHome, [ "kernel", "tests", "data", "EDFactoryPlugin", "testProject" ])
     strTestProjectRootDirectory1 = edFactoryPlugin.getProjectRootDirectory("EDPluginTestPluginFactory")
     EDAssert.equal(strTestProjectRootDirectoryReference, strTestProjectRootDirectory1)
     strTestProjectRootDirectory2 = edFactoryPlugin.getProjectRootDirectory("XSDataTestProject")
     EDAssert.equal(strTestProjectRootDirectoryReference, strTestProjectRootDirectory2)
     strTestProjectRootDirectory3 = edFactoryPlugin.getProjectRootDirectory("PluginThatNotExists")
     EDAssert.equal(None, strTestProjectRootDirectory3)
 def testGetPathToProjectConfigurationFile(self):
     edConfiguration = EDConfiguration()
     strPathToConfigurationFile1 = edConfiguration.getPathToProjectConfigurationFile("EDPluginTestPluginFactory")
     strPathToConfigurationFileReference1 = EDUtilsPath.appendListOfPaths(EDUtilsPath.getEdnaHome(),
                                                                               [ "kernel", "tests", "data", "EDFactoryPlugin", \
                                                                                "testProject", "conf", "XSConfiguration_TestSite.xml" ])
     EDAssert.equal(strPathToConfigurationFileReference1, strPathToConfigurationFile1)
     EDUtilsPath.setEdnaSite("NonexistingTestSite")
     strPathToConfigurationFile2 = edConfiguration.getPathToProjectConfigurationFile("EDPluginTestPluginFactory")
     strPathToConfigurationFileReference2 = None
     EDAssert.equal(strPathToConfigurationFileReference2, strPathToConfigurationFile2)
Exemple #26
0
 def __initModuleDictionary(self):
     """
     This private method initialises the dictionary with all plugins. If the path to
     the dictionary cache file exists the plugins are loaded, otherwise
     the plugin root directories are searched and the dictionary is
     written to the cache file.
     """
     if (os.path.exists(EDUtilsPath.getEdnaPluginCachePath())):
         self.loadModuleDictionaryFromDisk(EDUtilsPath.getEdnaPluginCachePath())
     else:
         self.__searchRootDirectories()
         self.saveModuleDictionaryToDisk(EDUtilsPath.getEdnaPluginCachePath())
Exemple #27
0
 def __initModuleDictionary(self):
     """
     This private method initialises the dictionary with all plugins. If the path to
     the dictionary cache file exists the plugins are loaded, otherwise
     the plugin root directories are searched and the dictionary is
     written to the cache file.
     """
     if (os.path.exists(EDUtilsPath.getEdnaPluginCachePath())):
         self.loadModuleDictionaryFromDisk(EDUtilsPath.getEdnaPluginCachePath())
     else:
         self.__searchRootDirectories()
         self.saveModuleDictionaryToDisk(EDUtilsPath.getEdnaPluginCachePath())
 def testGenerateXSDataInputISPyB(self):
     """
     This method is testing the generation of the XSDataInputISPyB object given a XSDataIndexingInput object.
     """
     strReferenceInputControlISPyBFile = EDUtilsPath.mergePath(self.strDataPath, "XSDataInputControlISPyB_reference.xml")
     strPath = os.path.join(self.strDataPath, strReferenceInputControlISPyBFile)
     strXMLIndexingInput = EDUtilsFile.readFileAndParseVariables(strPath, self.dictReplace)
     xsDataInputControlISPyB = XSDataInputControlISPyB.parseString(strXMLIndexingInput)
     xsDataInputISPyB = EDHandlerXSDataISPyBv1_4.generateXSDataInputISPyBStoreScreening(xsDataInputControlISPyB)
     strReferenceInputISPyBFile = EDUtilsPath.mergePath(self.strDataPath, "XSDataInputISPyB_reference.xml")
     strReferencePath = os.path.join(self.strDataPath, strReferenceInputISPyBFile)
     strXMLInputISPyBReference = EDUtilsFile.readFileAndParseVariables(strReferencePath, self.dictReplace)
     EDFactoryPluginStatic.loadModule("XSDataISPyBv1_4")
Exemple #29
0
 def testStaticEDConfiguration(self):
     # This test make sure that changing an instatiation of EDConfiguration does not change the
     # corresponding plugin configuration for EDConfigurationStatic
     strPathToTestConfigFile = os.path.join(
         self.strDataPath, "XSConfiguration_testNonStatic.xml")
     edConfiguration = EDConfiguration(strPathToTestConfigFile)
     strParam1 = edConfiguration.getStringValue("EDPluginTestPluginFactory",
                                                "testItemName")
     EDUtilsPath.setEdnaSite("TestStaticConfiguration")
     strParam2 = EDConfigurationStatic.getStringValue(
         "EDPluginTestPluginFactory", "testItemName")
     EDAssert.equal(False, strParam1 == strParam2,
                    "Static config is not equal to local config")
Exemple #30
0
 def testGetProjectRootDirectory(self):
     edFactoryPluginTest = EDFactoryPluginTest()
     strEdnaHome = EDUtilsPath.getEdnaHome()
     strTestProjectRootDirectoryReference = EDUtilsPath.appendListOfPaths(
         strEdnaHome,
         ["kernel", "tests", "data", "EDFactoryPlugin", "testProject"])
     strTestProjectRootDirectory1 = edFactoryPluginTest.getProjectRootDirectory(
         "EDTestCasePluginUnitTestPluginFactory")
     EDAssert.equal(strTestProjectRootDirectoryReference,
                    strTestProjectRootDirectory1)
     strTestProjectRootDirectory2 = edFactoryPluginTest.getProjectRootDirectory(
         "EDTestSuitePluginUnitTestProject")
     EDAssert.equal(strTestProjectRootDirectoryReference,
                    strTestProjectRootDirectory2)
Exemple #31
0
    def getModuleLocation(self, _strModuleName):
        """
        This method returns the location of a module, e.g. XSDataCommon.

        @param _strModuleName: Name of the module
        @type _strModuleName: python string

        @return: Path to the module location
        @type: python string
        """
        strModuleLocation = None
        if (self.__dictModuleLocation is None):
            with self.locked():
                if self.__dictModuleLocation is None:
                    self.__initModuleDictionary()
        if (_strModuleName in self.__dictModuleLocation):
            strModuleLocation = self.__dictModuleLocation[_strModuleName]
            strDirectoryIgnored = self.checkDirectoriesForIgnoreFile(
                strModuleLocation)
            if strDirectoryIgnored:
                self.warning(
                    "Module location %s ignored because directory %s contains %s"
                    %
                    (strModuleLocation, strDirectoryIgnored, self.IGNORE_FILE))
                self.__searchRootDirectories()
                self.saveModuleDictionaryToDisk(
                    EDUtilsPath.getEdnaPluginCachePath())
                strModuleLocation = None
        else:
            with self.locked():
                # The module was not found - force reloading of all plugins
                self.warning(
                    "Module %s not found, forcing reloading of all modules..."
                    % _strModuleName)
                self.__searchRootDirectories()
                # Save the new dictionary in any case - even if the plugin might not be found.
                self.saveModuleDictionaryToDisk(
                    EDUtilsPath.getEdnaPluginCachePath())
                if (_strModuleName in self.__dictModuleLocation.keys()):
                    strModuleLocation = self.__dictModuleLocation[
                        _strModuleName]
                    # Fix for bug #395 - update the saved cache
                    self.DEBUG(
                        "EDFactoryPlugin.loadModule: Updating the module cache file %s"
                        % EDUtilsPath.getEdnaPluginCachePath())
                else:
                    self.DEBUG(
                        "EDFactoryPlugin.loadModule: module %s not found after forced reload of all modules."
                        % _strModuleName)
        return strModuleLocation
Exemple #32
0
 def sendEmail(self, _strSubject, _strMessage):
     """Sends an email to the EDNA contact person (if configured)."""
     strTime = "%.1f s" % (self.tStop - self.tStart)
     if EDUtilsPath.isESRF():
         strPathImage = None
         for dataSet in self.dataInput.dataSet:
             for imageFile in dataSet.imageFile:
                 strPathImage = imageFile.path.value
                 break
         if strPathImage is not None:
             (strBeamline, strProposal, strPrefix) = self.getBeamlineProposalFromPath(strPathImage)
         else:
             strBeamline = "Unknown"
             strProposal = "Unknown"
             strPrefix = "Unknown"
         strHost = socket.gethostname()
         strSubject = "EDNA ch %s %s %s %s %s (%s)" % (_strSubject, strBeamline, strProposal, strPrefix, strHost, strTime)
     else:
         strSubject = "EDNA %s : %s (%s)" % (_strSubject, EDUtilsPath.getEdnaSite(), strTime)
     self.DEBUG("EDPluginControlInterfaceToMXCuBEv1_3.sendEmail: Subject = %s" % strSubject)
     self.DEBUG("EDPluginControlInterfaceToMXCuBEv1_3.sendEmail: Message:")
     self.DEBUG(_strMessage)
     if self.strEDNAContactEmail == None:
         self.DEBUG("EDPluginControlInterfaceToMXCuBEv1_3.sendEmail: No email address configured!")
     elif not EDUtilsPath.getEdnaSite().startswith("ESRF"):
         self.DEBUG("EDPluginControlInterfaceToMXCuBEv1_3.sendEmail: Not executed at the ESRF! EDNA_SITE=%s" % EDUtilsPath.getEdnaSite())
     else:
         try:
             self.DEBUG("Sending message to %s." % self.strEDNAContactEmail)
             self.DEBUG("Message: %s" % _strMessage)
             strMessage = "EDNA_HOME = %s\n" % EDUtilsPath.getEdnaHome()
             strMessage += "EDNA_SITE = %s\n" % EDUtilsPath.getEdnaSite()
             strMessage += "PLUGIN_NAME = %s\n" % self.getPluginName()
             strMessage += "working_dir = %s\n\n" % self.getWorkingDirectory()
             strMessage += "Reference images:\n"
             xsDataInputMXCuBE = self.getDataInput()
             for xsDataSetMXCuBE in xsDataInputMXCuBE.getDataSet():
                 for xsDataFile in xsDataSetMXCuBE.getImageFile():
                     strMessage += "%s\n" % xsDataFile.getPath().getValue()
             strMessage += "\n"
             strMessage += _strMessage
             strEmailMsg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s" % (self.strEDNAEmailSender, \
                                                                             self.strEDNAContactEmail, \
                                                                             strSubject, strMessage))
             server = smtplib.SMTP("localhost")
             server.sendmail(self.strEDNAEmailSender, self.strEDNAContactEmail, strEmailMsg)
             server.quit()
         except:
             self.ERROR("Error when sending email message!")
             self.writeErrorTrace()
Exemple #33
0
 def testGenerateXSDataInputISPyB(self):
     """
     This method is testing the generation of the XSDataInputISPyB object given a XSDataIndexingInput object.
     """
     strReferenceInputControlISPyBFile = EDUtilsPath.mergePath(self.strDataPath, "XSDataInputControlISPyB_reference.xml")
     strPath = os.path.join(self.strDataPath, strReferenceInputControlISPyBFile)
     strXMLIndexingInput = EDUtilsFile.readFileAndParseVariables(strPath, self.dictReplace)
     xsDataInputControlISPyB = XSDataInputControlISPyB.parseString(strXMLIndexingInput)
     xsDataInputISPyB = EDHandlerXSDataISPyBv1_3.generateXSDataInputISPyBStoreScreening(xsDataInputControlISPyB)
     print xsDataInputISPyB.marshal()
     strReferenceInputISPyBFile = EDUtilsPath.mergePath(self.strDataPath, "XSDataInputISPyB_reference.xml")
     strReferencePath = os.path.join(self.strDataPath, strReferenceInputISPyBFile)
     strXMLInputISPyBReference = EDUtilsFile.readFileAndParseVariables(strReferencePath, self.dictReplace)
     EDFactoryPluginStatic.loadModule("XSDataISPyBv1_3")
 def sendEmail(self, _strSubject, _strMessage):
     """Sends an email to the EDNA contact person (if configured)."""
     strTime = "%.1f s" % (self.tStop - self.tStart)
     if EDUtilsPath.isESRF():
         strPathImage = None
         for dataSet in self.dataInput.dataSet:
             for imageFile in dataSet.imageFile:
                 strPathImage = imageFile.path.value
                 break
         if strPathImage is not None:
             (strBeamline, strProposal, strPrefix) = self.getBeamlineProposalFromPath(strPathImage)
         else:
             strBeamline = "Unknown"
             strProposal = "Unknown"
             strPrefix = "Unknown"
         strHost = socket.gethostname()
         strSubject = "EDNA ch %s %s %s %s %s (%s)" % (_strSubject, strBeamline, strProposal, strPrefix, strHost, strTime)
     else:
         strSubject = "EDNA %s : %s (%s)" % (_strSubject, EDUtilsPath.getEdnaSite(), strTime)
     self.DEBUG("EDPluginControlInterfaceToMXCuBEv1_4.sendEmail: Subject = %s" % strSubject)
     self.DEBUG("EDPluginControlInterfaceToMXCuBEv1_4.sendEmail: Message:")
     self.DEBUG(_strMessage)
     if self.strEDNAContactEmail == None:
         self.DEBUG("EDPluginControlInterfaceToMXCuBEv1_4.sendEmail: No email address configured!")
     elif not EDUtilsPath.getEdnaSite().startswith("ESRF"):
         self.DEBUG("EDPluginControlInterfaceToMXCuBEv1_4.sendEmail: Not executed at the ESRF! EDNA_SITE=%s" % EDUtilsPath.getEdnaSite())
     else:
         try:
             self.DEBUG("Sending message to %s." % self.strEDNAContactEmail)
             self.DEBUG("Message: %s" % _strMessage)
             strMessage = "EDNA_HOME = %s\n" % EDUtilsPath.getEdnaHome()
             strMessage += "EDNA_SITE = %s\n" % EDUtilsPath.getEdnaSite()
             strMessage += "PLUGIN_NAME = %s\n" % self.getPluginName()
             strMessage += "working_dir = %s\n\n" % self.getWorkingDirectory()
             strMessage += "Reference images:\n"
             xsDataInputMXCuBE = self.getDataInput()
             for xsDataSetMXCuBE in xsDataInputMXCuBE.getDataSet():
                 for xsDataFile in xsDataSetMXCuBE.getImageFile():
                     strMessage += "%s\n" % xsDataFile.getPath().getValue()
             strMessage += "\n"
             strMessage += _strMessage
             strEmailMsg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s" % (self.strEDNAEmailSender, \
                                                                             self.strEDNAContactEmail, \
                                                                             strSubject, strMessage))
             server = smtplib.SMTP("localhost")
             server.sendmail(self.strEDNAEmailSender, self.strEDNAContactEmail, strEmailMsg)
             server.quit()
         except:
             self.ERROR("Error when sending email message!")
             self.writeErrorTrace()
Exemple #35
0
    def getInputParameter(self):
        """
        Read all the input parameters and store them in instance variables called  self.dictGeometry and  self.pathToInputFile
        """
        self.DEBUG("EDPluginSPDCakev1_5.getInputParameter")
        EDPluginSPDCorrectv10.getInputParameter(self)
        if self.xsDataInputSPD.getStartAzimuth() is not None:
            if self.xsDataInputSPD.getStartAzimuth().getUnit() is not None:
                self.dictGeometry["StartAzimuth"] = EDUtilsUnit.getValue(self.xsDataInputSPD.getStartAzimuth(), "deg")
            else:
                self.WARNING("You did not specify the StartAzimuth Unit, Falling back to Deg (not Rad)")
                self.dictGeometry["StartAzimuth"] = self.xsDataInputSPD.getStartAzimuth().getValue()
        if self.xsDataInputSPD.getStopAzimuth() is not None:
            if self.xsDataInputSPD.getStopAzimuth().getUnit() is not None:
                self.dictGeometry["StopAzimuth"] = EDUtilsUnit.getValue(self.xsDataInputSPD.getStopAzimuth(), "deg")
            else:
                self.WARNING("You did not specify the StopAzimuth Unit, Falling back to Deg (not Rad)")
                self.dictGeometry["StopAzimuth"] = self.xsDataInputSPD.getStopAzimuth().getValue()
        if self.xsDataInputSPD.getStepAzimuth() is not None:
            if self.xsDataInputSPD.getStepAzimuth().getUnit() is not None:
                self.dictGeometry["StepAzimuth"] = EDUtilsUnit.getValue(self.xsDataInputSPD.getStepAzimuth(), "deg")
            else:
                self.WARNING("You did not specify the StepAzimuth Unit, Falling back to Deg (not Rad)")
                self.dictGeometry["StepAzimuth"] = self.xsDataInputSPD.getStepAzimuth().getValue()
        if self.xsDataInputSPD.getInnerRadius() is not None:
            self.dictGeometry["InnerRadius"] = self.xsDataInputSPD.getInnerRadius().getValue()
        if self.xsDataInputSPD.getOuterRadius() is not None:
            self.dictGeometry["OuterRadius"] = self.xsDataInputSPD.getOuterRadius().getValue()
        if self.xsDataInputSPD.getOutputDirCake() is not None:
            self.dictGeometry["OutputDirCake"] = self.xsDataInputSPD.getOutputDirCake().getPath().getValue()
            EDUtilsPath.createFolder(self.dictGeometry["OutputDirCake"])
            if self.dictGeometry["OutputDirCake"] != self.dictGeometry["OutputDir"]:
                self.setFireAndForget(False)
        else:
            self.dictGeometry["OutputDirCake"] = self.dictGeometry["OutputDir"]
        if self.xsDataInputSPD.getMaskFile() is not None:
            self.dictGeometry["MaskFile"] = self.xsDataInputSPD.getMaskFile().getPath().getValue()
            if not os.path.isfile(self.dictGeometry["MaskFile"]):
                self.ERROR("Mask file %s does not exist " % self.dictGeometry["MaskFile"])
                self.dictGeometry.pop("MaskFile")
        if self.xsDataInputSPD.getIntensityScaleFactor() is not None:
            self.dictGeometry["IntensityScaleFactor"] = self.xsDataInputSPD.getIntensityScaleFactor().getValue()

        if self.xsDataInputSPD.getDeleteCorImg() is not None:
            self.bDeleteCorImg = (self.xsDataInputSPD.getDeleteCorImg().getValue() in ["1", 1, "true", "True", True])
        if self.bDeleteCorImg:
            self.setFireAndForget(False)
        if self.xsDataInputSPD.getCorrectTiltMask() is not None:
            self.bCorrectTiltMask = bool(self.xsDataInputSPD.getCorrectTiltMask().getValue())
Exemple #36
0
 def testGetPathToProjectConfigurationFile(self):
     edConfiguration = EDConfiguration()
     strPathToConfigurationFile1 = edConfiguration.getPathToProjectConfigurationFile(
         "EDPluginTestPluginFactory")
     strPathToConfigurationFileReference1 = EDUtilsPath.appendListOfPaths(EDUtilsPath.getEdnaHome(),
                                                                               [ "kernel", "tests", "data", "EDFactoryPlugin", \
                                                                                "testProject", "conf", "XSConfiguration_TestSite.xml" ])
     EDAssert.equal(strPathToConfigurationFileReference1,
                    strPathToConfigurationFile1)
     EDUtilsPath.setEdnaSite("NonexistingTestSite")
     strPathToConfigurationFile2 = edConfiguration.getPathToProjectConfigurationFile(
         "EDPluginTestPluginFactory")
     strPathToConfigurationFileReference2 = None
     EDAssert.equal(strPathToConfigurationFileReference2,
                    strPathToConfigurationFile2)
Exemple #37
0
 def preparePythonWrapperScript(self):
     listScript = ["#!%s" % sys.executable, ""]
     listScript += ["import os, sys, xmlrpclib"]
     listScript += ["""pyXmlrcplibProxy = xmlrpclib.ServerProxy('http://%s:%d')""" % (self.__edServerXMLRCP.getHost(), self.__edServerXMLRCP.getPort())]
     listScript += ["""os.chdir("%s")""" % self.getWorkingDirectory()]
     listScript += ["""os.environ['EDNA_HOME']="%s" """ % EDUtilsPath.getEdnaHome()]
     listScript += ["""os.environ['EDNA_SITE']="%s" """ % EDUtilsPath.getEdnaSite()]
     listScript += ["""sys.path.append(os.path.join(os.environ["EDNA_HOME"], "kernel", "src"))"""]
     listScript += ["""from EDFactoryPluginStatic import EDFactoryPluginStatic"""]
     listScript += ["""from EDUtilsFile import EDUtilsFile"""]
     listScript += ["""edPlugin = EDFactoryPluginStatic.loadPlugin("%s")""" % self.__strNameOfPlugin]
     for strValue in self.__dictXMLDataInput:
         if strValue == self.getDefaultInputDataKey():
             listScript += ["edPlugin.setDataInput(\"\"\"%s\"\"\")""" % self.__dictXMLDataInput[strValue]]
         else:
             listScript += ["edPlugin.setDataInput(\"\"\"%s\"\"\", \"%s\")" % (self.__dictXMLDataInput[strValue], strValue)]
     listScript += ["""def actionSuccessFile(_edPlugin=None):"""]
     listScript += ["""    strSuccessMessage = "" """]
     listScript += ["""    for strKey in _edPlugin.getListOfDataOutputKeys():"""]
     listScript += ["""        if strKey == _edPlugin.getDefaultOutputDataKey():"""]
     listScript += ["""            strXMLOutput = _edPlugin.getDataOutput().marshal()"""]
     listScript += ["""            strSuccessMessage += strKey + "\\n" """]
     listScript += ["""            EDUtilsFile.writeFile(os.path.join("%s", "XSDataResult_"+strKey+".xml"), strXMLOutput)""" % self.getWorkingDirectory()]
     listScript += ["""        else:"""]
     listScript += ["""            iIndex = 1"""]
     listScript += ["""            for xsDataResult in _edPlugin.getDataOutput(strKey):"""]
     listScript += ["""                strXMLOutput = xsDataResult.marshal()"""]
     listScript += ["""                strSuccessMessage += "%s_%d\\n" % (strKey, iIndex) """]
     listScript += ["""                EDUtilsFile.writeFile(os.path.join("%s", "XSDataResult_"+strKey+"_%%d.xml") %% iIndex, strXMLOutput)""" % self.getWorkingDirectory()]
     listScript += ["""                 """]
     listScript += ["""    EDUtilsFile.writeFile(os.path.join("%s", "SUCCESS.txt"), strSuccessMessage)""" % self.getWorkingDirectory()]
     listScript += ["""def actionSuccessXMLRCP(_edPlugin=None):"""]
     listScript += ["""    pyXmlrcplibProxy.callbackSUCCESS("%d", [])""" % self.getId()]
     listScript += ["""    for strKey in _edPlugin.getListOfDataOutputKeys():"""]
     listScript += ["""        strXMLOutput = _edPlugin.getDataOutput().marshal()"""]
     listScript += ["""        pyXmlrcplibProxy.setDataOutput("%d", strXMLOutput)""" % self.getId()]
     listScript += ["""def actionFailure(_edObject=None):"""]
     listScript += ["""    pyXmlrcplibProxy.callbackFAILURE("%d", [])""" % self.getId()]
     listScript += ["""#edPlugin.connectSUCCESS(actionSuccessFile)"""]
     listScript += ["""edPlugin.connectSUCCESS(actionSuccessXMLRCP)"""]
     listScript += ["""edPlugin.connectFAILURE(actionFailure)"""]
     listScript += ["""edPlugin.executeSynchronous()"""]
     listScript += [""]
     listScript += [""]
     strPythonWrapper = ""
     for strLine in listScript:
         strPythonWrapper = strPythonWrapper + strLine + "\n"
     return strPythonWrapper
 def process(self, _edObject=None):
     EDPluginExec.process(self)
     self.DEBUG("EDPluginExecPlotGlev1_1.process")
     for dictPlot in self.listPlot:
         if os.path.dirname(dictPlot["script"]) != self.getWorkingDirectory():
             shutil.copy(dictPlot["script"], self.getWorkingDirectory())
         listDataFiles = dictPlot["data"]
         for strDataFileFullPath in listDataFiles:
             strDataFile = os.path.basename(strDataFileFullPath)
             if not os.path.exists(os.path.join(self.getWorkingDirectory(), strDataFile)):
                 shutil.copy(strDataFileFullPath, self.getWorkingDirectory())
         if EDUtilsPath.isESRF():
             # Force PXSOFT version of gle
             strCommand = "/opt/pxsoft/bin/gle -verbosity 0 -r 150 -d jpg %s" % os.path.basename(dictPlot["script"])
         else:
             strCommand = "gle -verbosity 0 -r 150 -d jpg %s" % os.path.basename(dictPlot["script"])
         # Copied from EDPluginExecProcess
         self.DEBUG(self.getBaseName() + ": Processing")
         timer = threading.Timer(float(self.getTimeOut()), self.kill)
         timer.start()
         try:
             self.__subprocess = EDUtilsPlatform.Popen(shlex.split(str(EDUtilsPlatform.escape(strCommand))),
                                                cwd=self.getWorkingDirectory())
             self.__iPID = self.__subprocess.pid
             self.__strExecutionStatus = str(self.__subprocess.wait())
         except OSError as e:
             strErrorMessage = self.getPluginName() + " : required program gle not installed"
             self.error(strErrorMessage)
             self.setFailure()
         finally:
             timer.cancel()
Exemple #39
0
 def doFailureActionInterface(self, _edPlugin=None):
     self.DEBUG(
         "EDPluginControlInterfaceToMXCuBEv1_3.doFailureActionInterface...")
     self.setFailure()
     xsDataResultCharacterisation = None
     if self.edPluginControlInterface.hasDataOutput("characterisation"):
         xsDataResultCharacterisation = self.edPluginControlInterface.getDataOutput(
             "characterisation")[0]
     # Execute plugin which creates a simple HTML page
     self.executeSimpleHTML(xsDataResultCharacterisation)
     # Send failure email message (MXSUP-183):
     strSubject = "%s : FAILURE!" % EDUtilsPath.getEdnaSite()
     strMessage = "Interface FAILURE!"
     if self.edPluginControlInterface.hasDataOutput("characterisation"):
         xsDataResultCharacterisation = self.edPluginControlInterface.getDataOutput(
             "characterisation")[0]
         if xsDataResultCharacterisation.getStatusMessage():
             strMessage += "\n\n"
             strMessage += xsDataResultCharacterisation.getStatusMessage(
             ).getValue()
         if xsDataResultCharacterisation.getShortSummary():
             strMessage += "\n\n"
             strMessage += xsDataResultCharacterisation.getShortSummary(
             ).getValue()
     self.sendEmail(strSubject, strMessage)
 def preProcess(self):
     EDPluginExecProcessScript.preProcess(self)
     self.DEBUG('Pointless: preprocess')
     if self.output_file is not None and self.input_file is not None:
         if EDUtilsPath.isEMBL() or EDUtilsPath.isALBA():
             options = '''-c xdsin {0} hklout {1}'''.format(
                 self.input_file, self.output_file)
         else:
             options = '''xdsin {0} hklout {1}'''.format(
                 self.input_file, self.output_file)
         self.setScriptCommandline(options)
         self.DEBUG('command line options set to {0}'.format(options))
     self.addListCommandExecution('setting symmetry-based')
     if self.dataInput.choose_spacegroup is not None:
         self.addListCommandExecution('choose spacegroup {0}'.format(
             self.dataInput.choose_spacegroup.value))
Exemple #41
0
 def doFailureActionISPyB(self, _edPlugin=None):
     self.DEBUG("EDPluginControlInterfaceToMXCuBEv1_3.doFailureActionISpyB...")
     self.retrieveFailureMessages(self.edPluginControlISPyB, "EDPluginControlInterfaceToMXCuBEv1_3.doFailureActionISpyB")
     # Send failure email message (MXSUP-183):
     strSubject = "%s : FAILURE!" % EDUtilsPath.getEdnaSite()
     strMessage = "ISPyB FAILURE!"
     self.sendEmail(strSubject, strMessage)
    def getPathToProjectConfigurationFile(self, _strModuleName):
        """
        This method returns the path to the Project configuration file.

        @param _strModuleName: Name of the module
        @type _strModuleName: python string
        
        @return: The path to the project configuration file
        @type: python string
        """
        strPathToProjectConfigurationFile = None
        strCurrentDirectory = self.getModuleLocation(_strModuleName)
        bConfFileFound = False
        with self.locked():
            while not bConfFileFound:
                strPreviousDirectory = strCurrentDirectory
                strCurrentDirectory = os.path.dirname(strCurrentDirectory)
                strPathToConfigurationDirectory = os.path.abspath(os.path.join(strCurrentDirectory, "conf"))
                strConfigurationFileName = "XSConfiguration_%s.xml" % EDUtilsPath.getEdnaSite()
                strPathToProjectConfigurationFile = os.path.abspath(os.path.join(strPathToConfigurationDirectory, \
                                                                                strConfigurationFileName))
                self.DEBUG("Looking for configuration file for %s in %s" %
                                (_strModuleName, strPathToProjectConfigurationFile))
                bConfFileFound = os.path.isfile(strPathToProjectConfigurationFile)
                if strCurrentDirectory in (EDUtilsPath.EDNA_HOME, strPreviousDirectory):
                    strPathToProjectConfigurationFile = None
                    break
        return strPathToProjectConfigurationFile
 def __init__ (self):
     EDPluginControl.__init__(self)
     self.strPluginMXWaitFileName = "EDPluginMXWaitFilev1_1"
     self.strPluginName = "EDPluginDistlSignalStrengthv1_1"
     self.strPluginNameThinClient = "EDPluginDistlSignalStrengthThinClientv1_1"
     self.strPluginNameControlDozor = "EDPluginControlDozorv1_0"
     self.strISPyBPluginName = "EDPluginISPyBStoreListOfImageQualityIndicatorsv1_5"
     self.strIndexingLabelitPluginName = "EDPluginLabelitIndexingv1_1"
     self.edPluginLabelitIndexing = None
     self.strPluginReadImageHeaderName = "EDPluginControlReadImageHeaderv10"
     self.edPluginReadImageHeader = None
     self.edPluginControlDozor = None
     self.setXSDataInputClass(XSDataInputControlImageQualityIndicators)
     self.listPluginExecImageQualityIndicator = []
     self.listPluginControlDozor = []
     self.xsDataResultControlImageQualityIndicators = None
     self.edPluginMXWaitFile = None
     # Default time out for wait file
     self.fMXWaitFileTimeOut = 30  # s
     # Flag for using the thin client
     if EDUtilsPath.isEMBL():
         self.bUseThinClient = False
     else:
         self.bUseThinClient = True
     self.edPluginISPyB = None
     self.listPluginLabelit = []
     self.defaultMinImageSize = 1000000
     self.minImageSize = None
 def __init__(self, _edStringTestName=None):
     EDTestCasePluginExecute.__init__(
         self, "EDPluginControlImageQualityIndicatorsv1_2")
     self.strTmpDir = tempfile.mkdtemp(
         prefix="EDPluginControlImageQualityIndicatorsv1_2_",
         dir=EDUtilsPath.getEdnaTestDataImagesPath())
     os.chmod(self.strTmpDir, 0755)
     if "EDNA_TMP_DIR" in os.environ.keys():
         self.strTmpDirOrig = os.environ["EDNA_TMP_DIR"]
     else:
         self.strTmpDirOrig = None
     os.environ["EDNA_TMP_DIR"] = self.strTmpDir
     self.setRequiredPluginConfiguration("EDPluginDistlSignalStrengthv1_1")
     self.setConfigurationFile(self.getRefConfigFile())
     self.setDataInputFile(
         os.path.join(
             self.getPluginTestsDataHome(),
             "XSDataInputControlImageQualityIndicators_waitFile.xml"))
     self.setReferenceDataOutputFile(
         os.path.join(
             self.getPluginTestsDataHome(),
             "XSDataResultControlImageQualityIndicators_reference.xml"))
     self.strInputDataFile1 = os.path.join(self.getTestsDataImagesHome(),
                                           "ref-testscale_1_001.img")
     self.strInputDataFile2 = os.path.join(self.getTestsDataImagesHome(),
                                           "ref-testscale_1_002.img")
     self.strInputDataFileNew1 = None
     self.strInputDataFileNew2 = None
 def doFailureActionInterface(self, _edPlugin=None):
     self.DEBUG(
         "EDPluginControlInterfaceToMXCuBEv1_3.doFailureActionInterface...")
     # Send failure email message (MXSUP-183):
     strSubject = "%s : FAILURE!" % EDUtilsPath.getEdnaSite()
     strMessage = "Characterisation FAILURE!"
     self.storeResultsInISPyB(strSubject, strMessage)
 def doFailureActionISPyB(self, _edPlugin=None):
     self.DEBUG("EDPluginControlInterfaceToMXCuBEv1_3.doFailureActionISpyB...")
     self.retrieveFailureMessages(self.edPluginControlISPyB, "EDPluginControlInterfaceToMXCuBEv1_3.doFailureActionISpyB")
     # Send failure email message (MXSUP-183):
     strSubject = "%s : FAILURE!" % EDUtilsPath.getEdnaSite()
     strMessage = "ISPyB FAILURE!"
     self.sendEmail(strSubject, strMessage)
    def generateXSDataISPyBImage(_xsDataInputControlISPyB):
        """
        """
        EDFactoryPluginStatic.loadModule("XSDataISPyBv1_2")
        from XSDataISPyBv1_2 import XSDataString
        from XSDataISPyBv1_2 import XSDataISPyBImage
        xsDataResultCharacterisation = _xsDataInputControlISPyB.getCharacterisationResult(
        )

        xsDataISPyBImage = None
        # Find path to first image from data collection information
        strPathToFirstImage = None
        xsDataCollection = xsDataResultCharacterisation.getDataCollection()
        if (xsDataCollection is not None):
            lXSDataSubWedge = xsDataCollection.getSubWedge()
            if (lXSDataSubWedge is not None):
                xsDataSubWedgeFirst = lXSDataSubWedge[0]
                lXSDataImage = xsDataSubWedgeFirst.getImage()
                if (lXSDataImage is not None):
                    xsDataImageFirst = lXSDataImage[0]
                    strPathToFirstImage = xsDataImageFirst.getPath().getValue()

            # Add an image path if the dataCollectionId is not present...
            if (strPathToFirstImage is not None):
                xsDataISPyBImage = XSDataISPyBImage()
                strImageBaseName = EDUtilsFile.getBaseName(strPathToFirstImage)
                strDirectoryName = EDUtilsPath.getFolderName(
                    strPathToFirstImage)
                xsDataISPyBImage.setFileName(XSDataString(strImageBaseName))
                xsDataISPyBImage.setFileLocation(
                    XSDataString(strDirectoryName))
        return xsDataISPyBImage
Exemple #48
0
 def readAndParseFile(_strFileName):
     """
     Reads a file and parses potential existing environment variables such as:
      - EDNA_TESTS_DATA_HOME
     Returns the content of this file as a string
     """
     return EDUtilsFile.readFileAndParseVariables(_strFileName, EDUtilsPath.getDictOfPaths())
Exemple #49
0
 def getConfigurationHome(cls, _strPluginTestName):
     """
     Returns the configuration directory path for a given test module
     """
     strModuleLocation = cls.getFactoryPluginTest().getModuleLocation(_strPluginTestName)
     strConfigurationHome = EDUtilsPath.appendListOfPaths(strModuleLocation, [ "..", "..", "..", "..", "conf" ])
     return strConfigurationHome
    def getProjectRootDirectory(self, _strModuleName):
        """
        This method returns the project root directory of a given module name.
        A directory is considered to be a project root if it contains the following
        directories: "conf", "src" and "plugins"

        @param _strModuleName: Name of the module
        @type _strModuleName: python string
        
        @return: The project root directory
        @type: python string
        """
        strModuleLocation = self.getModuleLocation(_strModuleName)
        with self.locked():
            strProjectRootDirectory = None
            if (strModuleLocation is not None):
                # Now start looking for "conf" and "plugins", max four iterations
                bFoundRootDirectory = False
                iMaxIterations = 4
                strProjectRootDirectory = strModuleLocation
                while ((not bFoundRootDirectory) and (iMaxIterations > 0)):
                    strProjectRootDirectory = os.path.abspath(os.path.join(strProjectRootDirectory, ".."))
                    edListDirectoryContent = EDUtilsPath.getFileList(strProjectRootDirectory)
                    if (("conf" in edListDirectoryContent) and \
                         ("src" in edListDirectoryContent) and \
                         ("plugins" in edListDirectoryContent)):
                        bFoundRootDirectory = True
                    iMaxIterations = iMaxIterations - 1
                if (not bFoundRootDirectory):
                    strProjectRootDirectory = None
        return strProjectRootDirectory
Exemple #51
0
 def getPluginTestDataDirectory(cls, _strPluginTestName):
     """
     Given a test case name, returns the corresponding test data directory.
     """
     strModuleLocation = cls.getFactoryPluginTest().getModuleLocation(_strPluginTestName)
     strPluginTestDataDirectory = EDUtilsPath.appendListOfPaths(strModuleLocation, [ "..", "data" ])
     return strPluginTestDataDirectory
    def doSuccessMXWaitFile(self, _edPlugin=None):
        self.DEBUG("EDPluginControlID29CreateThumbnailv1_0.doSuccessMXWaitFile")
        self.retrieveSuccessMessages(_edPlugin, "EDPluginControlID29CreateThumbnailv1_0.doSuccessMXWaitFile")
        # Check that the image is really there
        if not self.edPluginMXWaitFile.dataOutput.timedOut.value:
            # Workaround for ESRF lag problem
            if EDUtilsPath.isESRF():
                time.sleep(2)
                if self.isH5:
                    diffractionImagePath = self.dataInput.diffractionImage.path.value
                    imageNumber = EDUtilsImage.getImageNumber(diffractionImagePath)
                    xsDataInputControlH5ToCBF = XSDataInputControlH5ToCBF()
                    xsDataInputControlH5ToCBF.hdf5File = XSDataFile(XSDataString(diffractionImagePath))
                    xsDataInputControlH5ToCBF.imageNumber = XSDataInteger(imageNumber)
                    xsDataInputControlH5ToCBF.hdf5ImageNumber = XSDataInteger(self.h5FileNumber)
                    xsDataInputControlH5ToCBF.ispybDataCollection = None
                    xsDataInputControlH5ToCBF.forcedOutputDirectory = XSDataFile(XSDataString(self.getWorkingDirectory()))
                    edPluginControlH5ToCBF = self.loadPlugin(self.strPluginControlH5ToCBF, "ControlH5ToCBF_{0:04d}".format(imageNumber))
                    edPluginControlH5ToCBF.dataInput = xsDataInputControlH5ToCBF
                    edPluginControlH5ToCBF.executeSynchronous()
                    cbfFile = edPluginControlH5ToCBF.dataOutput.outputCBFFile
                    self.edPluginExecThumbnail.dataInput.image = cbfFile

            # The image is here - make the first thumbnail
            self.edPluginExecThumbnail.connectSUCCESS(self.doSuccessExecThumbnail)
            self.edPluginExecThumbnail.connectFAILURE(self.doFailureExecThumbnail)
            self.edPluginExecThumbnail.executeSynchronous()
        else:
            self.error("Time-out while waiting for image!")
            self.setFailure()
Exemple #53
0
    def getProjectRootDirectory(self, _strModuleName):
        """
        This method returns the project root directory of a given module name.
        A directory is considered to be a project root if it contains the following
        directories: "conf", "src" and "plugins"

        @param _strModuleName: Name of the module
        @type _strModuleName: python string
        
        @return: The project root directory
        @type: python string
        """
        strModuleLocation = self.getModuleLocation(_strModuleName)
        if strModuleLocation not in self.__class__.__dictProjectRootDir:
            with self.__class__.__semaphoreStatic:
                if strModuleLocation not in self.__class__.__dictProjectRootDir:
                    strProjectRootDirectory = None
                    if (strModuleLocation is not None):
                        # Now start looking for "conf" and "plugins", max four iterations
                        bFoundRootDirectory = False
                        iMaxIterations = 4
                        strProjectRootDirectory = strModuleLocation
                        while ((not bFoundRootDirectory) and (iMaxIterations > 0)):
                            strProjectRootDirectory = os.path.abspath(os.path.join(strProjectRootDirectory, ".."))
                            edListDirectoryContent = EDUtilsPath.getFileList(strProjectRootDirectory)
                            if (("conf" in edListDirectoryContent) and \
                                 ("src" in edListDirectoryContent) and \
                                 ("plugins" in edListDirectoryContent)):
                                bFoundRootDirectory = True
                            iMaxIterations = iMaxIterations - 1
                        if (not bFoundRootDirectory):
                            strProjectRootDirectory = None
                        self.__class__.__dictProjectRootDir[strModuleLocation] = strProjectRootDirectory
        return self.__class__.__dictProjectRootDir[strModuleLocation]
    def __init__( self, _edStringTestName = None):
        """
        """
        EDTestCasePluginExecute.__init__( self, "EDPluginExecDIMPLEMTZDUMPv10" )

        self.setConfigurationFile( self.getRefConfigFile() )
        
        self.setDataInputFile( EDUtilsPath.mergePath( self.getPluginTestsDataHome(), \
                                                      "XSDataInputDIMPLEMTZDUMP_reference.xml" ) )
        
        self.setReferenceDataOutputFile( EDUtilsPath.mergePath( self.getPluginTestsDataHome(), \
                                                                "XSDataResultDIMPLEMTZDUMP_reference.xml"))

        self.m_edObtainedOutputDataFile = self.getPluginName() + "_output.xml"
        
        self.m_iNoErrorMessages = 0
        self.m_iNoWarningMessages = 0        
 def testGetProjectRootDirectory(self):
     edFactoryPlugin = EDFactoryPlugin()
     strEdnaHome = EDUtilsPath.getEdnaHome()
     strTestProjectRootDirectoryReference = EDUtilsPath.appendListOfPaths(
         strEdnaHome,
         ["kernel", "tests", "data", "EDFactoryPlugin", "testProject"])
     strTestProjectRootDirectory1 = edFactoryPlugin.getProjectRootDirectory(
         "EDPluginTestPluginFactory")
     EDAssert.equal(strTestProjectRootDirectoryReference,
                    strTestProjectRootDirectory1)
     strTestProjectRootDirectory2 = edFactoryPlugin.getProjectRootDirectory(
         "XSDataTestProject")
     EDAssert.equal(strTestProjectRootDirectoryReference,
                    strTestProjectRootDirectory2)
     strTestProjectRootDirectory3 = edFactoryPlugin.getProjectRootDirectory(
         "PluginThatNotExists")
     EDAssert.equal(None, strTestProjectRootDirectory3)