コード例 #1
0
    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)
コード例 #2
0
    def postProcess(self, _edObject=None):
        """
        Calls the parent preProcess method
        Checks that the installed 3rd party software is in the list of compatible versions
        """
        EDPluginExecProcess.postProcess(self)
        self.DEBUG("EDPluginExecProcessScript.postProcess")

        # Tests the compatibles executable versions
        listCompatibleVersions = self.getListOfCompatibleVersions()

        if (len(listCompatibleVersions) != 0):

            bFound = False
            for compatibleVersion in listCompatibleVersions:
                bFound = self.findStringInLog(compatibleVersion)
                if (bFound == True):
                    break

            if (bFound == False):
                strErrorMessage = "Plugin not compatible with %s, compatible versions are: %s" % (
                    self.getStringVersion(),
                    self.getCompatibleVersionsStringLine())
                self.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                self.setFailure()
                if self.isVerboseDebug():
                    raise RuntimeError(strErrorMessage)
コード例 #3
0
    def postProcess(self, _edObject=None):
        """
        Calls the parent preProcess method
        Checks that the installed 3rd party software is in the list of compatible versions
        """
        EDPluginExecProcess.postProcess(self)
        self.DEBUG("EDPluginExecProcessScript.postProcess")

        # Tests the compatibles executable versions
        listCompatibleVersions = self.getListOfCompatibleVersions()

        if(len(listCompatibleVersions) != 0):

            bFound = False
            for compatibleVersion in listCompatibleVersions:
                bFound = self.findStringInLog(compatibleVersion)
                if(bFound == True):
                    break

            if(bFound == False):
                strErrorMessage = "Plugin not compatible with %s, compatible versions are: %s" % (self.getStringVersion(), self.getCompatibleVersionsStringLine())
                self.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                self.setFailure()
                if self.isVerboseDebug():
                    raise RuntimeError, strErrorMessage
コード例 #4
0
 def preProcess(self, _edObject=None):
     """
     Calls the parent preProcess method
     Generates the script
     """
     EDPluginExecProcess.preProcess(self)
     self.DEBUG("EDPluginExecProcessScript.preProcess")
     # The generateScript method will be called at the end of the preProcess method
     self.connectPreProcess(self.generateScript)
コード例 #5
0
 def preProcess(self, _edObject=None):
     """
     Calls the parent preProcess method
     Generates the script
     """
     EDPluginExecProcess.preProcess(self)
     self.DEBUG("EDPluginExecProcessScript.preProcess")
     # The generateScript method will be called at the end of the preProcess method
     self.connectPreProcess(self.generateScript)
コード例 #6
0
ファイル: EDPluginSPDCorrectv10.py プロジェクト: rentreg/edna
    def preProcess(self, _edObject=None):
        """
        Preprocess methods for the EDPluginSPDCorrectv10 :
        - Reads input parameters
        - Creates the displacement matrix if the the detector is tilted
        - create the configuration for SPD
        - selects the worker (SPD program under control)
        """
        EDPluginExecProcess.preProcess(self)
        self.DEBUG("EDPluginSPDCorrectv10.preProcess")
        # Check that the input data and correction images are present
        self.getInputParameter()
        if "SpatialDistortionFile" in self.dictGeometry:
            splineDM = Spline()
            splineDM.read(self.dictGeometry["SpatialDistortionFile"])
            self.dictGeometry["PixelSizeX"], self.dictGeometry[
                "PixelSizeY"] = splineDM.getPixelSize()
        else:
            splineDM = None
        if self.dictGeometry["AngleOfTilt"] != 0:
            EDPluginSPDCorrectv10.__lockTilt.acquire()
            if splineDM == None:
                edfFile = fabio.open(self.pathToInputFile)
                data = edfFile.data
                size = data.shape
                splineDM = splineDM.zeros(xmin=0.0,
                                          ymin=0.0,
                                          xmax=size[0],
                                          ymax=size[1])
                if ("PixelSizeX"
                        in self.dictGeometry) and ("PixelSizeY"
                                                   in self.dictGeometry):
                    splineDM.setPixelSize = (self.dictGeometry["PixelSizeX"],
                                             self.dictGeometry["PixelSizeY"])

            strtmp = os.path.join(
                self.getSPDCommonDirectory(),
                os.path.basename(
                    os.path.splitext(
                        self.dictGeometry["SpatialDistortionFile"])[0]))

            if not (os.path.isfile(strtmp + "-tilted-x.edf")
                    and os.path.isfile(strtmp + "-tilted-y.edf")):
                #                self.DEBUG("preProcess: \t EDPluginSPDCorrectv10.__lock.acquire(), currently: %i" % EDPluginSPDCorrectv10.__lock._Semaphore__value)

                if not (os.path.isfile(strtmp + "-tilted-x.edf")
                        and os.path.isfile(strtmp + "-tilted-y.edf")):
                    #The second test is just here to gain some time as the global semaphore could be in use elsewhere
                    self.createDisplacementMatrix(splineDM)

            self.dictGeometry["DistortionFileX"] = strtmp + "-tilted-x.edf"
            self.dictGeometry["DistortionFileY"] = strtmp + "-tilted-y.edf"
            EDPluginSPDCorrectv10.__lockTilt.release()
        self.generateSPDCommand()
