Beispiel #1
0
    def testExecute(self):
        """
        execute the execution test 
        """
        self.run()
        # Checks the expected result
        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
        strObtainedOutput = self.readAndParseFile (self.m_edObtainedOutputDataFile)
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultExecCommandLine.parseString(strExpectedOutput)
        xsDataResultObtained = XSDataResultExecCommandLine.parseString(strObtainedOutput)

        EDAssert.equal(xsDataResultReference.marshal(), xsDataResultObtained.marshal())
    def postProcess(self, _edObject=None):
        """
        Post-Process: set the output of the plugin
        """
        EDPluginExecProcessScript.postProcess(self)
        self.DEBUG("EDPluginExecCommandLinev10.postProcess")

        # Create some output data
        xsDataResult = XSDataResultExecCommandLine()
        if self.dataInput.getFireAndForget() is not None:
            if self.dataInput.getFireAndForget().value is True:
                self.setDataOutput(xsDataResult)
                return
        if self.dataInput.getOutfileFromStdout() is not None:
            #self.DEBUG("*** getOutfileFromStdout = %s" % self.dataInput.getOutfileFromStdout().value)
            if self.dataInput.getOutfileFromStdout().value : # this is not clean ... should be 1 or True ... or whatever
                if self.dataInput.getOutputPath() is not None:
                    outputPath = self.dataInput.getOutputPath().path.value
                    stdout = os.path.join(self.getWorkingDirectory() , self.getScriptLogFileName())

                    self.synchronizeOn()
                    if os.path.isdir(outputPath):
                        outfile = os.path.join(outputPath, os.path.split(self.dataInput.inputFileName.path.value)[1])
                    else:
                        outfile = outputPath
                    if os.path.isfile(outfile):
                            takenNames = []
                            [mydir, myname] = os.path.split(outfile)
                            for onefile in os.listdir(mydir):
                                if onefile.find(myname) == 0:
                                    takenNames.append(onefile)
                            for ext in string.digits + string.ascii_lowercase:
                                if not (outfile + ext) in takenNames:
                                    outfile += ext
                                    break
                    shutil.move(stdout , outfile)
                    self.synchronizeOff()

                    xsDataFile = XSDataFile()
                    xsDataFile.setPath(XSDataString(outfile))
                    xsDataResult.setOutputFilename(xsDataFile)
                else:
                    xsDataResult.setOutputFilename(self.getScriptLogFileName())
        self.setDataOutput(xsDataResult)
Beispiel #3
0
 def preProcess(self):
     """
     PreProcess of the execution test: download an EDF file from http://www.edna-site.org
     and remove any existing output file, i.e. /tmp/diff6105.edf 
     """
     EDTestCasePluginExecute.preProcess(self)
     self.loadTestImage([ "test_region1_dark_1_0041.edf"])
     strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
     xsDataResultReference = XSDataResultExecCommandLine.parseString(strExpectedOutput)
     outputFileName = xsDataResultReference.getOutputFilename().getPath().getValue()
     EDVerbose.DEBUG(" Output file is %s" % outputFileName)
     if os.path.isfile(outputFileName):
         EDVerbose.DEBUG(" Output file exists %s, I will remove it" % outputFileName)
         os.remove(outputFileName)
     outputDirName = os.path.dirname(outputFileName)
     if not os.path.isdir(outputDirName):
         os.makedirs(outputDirName, int("777", 8))
Beispiel #4
0
    def postProcess(self, _edObject=None):
        """
        Post-Process: set the output of the plugin
        """
        EDPluginExecProcessScript.postProcess(self)
        self.DEBUG("EDPluginExecCommandLinev10.postProcess")

        # Create some output data
        xsDataResult = XSDataResultExecCommandLine()
        if self.dataInput.getFireAndForget() is not None:
            if self.dataInput.getFireAndForget().value is True:
                self.setDataOutput(xsDataResult)
                return
        if self.dataInput.getOutfileFromStdout() is not None:
            #self.DEBUG("*** getOutfileFromStdout = %s" % self.dataInput.getOutfileFromStdout().value)
            if self.dataInput.getOutfileFromStdout(
            ).value:  # this is not clean ... should be 1 or True ... or whatever
                if self.dataInput.getOutputPath() is not None:
                    outputPath = self.dataInput.getOutputPath().path.value
                    stdout = os.path.join(self.getWorkingDirectory(),
                                          self.getScriptLogFileName())

                    self.synchronizeOn()
                    if os.path.isdir(outputPath):
                        outfile = os.path.join(
                            outputPath,
                            os.path.split(
                                self.dataInput.inputFileName.path.value)[1])
                    else:
                        outfile = outputPath
                    if os.path.isfile(outfile):
                        takenNames = []
                        [mydir, myname] = os.path.split(outfile)
                        for onefile in os.listdir(mydir):
                            if onefile.find(myname) == 0:
                                takenNames.append(onefile)
                        for ext in string.digits + string.ascii_lowercase:
                            if not (outfile + ext) in takenNames:
                                outfile += ext
                                break
                    shutil.move(stdout, outfile)
                    self.synchronizeOff()

                    xsDataFile = XSDataFile()
                    xsDataFile.setPath(XSDataString(outfile))
                    xsDataResult.setOutputFilename(xsDataFile)
                else:
                    xsDataResult.setOutputFilename(self.getScriptLogFileName())
        self.setDataOutput(xsDataResult)