Example #1
0
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginWaitMultiFile.process  global time-out is set to: %s (default value)" % (self.getTimeOut()))
        self.setTimeInit()
################################################################################
# Initialize the accumulator with the query
################################################################################
        xsdiAccumulator = XSDataInputAccumulator()
        xsdQuery = XSDataQuery()
        xsdQuery.setRemoveItems(XSDataBoolean(1))
        xsdQuery.setItem(self.listXsdStrings)
        xsdiAccumulator.setQuery([xsdQuery])
        edPluginAccumulator = self.loadPlugin(self.__strControlledPluginAccumulator)
        edPluginAccumulator.setDataInput(xsdiAccumulator)
        edPluginAccumulator.connectSUCCESS(self.doSuccessAccumulator)
        edPluginAccumulator.connectFAILURE(self.doFailureAccumulator)
        edPluginAccumulator.execute()

        for oneXSDImage in self.listXsdFiles:
            xsdiWaitFile = XSDataInputWaitFile()
            xsdiWaitFile.setExpectedFile(oneXSDImage)
            xsdiWaitFile.setExpectedSize(self.dataInput.expectedSize)
            xsdiWaitFile.setTimeOut(self.dataInput.timeOut)
            edPluginWaitFile = self.loadPlugin(self.__strControlledPluginWaitFile)
            edPluginWaitFile.setDataInput(xsdiWaitFile)
            edPluginWaitFile.connectSUCCESS(self.doSuccessWaitFile)
            edPluginWaitFile.connectFAILURE(self.doFailureWaitFile)
            edPluginWaitFile.execute()
 def testFlush(self):
     xsDataInput = XSDataInputAccumulator()
     xsDataInput.setFlush(XSDataBoolean(True))
     edPluginAccumulator = self.createPlugin()
     edPluginAccumulator.emptyItems()
     edPluginAccumulator.emptyQueries()
     edPluginAccumulator.addItem("data1")
     edPluginAccumulator.addItem("data2")
     edPluginAccumulator.addItem("data3")
     edPluginAccumulator.addItem("data4")
     edPluginAccumulator.addItem("data3")
     EDAssert.equal(edPluginAccumulator.getItems(),
                    ["data1", "data2", "data3", "data4", "data3"],
                    "Artificial item feed")
     edPluginAccumulator.setDataInput(xsDataInput)
     edPluginAccumulator.checkParameters()
     edPluginAccumulator.preProcess()
     edPluginAccumulator.process()
     edPluginAccumulator.postProcess()
     EDAssert.equal(edPluginAccumulator.getItems(), [],
                    "Empty item list after Flush")
     if "query" in edPluginAccumulator.getDataOutput().__dict__:
         #            print "Old datamodel"
         myQuery = edPluginAccumulator.getDataOutput(
         ).__dict__["query"][0].__dict__['item']
     else:
         myQuery = edPluginAccumulator.getDataOutput(
         ).__dict__["_XSDataResultAccumulator__query"][0].__dict__[
             '_XSDataQuery__item']
     EDAssert.equal(len(myQuery), 5, "We expect 5 items as output")