コード例 #7
0
ファイル: EDPluginSPDCorrectv10.py プロジェクト: rentreg/edna
 def configure(self):
     """
     Configures the plugin from the configuration file with the following parameters
      - Script executable to be invoked
      - number of worker 
      - The 3rd party executable installed version
     """
     EDPluginExecProcess.configure(self)
     self.DEBUG(" EDPluginSPDCorrect.configure")
     xsPluginItem = self.getConfiguration()
     if (xsPluginItem == None):
         self.WARNING(
             "EDPluginSPDCorrect.configure: No plugin item defined.")
         xsPluginItem = XSPluginItem()
     if (self.getExecutable() is None):
         edStringScriptExecutable = EDConfiguration.getStringParamValue(
             xsPluginItem, CONF_EXEC_PROCESS_SCRIPT_EXECUTABLE)
         if (edStringScriptExecutable == None):
             errorMessage = EDMessage.ERROR_EXECUTION_03 % ('EDPluginSPDCorrect.process', self.getClassName(), "Configuration parameter missing: " \
                                                            + CONF_EXEC_PROCESS_SCRIPT_EXECUTABLE)
             self.error(errorMessage)
             self.addErrorMessage(errorMessage)
             raise RuntimeError, errorMessage
         else:
             # Check that the executable file exists
             if not os.path.isfile(edStringScriptExecutable):
                 errorMessage = EDMessage.ERROR_EXECUTION_03 % ('EDPluginSPDCorrect.process', self.getClassName(), "Cannot find configured " \
                                                                + CONF_EXEC_PROCESS_SCRIPT_EXECUTABLE + " : " + edStringScriptExecutable)
                 self.error(errorMessage)
                 self.addErrorMessage(errorMessage)
                 raise RuntimeError, errorMessage
             else:
                 self.setExecutable(edStringScriptExecutable)
     edStringConfigSetupNbWorker = EDConfiguration.getStringParamValue(
         xsPluginItem, CONF_EXEC_MAX_MAX_NUMBER_OF_WORKERS)
     if (edStringConfigSetupNbWorker == None):
         self.DEBUG(
             "EDPluginSPDCorrect.configure: No configuration parameter found for: "
             + CONF_EXEC_MAX_MAX_NUMBER_OF_WORKERS + ", NO default value!")
     else:
         self._iConfigNumberOfWorker = int(edStringConfigSetupNbWorker)
     edStringVersion = EDConfiguration.getStringParamValue(
         xsPluginItem, CONF_EXEC_PROCESS_SCRIPT_VERSION_STRING)
     if (edStringVersion == None):
         self.DEBUG(
             "EDPluginSPDCorrect.configure: No configuration parameter found for: "
             + CONF_EXEC_PROCESS_SCRIPT_VERSION_STRING +
             ", NO default value!")
     else:
         self.setStringVersion(edStringVersion)
コード例 #8
0
ファイル: EDPluginSPDCorrectv10.py プロジェクト: rentreg/edna
    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)