Example #3
0
 def doSuccessWaitFile(self, _edPlugin=None):
     with self.locked():
         self.DEBUG("EDPluginWaitMultiFile.doSuccessWaitFile")
         self.retrieveSuccessMessages(
             _edPlugin, "EDPluginWaitMultiFile.doSuccessWaitFile")
         xsdFile = _edPlugin.dataOutput.actualFile
         if _edPlugin.dataOutput.getActualSize() is None:
             self.WARNING("Wait for file %s finished in timeout!" %
                          _edPlugin.dataInput.expectedFile.path.value)
             self.DEBUG("Please check why XSDataResultWaitFile is:\n%s" %
                        _edPlugin.dataOutput.marshal())
             self.DEBUG(
                 "This usually happens when EDPluginWaitFile has no configuration file or EDNA_SITE is undefined"
             )
             self.setFailure()
         else:
             self.__filesize.append(_edPlugin.dataOutput.actualSize.value)
             if _edPlugin.dataOutput.timedOut.value:
                 self.__bAnyTimeOut = True
             if xsdFile is not None:
                 xsdiAccumulator = XSDataInputAccumulator()
                 xsdiAccumulator.setItem([xsdFile.path
                                          ])  #Mandatory to be a list !!!
                 edPluginAccumulator = self.loadPlugin(
                     self.__strControlledPluginAccumulator)
                 edPluginAccumulator.setDataInput(xsdiAccumulator)
                 edPluginAccumulator.connectSUCCESS(
                     self.doSuccessAccumulator)
                 edPluginAccumulator.connectFAILURE(
                     self.doFailureAccumulator)
                 edPluginAccumulator.execute()
 def preProcess(self):
     """
     PreProcess of the execution test: download an EDF file from http://www.edna-site.org
     """
     EDTestCasePluginExecuteControlMedianFilterImagev1_0.preProcess(self)
     self.loadTestImage([ "noise2.edf", "noise3.edf", "noise4.edf", "noise5.edf", "noise6.edf"])
     acc = EDFactoryPluginStatic.loadPlugin("EDPluginAccumulatorv1_0")
     xsdIn = XSDataInputAccumulator()
     xsdIn.setItem([XSDataString(os.path.join(self.getTestsDataImagesHome(), "noise%i.edf" % i)) for i in [2, 3, 5, 6]])
     acc.setDataInput(xsdIn)
     acc.executeSynchronous()
 def preProcess(self, _edObject=None):
     EDPluginControl.preProcess(self)
     self.DEBUG("EDPluginControlMedianFilterImagev1_0.preProcess")
     # Load the execution plugin
     self.__edPluginExecAccumulator = self.loadPlugin(self.__strControlledPluginAccumulator)
     self.image = os.path.abspath(self.getDataInput().getInputImage().getPath().getValue())
     self.width = self.getDataInput().getFilterWidth().getValue()
     if self.getDataInput().getMedianFilteredImage() is not None:
         self.outputImage = os.path.abspath(self.getDataInput().getMedianFilteredImage().getPath().getValue())
     xsdAcc = XSDataInputAccumulator()
     xsdAcc.setQuery([self.prepareQuery(self.image, self.width)])
     xsdAcc.setItem([XSDataString(self.image)])
     self.__edPluginExecAccumulator.setDataInput(xsdAcc)
 def preProcess(self):
     """
     PreProcess of the execution test: download an EDF file from http://www.edna-site.org
     """
     EDTestCasePluginExecuteControlMedianFilterImagev1_0.preProcess(self)
     self.loadTestImage([
         "noise2.edf", "noise3.edf", "noise4.edf", "noise5.edf",
         "noise6.edf"
     ])
     acc = EDFactoryPluginStatic.loadPlugin("EDPluginAccumulatorv1_0")
     xsdIn = XSDataInputAccumulator()
     xsdIn.setItem([
         XSDataString(
             os.path.join(self.getTestsDataImagesHome(), "noise%i.edf" % i))
         for i in [2, 3, 5, 6]
     ])
     acc.setDataInput(xsdIn)
     acc.executeSynchronous()
Example #7
0
 def doSuccessWaitFile(self, _edPlugin=None):
     with self.locked():
         self.DEBUG("EDPluginWaitMultiFile.doSuccessWaitFile")
         self.retrieveSuccessMessages(_edPlugin, "EDPluginWaitMultiFile.doSuccessWaitFile")
         xsdFile = _edPlugin.dataOutput.actualFile
         if _edPlugin.dataOutput.getActualSize() is None:
             self.WARNING("Wait for file %s finished in timeout!" % _edPlugin.dataInput.expectedFile.path.value)
             self.DEBUG("Please check why XSDataResultWaitFile is:\n%s" % _edPlugin.dataOutput.marshal())
             self.DEBUG("This usually happens when EDPluginWaitFile has no configuration file or EDNA_SITE is undefined")
             self.setFailure()
         else:
             self.__filesize.append(_edPlugin.dataOutput.actualSize.value)
             if _edPlugin.dataOutput.timedOut.value:
                 self.__bAnyTimeOut = True
             if xsdFile is not None:
                 xsdiAccumulator = XSDataInputAccumulator()
                 xsdiAccumulator.setItem([xsdFile.path]) #Mandatory to be a list !!!
                 edPluginAccumulator = self.loadPlugin(self.__strControlledPluginAccumulator)
                 edPluginAccumulator.setDataInput(xsdiAccumulator)
                 edPluginAccumulator.connectSUCCESS(self.doSuccessAccumulator)
                 edPluginAccumulator.connectFAILURE(self.doFailureAccumulator)
                 edPluginAccumulator.execute()
    def testFlush(self):
        xsDataInput = XSDataInputAccumulator()
        xsDataInput.setFlush(XSDataBoolean(True))
        edPluginAccumulator = self.createPlugin()
        edPluginAccumulator.emptyItems()
        edPluginAccumulator.emptyQueries()
        edPluginAccumulator.addItem("data1")
        edPluginAccumulator.addItem("data2")
        edPluginAccumulator.addItem("data3")
        edPluginAccumulator.addItem("data4")
        edPluginAccumulator.addItem("data3")
        EDAssert.equal(edPluginAccumulator.getItems(), ["data1", "data2", "data3", "data4", "data3"], "Artificial item feed")
        edPluginAccumulator.setDataInput(xsDataInput)
        edPluginAccumulator.checkParameters()
        edPluginAccumulator.preProcess()
        edPluginAccumulator.process()
        edPluginAccumulator.postProcess()
        EDAssert.equal(edPluginAccumulator.getItems(), [], "Empty item list after Flush")
        if "query" in  edPluginAccumulator.getDataOutput().__dict__:
#            print "Old datamodel"
            myQuery = edPluginAccumulator.getDataOutput().__dict__["query"][0].__dict__['item']
        else:
            myQuery = edPluginAccumulator.getDataOutput().__dict__["_XSDataResultAccumulator__query"][0].__dict__['_XSDataQuery__item']
        EDAssert.equal(len(myQuery), 5, "We expect 5 items as output")
Example #9
0
 def preProcess(self, _edObject=None):
     EDPluginControl.preProcess(self)
     self.DEBUG("EDPluginControlMedianFilterImagev1_0.preProcess")
     # Load the execution plugin
     self.__edPluginExecAccumulator = self.loadPlugin(
         self.__strControlledPluginAccumulator)
     self.image = os.path.abspath(
         self.getDataInput().getInputImage().getPath().getValue())
     self.width = self.getDataInput().getFilterWidth().getValue()
     if self.getDataInput().getMedianFilteredImage() is not None:
         self.outputImage = os.path.abspath(self.getDataInput(
         ).getMedianFilteredImage().getPath().getValue())
     xsdAcc = XSDataInputAccumulator()
     xsdAcc.setQuery([self.prepareQuery(self.image, self.width)])
     xsdAcc.setItem([XSDataString(self.image)])
     self.__edPluginExecAccumulator.setDataInput(xsdAcc)
Example #10
0
    def doSuccessExecMeasureOffset(self, _edPlugin=None):
        with self.semMeasure:
            self.DEBUG(
                "EDPluginControlAlignStackv1_0.doSuccessExecMeasureOffset")
            self.retrieveSuccessMessages(
                _edPlugin,
                "EDPluginControlAlignStackv1_0.doSuccessExecMeasureOffset")
            listIndex = [i.getValue() for i in _edPlugin.dataInput.index]
            listIndex.sort()
            dataOutput = _edPlugin.dataOutput
            if self.bAlwaysMOvsRef:
                if min(listIndex) < EDPluginControlAlignStackv1_0.__iRefFrame:
                    iToShift, iRef = tuple(listIndex)
                    EDPluginControlAlignStackv1_0.__dictAbsShift[
                        iToShift] = tuple(
                            [-i.getValue() for i in dataOutput.getOffset()])
                else:
                    iRef, iToShift = tuple(listIndex)
                    EDPluginControlAlignStackv1_0.__dictAbsShift[
                        iToShift] = tuple(
                            [i.getValue() for i in dataOutput.getOffset()])
                self.screen(
                    "Frame number %i has absolute offset of %.3f,%.3f" %
                    (iToShift,
                     EDPluginControlAlignStackv1_0.__dictAbsShift[iToShift][0],
                     EDPluginControlAlignStackv1_0.__dictAbsShift[iToShift][1])
                )
                edPluginExecShift = self.loadPlugin(
                    self.__strControlledPluginShift)
                xsdata = XSDataInputShiftImage(
                    index=XSDataInteger(iToShift),
                    offset=[
                        XSDataDouble(i) for i in
                        EDPluginControlAlignStackv1_0.__dictAbsShift[iToShift]
                    ],
                    inputImage=self.getFrameRef(iToShift),
                    outputImage=XSDataImageExt(
                        shared=XSDataString("Shifted-%06i" % iToShift)))
                edPluginExecShift.setDataInput(xsdata)
                edPluginExecShift.connectSUCCESS(self.doSuccessExecShiftImage)
                edPluginExecShift.connectFAILURE(self.doFailureExecShiftImage)
                self.queue.put(edPluginExecShift)
            else:
                if min(listIndex) < EDPluginControlAlignStackv1_0.__iRefFrame:

                    iToShift, iRef = tuple(listIndex)
                    EDPluginControlAlignStackv1_0.__dictRelShift[
                        iToShift] = tuple(
                            [-i.value for i in dataOutput.offset])
                else:
                    iRef, iToShift = tuple(listIndex)
                    EDPluginControlAlignStackv1_0.__dictRelShift[
                        iToShift] = tuple([i.value for i in dataOutput.offset])
                self.screen(
                    "Frame number %i has relative offset of %.3f,%.3f" %
                    (iToShift,
                     EDPluginControlAlignStackv1_0.__dictRelShift[iToShift][0],
                     EDPluginControlAlignStackv1_0.__dictRelShift[iToShift][1])
                )

                xsdata = XSDataInputAccumulator(
                    item=[XSDataString("shift %04i" % iToShift)])
                edPluginExecAccumulator = self.loadPlugin(
                    self.__strControlledPluginAccumulator)
                edPluginExecAccumulator.setDataInput(xsdata)
                edPluginExecAccumulator.connectSUCCESS(
                    self.doSuccessExecAccumultor)
                edPluginExecAccumulator.connectFAILURE(
                    self.doFailureExecAccumulator)
                self.queue.put(edPluginExecAccumulator)