コード例 #9
0
    def preProcess(self, _edObject=None):
        """
        Preprocess methods for the EDPluginSPDCorrectv10 :
        - Reads input parameters
        - Creates the displacement matrix if the the detector is tilted
        - create the configuration for SPD
        - selects the worker (SPD program under control)
        """
        EDPluginExecProcess.preProcess(self)
        self.DEBUG("EDPluginSPDCorrectv10.preProcess")
        # Check that the input data and correction images are present
        self.getInputParameter()
        if "SpatialDistortionFile" in self.dictGeometry:
            splineDM = Spline()
            splineDM.read(self.dictGeometry["SpatialDistortionFile"])
            self.dictGeometry["PixelSizeX"], self.dictGeometry["PixelSizeY"] = splineDM.getPixelSize()
        else:
            splineDM = None
        if self.dictGeometry["AngleOfTilt"] != 0:
            EDPluginSPDCorrectv10.__lockTilt.acquire()
            if splineDM == None:
                edfFile = fabio.open(self.pathToInputFile)
                data = edfFile.data
                size = data.shape
                splineDM = splineDM.zeros(xmin=0.0, ymin=0.0, xmax=size[0], ymax=size[1])
                if ("PixelSizeX" in self.dictGeometry) and ("PixelSizeY" in self.dictGeometry):
                    splineDM.setPixelSize = (self.dictGeometry["PixelSizeX"], self.dictGeometry["PixelSizeY"])

            strtmp = os.path.join(
                self.getSPDCommonDirectory(),
                os.path.basename(os.path.splitext(self.dictGeometry["SpatialDistortionFile"])[0]),
            )

            if not (os.path.isfile(strtmp + "-tilted-x.edf") and os.path.isfile(strtmp + "-tilted-y.edf")):
                #                self.DEBUG("preProcess: \t EDPluginSPDCorrectv10.__lock.acquire(), currently: %i" % EDPluginSPDCorrectv10.__lock._Semaphore__value)

                if not (os.path.isfile(strtmp + "-tilted-x.edf") and os.path.isfile(strtmp + "-tilted-y.edf")):
                    # The second test is just here to gain some time as the global semaphore could be in use elsewhere
                    self.createDisplacementMatrix(splineDM)

            self.dictGeometry["DistortionFileX"] = strtmp + "-tilted-x.edf"
            self.dictGeometry["DistortionFileY"] = strtmp + "-tilted-y.edf"
            EDPluginSPDCorrectv10.__lockTilt.release()
        self.generateSPDCommand()
コード例 #10
0
ファイル: EDPluginSPDCorrectv10.py プロジェクト: gbourgh/edna
 def configure(self):
     """
     Configures the plugin from the configuration file with the following parameters
      - Script executable to be invoked
      - number of worker 
      - The 3rd party executable installed version
     """
     EDPluginExecProcess.configure(self)
     self.DEBUG(" EDPluginSPDCorrect.configure")
     xsPluginItem = self.getConfiguration()
     if (xsPluginItem == None):
         self.WARNING("EDPluginSPDCorrect.configure: No plugin item defined.")
         xsPluginItem = XSPluginItem()
     if (self.getExecutable() is None):
         edStringScriptExecutable = EDConfiguration.getStringParamValue(xsPluginItem, CONF_EXEC_PROCESS_SCRIPT_EXECUTABLE)
         if(edStringScriptExecutable == None):
             errorMessage = EDMessage.ERROR_EXECUTION_03 % ('EDPluginSPDCorrect.process', self.getClassName(), "Configuration parameter missing: " \
                                                            + CONF_EXEC_PROCESS_SCRIPT_EXECUTABLE)
             self.error(errorMessage)
             self.addErrorMessage(errorMessage)
             raise RuntimeError, errorMessage
         else:
             # Check that the executable file exists
             if not os.path.isfile(edStringScriptExecutable):
                 errorMessage = EDMessage.ERROR_EXECUTION_03 % ('EDPluginSPDCorrect.process', self.getClassName(), "Cannot find configured " \
                                                                + CONF_EXEC_PROCESS_SCRIPT_EXECUTABLE + " : " + edStringScriptExecutable)
                 self.error(errorMessage)
                 self.addErrorMessage(errorMessage)
                 raise RuntimeError, errorMessage
             else:
                 self.setExecutable(edStringScriptExecutable)
     edStringConfigSetupNbWorker = EDConfiguration.getStringParamValue(xsPluginItem, CONF_EXEC_MAX_MAX_NUMBER_OF_WORKERS)
     if(edStringConfigSetupNbWorker == None):
         self.DEBUG("EDPluginSPDCorrect.configure: No configuration parameter found for: " + CONF_EXEC_MAX_MAX_NUMBER_OF_WORKERS + ", NO default value!")
     else:
         self._iConfigNumberOfWorker = int(edStringConfigSetupNbWorker)
     edStringVersion = EDConfiguration.getStringParamValue(xsPluginItem, CONF_EXEC_PROCESS_SCRIPT_VERSION_STRING)
     if(edStringVersion == None):
         self.DEBUG("EDPluginSPDCorrect.configure: No configuration parameter found for: " + CONF_EXEC_PROCESS_SCRIPT_VERSION_STRING + ", NO default value!")
     else:
         self.setStringVersion(edStringVersion)
コード例 #11
0
 def __init__ (self):
     """
     Initializes process related attributes described above
     """
     EDPluginExecProcess.__init__(self)
     self.__strConfigShell = "/bin/bash"
     self.__strScriptExecutor = None
     self.__strScriptExecutable = None
     self.__strConfigSetupCCP4 = None
     self.__strVersion = None
     self.__listCompatibleVersions = []
     self.__strScriptCommandline = ""
     self.__strScriptBaseName = None
     self.__strScriptLogFileName = None
     self.__strScriptErrorLogFileName = None
     self.__strScriptFileName = None
     self.__bRequireCCP4 = False
     self.__listCommandPreExecution = []
     self.__listCommandExecution = []
     self.__listCommandPostExecution = []
     self.__iPollScriptProcessTime = 1 # [s]
     self.__strPathToHostNamePidFile = None
     self.__iNumberOfLastLinesFromLogFileIfError = 15
コード例 #12
0
 def __init__(self):
     """
     Initializes process related attributes described above
     """
     EDPluginExecProcess.__init__(self)
     self.__strConfigShell = "/bin/bash"
     self.__strScriptExecutor = None
     self.__strScriptExecutable = None
     self.__strConfigSetupCCP4 = None
     self.__strVersion = None
     self.__listCompatibleVersions = []
     self.__strScriptCommandline = ""
     self.__strScriptBaseName = None
     self.__strScriptLogFileName = None
     self.__strScriptErrorLogFileName = None
     self.__strScriptFileName = None
     self.__bRequireCCP4 = False
     self.__listCommandPreExecution = []
     self.__listCommandExecution = []
     self.__listCommandPostExecution = []
     self.__iPollScriptProcessTime = 1  # [s]
     self.__strPathToHostNamePidFile = None
     self.__iNumberOfLastLinesFromLogFileIfError = 15
コード例 #13
0
    def __init__(self):
        """
        Constructor of the plugin: just do some simple initialization 
        """
        EDPluginExecProcess.__init__(self)
        #        self.DEBUG(self.getBaseName())
        if self.getClassName() == "EDPluginSPDCorrectv10":
            self.setXSDataInputClass(XSDataInputSPD)
        self.dictGeometry = {}
        self.dictRes = {}
        self.xsDataInputSPD = None
        self.pathToInputFile = None
        self._SPDconfig = None
        self.worker = None
        self.workerID = None
        self._listCompatibleVersions = []
        self._strConfigExecutable = None
        self.bTimeOut = False

        self._iConfigNumberOfWorker = 0
        self._bFireAndForget = False
        self.strCurrentVersion = None
        self.addCompatibleVersion("spd version SPD = 1.2 SAXS = 2.436 EDF = 2.171")
コード例 #14
0
ファイル: EDPluginSPDCorrectv10.py プロジェクト: kif/edna
    def __init__(self):
        """
        Constructor of the plugin: just do some simple initialization 
        """
        EDPluginExecProcess.__init__(self)
#        self.DEBUG(self.getBaseName())
        if self.getClassName() == "EDPluginSPDCorrectv10":
            self.setXSDataInputClass(XSDataInputSPD)
        self.dictGeometry = {}
        self.dictRes = {}
        self.xsDataInputSPD = None
        self.pathToInputFile = None
        self._SPDconfig = None
        self.worker = None
        self.workerID = None
        self._listCompatibleVersions = []
        self._strConfigExecutable = None
        self.bTimeOut = False

        self._iConfigNumberOfWorker = 0
        self._bFireAndForget = False
        self.strCurrentVersion = None
        self.addCompatibleVersion("spd version SPD = 1.2 SAXS = 2.436 EDF = 2.171")