Example #11
0
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginControlAlignStackv1_0.process")

        for iFrame in self.iFrames:
            edPluginExecAccumulator = self.loadPlugin(
                self.__strControlledPluginAccumulator)
            queryRaw = XSDataQuery()
            queryShift = XSDataQuery()
            queryRaw.setRemoveItems(XSDataBoolean(False))
            queryShift.setRemoveItems(XSDataBoolean(False))
            xsdataAcc = XSDataInputAccumulator()
            if (EDPluginControlAlignStackv1_0.__iRefFrame
                    == iFrame) or (self.bDoAlign == False):
                EDPluginControlAlignStackv1_0.__dictAbsShift[iFrame] = (0.0,
                                                                        0.0)
                EDPluginControlAlignStackv1_0.__dictRelShift[iFrame] = (0.0,
                                                                        0.0)
                self.hdf5_offset(index=iFrame, offset=[0.0, 0.0])
                edPluginExecShift = self.loadPlugin(
                    self.__strControlledPluginShift)
                xsdata = XSDataInputShiftImage(
                    index=XSDataInteger(iFrame),
                    offset=[
                        XSDataDouble(i) for i in
                        EDPluginControlAlignStackv1_0.__dictAbsShift[iFrame]
                    ],
                    inputImage=self.getFrameRef(iFrame),
                    outputImage=XSDataImageExt(
                        shared=XSDataString("Shifted-%06i" % iFrame)))
                edPluginExecShift.setDataInput(xsdata)
                edPluginExecShift.connectSUCCESS(self.doSuccessExecShiftImage)
                edPluginExecShift.connectFAILURE(self.doFailureExecShiftImage)
                self.queue.put(edPluginExecShift)
                if (self.bDoAlign == False):
                    self.executeControlledPlugins()
                    return

            elif EDPluginControlAlignStackv1_0.__iRefFrame < iFrame:
                if self.bAlwaysMOvsRef:
                    queryRaw.setItem([
                        XSDataString(
                            "raw %04i" %
                            (EDPluginControlAlignStackv1_0.__iRefFrame)),
                        XSDataString("raw %04i" % iFrame)
                    ])
                    xsdataAcc.setQuery([queryRaw])
                else:
                    queryRaw.setItem([
                        XSDataString("raw %04i" % (iFrame - 1)),
                        XSDataString("raw %04i" % iFrame)
                    ])
                    queryShift.setItem([
                        XSDataString("shift %04i" % i) for i in range(
                            EDPluginControlAlignStackv1_0.__iRefFrame +
                            1, iFrame + 1)
                    ])
                    xsdataAcc.setQuery([queryRaw, queryShift])
            elif EDPluginControlAlignStackv1_0.__iRefFrame > iFrame:
                if self.bAlwaysMOvsRef:
                    queryRaw.setItem([
                        XSDataString("raw %04i" % iFrame),
                        XSDataString(
                            "raw %04i" %
                            (EDPluginControlAlignStackv1_0.__iRefFrame))
                    ])
                    xsdataAcc.setQuery([queryRaw])
                else:
                    queryRaw.setItem([
                        XSDataString("raw %04i" % (iFrame + 1)),
                        XSDataString("raw %04i" % iFrame)
                    ])
                    queryShift.setItem([
                        XSDataString("shift %04i" % i) for i in range(
                            EDPluginControlAlignStackv1_0.__iRefFrame -
                            1, iFrame - 1, -1)
                    ])
                    xsdataAcc.setQuery([queryRaw, queryShift])
            if (EDPluginControlAlignStackv1_0.__iRefFrame == iFrame):
                self.saveReferenceFrame(iFrame)

            xsdataAcc.setItem([XSDataString("raw %04i" % iFrame)])
            edPluginExecAccumulator.setDataInput(xsdataAcc)
            edPluginExecAccumulator.connectSUCCESS(
                self.doSuccessExecAccumultor)
            edPluginExecAccumulator.connectFAILURE(
                self.doFailureExecAccumulator)
            self.queue.put(edPluginExecAccumulator)
        self.executeControlledPlugins()
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginControlAlignStackv1_0.process")

        for iFrame in self.iFrames:
            edPluginExecAccumulator = self.loadPlugin(self.__strControlledPluginAccumulator)
            queryRaw = XSDataQuery()
            queryShift = XSDataQuery()
            queryRaw.setRemoveItems(XSDataBoolean(False))
            queryShift.setRemoveItems(XSDataBoolean(False))
            xsdataAcc = XSDataInputAccumulator()
            if  (EDPluginControlAlignStackv1_0.__iRefFrame == iFrame) or (self.bDoAlign == False) :
                EDPluginControlAlignStackv1_0.__dictAbsShift[iFrame] = (0.0, 0.0)
                EDPluginControlAlignStackv1_0.__dictRelShift[iFrame] = (0.0, 0.0)
                self.hdf5_offset(index=iFrame, offset=[0.0, 0.0])
                edPluginExecShift = self.loadPlugin(self.__strControlledPluginShift)
                xsdata = XSDataInputShiftImage(index=XSDataInteger(iFrame),
                                               offset=[XSDataDouble(i) for i in EDPluginControlAlignStackv1_0.__dictAbsShift[iFrame]],
                                               inputImage=self.getFrameRef(iFrame),
                                               outputImage=XSDataImageExt(shared=XSDataString("Shifted-%06i" % iFrame)))
                edPluginExecShift.setDataInput(xsdata)
                edPluginExecShift.connectSUCCESS(self.doSuccessExecShiftImage)
                edPluginExecShift.connectFAILURE(self.doFailureExecShiftImage)
                self.queue.put(edPluginExecShift)
                if (self.bDoAlign == False):
                    self.executeControlledPlugins()
                    return

            elif EDPluginControlAlignStackv1_0.__iRefFrame < iFrame:
                if self.bAlwaysMOvsRef:
                    queryRaw.setItem([XSDataString("raw %04i" % (EDPluginControlAlignStackv1_0.__iRefFrame)), XSDataString("raw %04i" % iFrame)])
                    xsdataAcc.setQuery([queryRaw])
                else:
                    queryRaw.setItem([XSDataString("raw %04i" % (iFrame - 1)), XSDataString("raw %04i" % iFrame)])
                    queryShift.setItem([XSDataString("shift %04i" % i) for i in range(EDPluginControlAlignStackv1_0.__iRefFrame + 1, iFrame + 1)])
                    xsdataAcc.setQuery([queryRaw, queryShift])
            elif EDPluginControlAlignStackv1_0.__iRefFrame > iFrame:
                if self.bAlwaysMOvsRef:
                    queryRaw.setItem([ XSDataString("raw %04i" % iFrame), XSDataString("raw %04i" % (EDPluginControlAlignStackv1_0.__iRefFrame))])
                    xsdataAcc.setQuery([queryRaw])
                else:
                    queryRaw.setItem([XSDataString("raw %04i" % (iFrame + 1)), XSDataString("raw %04i" % iFrame)])
                    queryShift.setItem([XSDataString("shift %04i" % i) for i in range(EDPluginControlAlignStackv1_0.__iRefFrame - 1, iFrame - 1, -1)])
                    xsdataAcc.setQuery([queryRaw, queryShift])
            if (EDPluginControlAlignStackv1_0.__iRefFrame == iFrame):
                self.saveReferenceFrame(iFrame)

            xsdataAcc.setItem([XSDataString("raw %04i" % iFrame)])
            edPluginExecAccumulator.setDataInput(xsdataAcc)
            edPluginExecAccumulator.connectSUCCESS(self.doSuccessExecAccumultor)
            edPluginExecAccumulator.connectFAILURE(self.doFailureExecAccumulator)
            self.queue.put(edPluginExecAccumulator)
        self.executeControlledPlugins()
 def testCheckParameters(self):
     xsDataInput = XSDataInputAccumulator()
     edPluginAccumulator = self.createPlugin()
     edPluginAccumulator.setDataInput(xsDataInput)
     edPluginAccumulator.checkParameters()