コード例 #15
0
    def configure(self):
        """
        Configures the plugin from the configuration file with the following parameters
         - The shell that will execute the script
         - Script executor
         - Script executable to be invoked
         - Path to CCP4 setup file if required
         - The 3rd party executable installed version
        """
        EDPluginExecProcess.configure(self)
        self.DEBUG("EDPluginExecProcessScript.configure")
        strShell = self.config.get(self.CONF_EXEC_PROCESS_SCRIPT_SHELL)
        if strShell is None:
            self.DEBUG("EDPluginExecProcessScript.configure: No configuration parameter found for: " + \
                            self.CONF_EXEC_PROCESS_SCRIPT_SHELL + ", using default value: " + self.getScriptShell())
        else:
            self.setScriptShell(strShell)
        strScriptExecutor = self.config.get(
            self.CONF_EXEC_PROCESS_SCRIPT_EXECUTOR)
        if strScriptExecutor is None:
            self.setScriptExecutor(self.getScriptShell())
            self.DEBUG("EDPluginExecProcessScript.configure: No configuration parameter found for: " + \
                            self.CONF_EXEC_PROCESS_SCRIPT_EXECUTOR + ", using script shell: " + self.getScriptShell())
        else:
            self.setScriptExecutor(strScriptExecutor)
        if self.__strScriptExecutable is None:
            strScriptExecutable = self.config.get(
                self.CONF_EXEC_PROCESS_SCRIPT_EXECUTABLE)
            if strScriptExecutable is None:
                strErrorMessage = "Configuration parameter %s missing for plugin %s with EDNA_SITE=%s" % \
                                    (self.CONF_EXEC_PROCESS_SCRIPT_EXECUTABLE, \
                                      self.getPluginName(), EDUtilsPath.EDNA_SITE)
                self.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                self.setFailure()
                if self.isVerboseDebug():
                    raise RuntimeError(strErrorMessage)
            else:
                # Check that the executable file exists
                if not os.path.exists(strScriptExecutable):
                    strErrorMessage = "Cannot find configured executable %s: %s for plugin %s with EDNA_SITE=%s" % \
                                    (self.CONF_EXEC_PROCESS_SCRIPT_EXECUTABLE, strScriptExecutable, \
                                      self.getPluginName(), EDUtilsPath.EDNA_SITE)
                    self.error(strErrorMessage)
                    self.addErrorMessage(strErrorMessage)
                    self.setFailure()
                    if self.isVerboseDebug():
                        raise RuntimeError(strErrorMessage)
                else:
                    self.setScriptExecutable(strScriptExecutable)
        if not self.__strScriptExecutable:
            self.error("No executable found for plugin %s with EDNA_SITE=%s" %
                       (self.getClassName(), EDUtilsPath.EDNA_SITE))

        strConfigSetupCCP4 = self.config.get(
            self.CONF_EXEC_PROCESS_SCRIPT_SETUP_CCP4)
        if strConfigSetupCCP4 is None:
            self.DEBUG("EDPluginExecProcessScript.configure: No configuration parameter found for: " + \
                            self.CONF_EXEC_PROCESS_SCRIPT_SETUP_CCP4 + ", NO default value!")
        else:
            self.setSetupCCP4(strConfigSetupCCP4)
        strVersion = self.config.get(
            self.CONF_EXEC_PROCESS_SCRIPT_VERSION_STRING)
        if strVersion is None:
            self.DEBUG("EDPluginExecProcessScript.configure: No configuration parameter found for: " + \
                            self.CONF_EXEC_PROCESS_SCRIPT_VERSION_STRING + ", NO default value!")
        else:
            self.setStringVersion(strVersion)

        if self.__strScriptBaseName is None:
            self.setScriptBaseName(self.getBaseName())
        if self.__strScriptFileName is None:
            self.setScriptFileName(self.__strScriptBaseName + ".sh")
        if self.__strScriptLogFileName is None:
            self.setScriptLogFileName(self.__strScriptBaseName + ".log")
        if self.__strScriptErrorLogFileName is None:
            self.setScriptErrorLogFileName(self.__strScriptBaseName + ".err")
        if self.__strScriptExecutable is not None:
            self.__strPathToHostNamePidFile = os.path.join(
                self.getWorkingDirectory(),
                os.path.basename(self.__strScriptExecutable) +
                "_hostNamePid.txt")
コード例 #16
0
    def process(self, _edObject=None):
        """
        This method starts the execution of the EDNA script using EDActionExecuteSystemCommand
        In case of failure, an error message is added to the list and the plugin fails.
        """
        EDPluginExecProcess.process(self)
        self.DEBUG("EDPluginExecProcessScript.process starting")
        self.synchronizeOn()
        if "TIMEOUT" in EDUtilsFile.readFile(self.__strPathToHostNamePidFile):
            self.error("Timeout message found in %s" %
                       self.__strPathToHostNamePidFile)
            self.hasTimedOut(True)

        bTimeOut = self.isTimeOut()
        if bTimeOut == True:
            self.DEBUG(
                "EDPluginExecProcessScript.process ========================================= ERROR! ================"
            )
            strErrorMessage = "%s execution timed out ( > %.1f s)!" % (
                self.__strScriptExecutable, float(self.getTimeOut()))
            self.error(strErrorMessage)
            self.addErrorMessage(strErrorMessage)
            self.setFailure()
            strExecutionStatus = "timeout"
            if self.isVerboseDebug():
                raise RuntimeError(strErrorMessage)
        else:
            strExecutionStatus = self.getExecutionStatus()
            # Report an error if the result is not "0" and the result is not an empty string
            if not strExecutionStatus == "0" and not strExecutionStatus == "":
                self.DEBUG(
                    "EDPluginExecProcessScript.process ========================================= ERROR! ================"
                )
                # Add any messages in the error log file (.err) to the list of error messages
                strErrorLog = self.readProcessErrorLogFile()
                if strErrorLog is None:
                    strErrorMessage = "%s execution error - status : %s" % (
                        self.getClassName(), strExecutionStatus)
                    self.error(strErrorMessage)
                    self.addErrorMessage(strErrorMessage)
                    self.setFailure()
                    if self.isVerboseDebug():
                        raise RuntimeError(strErrorMessage)
                else:
                    strErrorMessage = "%s execution error : %s" % (
                        self.getClassName(), strErrorLog)
                    self.error(strErrorMessage)
                    self.addErrorMessage(strErrorMessage)
                    self.setFailure()
                    if self.isVerboseDebug():
                        raise RuntimeError(strErrorMessage)
                # Add any messages in the log file (.log) to the list of error messages
                strLog = self.readProcessLogFile()
                if strLog is not None:
                    # Cut down the log file to the last part if it's long
                    listLogLines = strLog.split("\n")
                    if len(listLogLines
                           ) > self.__iNumberOfLastLinesFromLogFileIfError:
                        strErrorMessage = "Last part of the %s log file:" % self.__strScriptExecutable
                        self.ERROR(strErrorMessage)
                        self.addErrorMessage(strErrorMessage)
                        listLogLastLines = listLogLines[
                            -self.__iNumberOfLastLinesFromLogFileIfError:]
                        strLogLastLines = ""
                        for strLine in listLogLastLines:
                            strLogLastLines += strLine + "\n"
                        self.ERROR(strLogLastLines)
                        self.addErrorMessage(strLogLastLines)
                        strMessage = "Please inspect log file: %s" % os.path.join(
                            self.getWorkingDirectory(),
                            self.getScriptLogFileName())
                        self.ERROR(strMessage)
                        self.addErrorMessage(strMessage)
                    else:
                        strMessage = "%s log file: \n%s" % (
                            self.__strScriptExecutable, strLog)
                        self.ERROR(strMessage)
                        self.addErrorMessage(strMessage)
        #       Save the return code of the external program in the PID file
        open(self.__strPathToHostNamePidFile,
             "a").write(strExecutionStatus + os.linesep)

        self.DEBUG("EDPluginExecProcessScript.process finished ")
        self.synchronizeOff()
コード例 #17
0
 def configure(self):
     """
     Configures the plugin from the configuration file with the following parameters
      - The shell that will execute the script
      - Script executor
      - Script executable to be invoked
      - Path to CCP4 setup file if required
      - The 3rd party executable installed version
     """
     EDPluginExecProcess.configure(self)
     EDVerbose.DEBUG("EDPluginExecProcessScript.configure")
     xsPluginItem = self.getConfiguration()
     if (xsPluginItem == None):
         EDVerbose.warning("EDPluginExecProcessScript.configure: No plugin item defined.")
         xsPluginItem = XSPluginItem()
     strShell = EDConfiguration.getStringParamValue(xsPluginItem, EDPluginExecProcessScript.CONF_EXEC_PROCESS_SCRIPT_SHELL)
     if(strShell == None):
         EDVerbose.DEBUG("EDPluginExecProcessScript.configure: No configuration parameter found for: " + \
                         EDPluginExecProcessScript.CONF_EXEC_PROCESS_SCRIPT_SHELL + ", using default value: " + self.getScriptShell())
     else:
         self.setScriptShell(strShell)
     strScriptExecutor = EDConfiguration.getStringParamValue(xsPluginItem, EDPluginExecProcessScript.CONF_EXEC_PROCESS_SCRIPT_EXECUTOR)
     if(strScriptExecutor == None):
         self.setScriptExecutor(self.getScriptShell())
         EDVerbose.DEBUG("EDPluginExecProcessScript.configure: No configuration parameter found for: " + \
                         EDPluginExecProcessScript.CONF_EXEC_PROCESS_SCRIPT_EXECUTOR + ", using script shell: " + self.getScriptShell())
     else:
         self.setScriptExecutor(strScriptExecutor)
     if (self.getScriptExecutable() is None):
         strScriptExecutable = EDConfiguration.getStringParamValue(xsPluginItem, EDPluginExecProcessScript.CONF_EXEC_PROCESS_SCRIPT_EXECUTABLE)
         if(strScriptExecutable == None):
             strErrorMessage = "Configuration parameter missing: " + EDPluginExecProcessScript.CONF_EXEC_PROCESS_SCRIPT_EXECUTABLE
             EDVerbose.error(strErrorMessage)
             self.addErrorMessage(strErrorMessage)
             self.setFailure()
             if (EDVerbose.isVerboseDebug()):
                 raise RuntimeError, strErrorMessage
         else:
             # Check that the executable file exists
             if (os.path.exists(strScriptExecutable) == False):
                 strErrorMessage = "Cannot find configured " + EDPluginExecProcessScript.CONF_EXEC_PROCESS_SCRIPT_EXECUTABLE + " : " + strScriptExecutable
                 EDVerbose.error(strErrorMessage)
                 self.addErrorMessage(strErrorMessage)
                 self.setFailure()
                 if (EDVerbose.isVerboseDebug()):
                     raise RuntimeError, strErrorMessage
             else:
                 self.setScriptExecutable(strScriptExecutable)
     strConfigSetupCCP4 = EDConfiguration.getStringParamValue(xsPluginItem, EDPluginExecProcessScript.CONF_EXEC_PROCESS_SCRIPT_SETUP_CCP4)
     if(strConfigSetupCCP4 == None):
         EDVerbose.DEBUG("EDPluginExecProcessScript.configure: No configuration parameter found for: " + \
                         EDPluginExecProcessScript.CONF_EXEC_PROCESS_SCRIPT_SETUP_CCP4 + ", NO default value!")
     else:
         self.setSetupCCP4(strConfigSetupCCP4)
     strVersion = EDConfiguration.getStringParamValue(xsPluginItem, EDPluginExecProcessScript.CONF_EXEC_PROCESS_SCRIPT_VERSION_STRING)
     if(strVersion == None):
         EDVerbose.DEBUG("EDPluginExecProcessScript.configure: No configuration parameter found for: " + \
                         EDPluginExecProcessScript.CONF_EXEC_PROCESS_SCRIPT_VERSION_STRING + ", NO default value!")
     else:
         self.setStringVersion(strVersion)
     if (self.__strScriptBaseName == None):
         self.setScriptBaseName(self.getBaseName())
     if (self.__strScriptFileName == None):
         self.setScriptFileName(self.__strScriptBaseName + ".sh")
     if (self.__strScriptLogFileName == None):
         self.setScriptLogFileName(self.__strScriptBaseName + ".log")
     if (self.__strScriptErrorLogFileName == None):
         self.setScriptErrorLogFileName(self.__strScriptBaseName + ".err")
     self.__strPathToHostNamePidFile = os.path.join(self.getWorkingDirectory(), os.path.basename(self.__strScriptExecutable) + "_hostNamePid.txt")
コード例 #18
0
    def configure(self):
        """
        Configures the plugin from the configuration file with the following parameters
         - The shell that will execute the script
         - Script executor
         - Script executable to be invoked
         - Path to CCP4 setup file if required
         - The 3rd party executable installed version
        """
        EDPluginExecProcess.configure(self)
        self.DEBUG("EDPluginExecProcessScript.configure")
        strShell = self.config.get(self.CONF_EXEC_PROCESS_SCRIPT_SHELL)
        if strShell is None:
            self.DEBUG("EDPluginExecProcessScript.configure: No configuration parameter found for: " + \
                            self.CONF_EXEC_PROCESS_SCRIPT_SHELL + ", using default value: " + self.getScriptShell())
        else:
            self.setScriptShell(strShell)
        strScriptExecutor = self.config.get(self.CONF_EXEC_PROCESS_SCRIPT_EXECUTOR)
        if strScriptExecutor is None:
            self.setScriptExecutor(self.getScriptShell())
            self.DEBUG("EDPluginExecProcessScript.configure: No configuration parameter found for: " + \
                            self.CONF_EXEC_PROCESS_SCRIPT_EXECUTOR + ", using script shell: " + self.getScriptShell())
        else:
            self.setScriptExecutor(strScriptExecutor)
        if self.__strScriptExecutable is None:
            strScriptExecutable = self.config.get(self.CONF_EXEC_PROCESS_SCRIPT_EXECUTABLE)
            if strScriptExecutable is None:
                strErrorMessage = "Configuration parameter %s missing for plugin %s with EDNA_SITE=%s" % \
                                    (self.CONF_EXEC_PROCESS_SCRIPT_EXECUTABLE, \
                                      self.getPluginName(), EDUtilsPath.EDNA_SITE)
                self.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                self.setFailure()
                if self.isVerboseDebug():
                    raise RuntimeError, strErrorMessage
            else:
                # Check that the executable file exists
                if not os.path.exists(strScriptExecutable):
                    strErrorMessage = "Cannot find configured executable %s: %s for plugin %s with EDNA_SITE=%s" % \
                                    (self.CONF_EXEC_PROCESS_SCRIPT_EXECUTABLE, strScriptExecutable, \
                                      self.getPluginName(), EDUtilsPath.EDNA_SITE)
                    self.error(strErrorMessage)
                    self.addErrorMessage(strErrorMessage)
                    self.setFailure()
                    if self.isVerboseDebug():
                        raise RuntimeError, strErrorMessage
                else:
                    self.setScriptExecutable(strScriptExecutable)
        if not self.__strScriptExecutable:
            self.error("No executable found for plugin %s with EDNA_SITE=%s" % (self.getClassName(), EDUtilsPath.EDNA_SITE))

        strConfigSetupCCP4 = self.config.get(self.CONF_EXEC_PROCESS_SCRIPT_SETUP_CCP4)
        if strConfigSetupCCP4 is None:
            self.DEBUG("EDPluginExecProcessScript.configure: No configuration parameter found for: " + \
                            self.CONF_EXEC_PROCESS_SCRIPT_SETUP_CCP4 + ", NO default value!")
        else:
            self.setSetupCCP4(strConfigSetupCCP4)
        strVersion = self.config.get(self.CONF_EXEC_PROCESS_SCRIPT_VERSION_STRING)
        if strVersion is None:
            self.DEBUG("EDPluginExecProcessScript.configure: No configuration parameter found for: " + \
                            self.CONF_EXEC_PROCESS_SCRIPT_VERSION_STRING + ", NO default value!")
        else:
            self.setStringVersion(strVersion)

        if self.__strScriptBaseName is None:
            self.setScriptBaseName(self.getBaseName())
        if self.__strScriptFileName is None:
            self.setScriptFileName(self.__strScriptBaseName + ".sh")
        if self.__strScriptLogFileName is None:
            self.setScriptLogFileName(self.__strScriptBaseName + ".log")
        if self.__strScriptErrorLogFileName is None:
            self.setScriptErrorLogFileName(self.__strScriptBaseName + ".err")
        if self.__strScriptExecutable is not None:
            self.__strPathToHostNamePidFile = os.path.join(self.getWorkingDirectory(), os.path.basename(self.__strScriptExecutable) + "_hostNamePid.txt")
コード例 #19
0
    def process(self, _edObject=None):
        """
        This method starts the execution of the EDNA script using EDActionExecuteSystemCommand
        In case of failure, an error message is added to the list and the plugin fails.
        """
        EDPluginExecProcess.process(self)
        self.DEBUG("EDPluginExecProcessScript.process starting")
        self.synchronizeOn()
        if "TIMEOUT" in EDUtilsFile.readFile(self.__strPathToHostNamePidFile):
            self.error("Timeout message found in %s" % self.__strPathToHostNamePidFile)
            self.hasTimedOut(True)

        bTimeOut = self.isTimeOut()
        if bTimeOut == True:
            self.DEBUG("EDPluginExecProcessScript.process ========================================= ERROR! ================")
            strErrorMessage = "%s execution timed out ( > %.1f s)!" % (self.__strScriptExecutable, float(self.getTimeOut()))
            self.error(strErrorMessage)
            self.addErrorMessage(strErrorMessage)
            self.setFailure()
            strExecutionStatus = "timeout"
            if self.isVerboseDebug():
                raise RuntimeError(strErrorMessage)
        else:
            strExecutionStatus = self.getExecutionStatus()
            # Report an error if the result is not "0" and the result is not an empty string
            if not strExecutionStatus == "0" and not strExecutionStatus == "":
                self.DEBUG("EDPluginExecProcessScript.process ========================================= ERROR! ================")
                # Add any messages in the error log file (.err) to the list of error messages
                strErrorLog = self.readProcessErrorLogFile()
                if strErrorLog is None:
                    strErrorMessage = "%s execution error - status : %s" % (self.getClassName(), strExecutionStatus)
                    self.error(strErrorMessage)
                    self.addErrorMessage(strErrorMessage)
                    self.setFailure()
                    if self.isVerboseDebug():
                        raise RuntimeError(strErrorMessage)
                else:
                    strErrorMessage = "%s execution error : %s" % (self.getClassName(), strErrorLog)
                    self.error(strErrorMessage)
                    self.addErrorMessage(strErrorMessage)
                    self.setFailure()
                    if self.isVerboseDebug():
                        raise RuntimeError(strErrorMessage)
                # Add any messages in the log file (.log) to the list of error messages
                strLog = self.readProcessLogFile()
                if strLog is not None:
                    # Cut down the log file to the last part if it's long
                    listLogLines = strLog.split("\n")
                    if len(listLogLines) > self.__iNumberOfLastLinesFromLogFileIfError:
                        strErrorMessage = "Last part of the %s log file:" % self.__strScriptExecutable
                        self.ERROR(strErrorMessage)
                        self.addErrorMessage(strErrorMessage)
                        listLogLastLines = listLogLines[-self.__iNumberOfLastLinesFromLogFileIfError:]
                        strLogLastLines = ""
                        for strLine in listLogLastLines:
                            strLogLastLines += strLine + "\n"
                        self.ERROR(strLogLastLines)
                        self.addErrorMessage(strLogLastLines)
                        strMessage = "Please inspect log file: %s" % os.path.join(self.getWorkingDirectory(), self.getScriptLogFileName())
                        self.ERROR(strMessage)
                        self.addErrorMessage(strMessage)
                    else:
                        strMessage = "%s log file: \n%s" % (self.__strScriptExecutable, strLog)
                        self.ERROR(strMessage)
                        self.addErrorMessage(strMessage)
        #       Save the return code of the external program in the PID file
        open(self.__strPathToHostNamePidFile, "a").write(strExecutionStatus + os.linesep)

        self.DEBUG("EDPluginExecProcessScript.process finished ")
        self.synchronizeOff()