def createDataCollectionFromImageHeaders(self, _edPlugin): """ This method creates a list of XSDataSubwedges by reading the header of the images given as a list of paths as input. """ self.DEBUG( "EDPluginControlSubWedgeAssemblev1_1.createDataCollectionFromImageHeaders" ) xsDataInputSubWedgeAssemble = _edPlugin.getDataInput() listXSDataFile = xsDataInputSubWedgeAssemble.getFile() if (len(listXSDataFile) > 0): listSubWedge = [] iIndex = 1 for xsDataFile in listXSDataFile: xsDataFileCopy = XSDataFile.parseString(xsDataFile.marshal()) xsDataInputReadImageHeader = XSDataInputReadImageHeader() xsDataInputReadImageHeader.setImage(xsDataFileCopy) self.__edPluginReadImageHeader = self.loadPlugin( self.__strPluginReadImageHeaderName, "ReadImageHeader_%d" % (iIndex)) self.__edPluginReadImageHeader.setDataInput( xsDataInputReadImageHeader) self.__edPluginReadImageHeader.executeSynchronous() xsDataResultReadImageHeader = self.__edPluginReadImageHeader.getDataOutput( ) bSuccess = False if (xsDataResultReadImageHeader is not None): xsDataSubWedge = xsDataResultReadImageHeader.getSubWedge() if (xsDataSubWedge is not None): xsDataSubWedge.setSubWedgeNumber(XSDataInteger(iIndex)) listSubWedge.append(xsDataSubWedge) bSuccess = True if (not bSuccess): # Fix for bug #223: raise an error if an image could not be read strErrorMessage = "EDPluginControlSubWedgeAssemblev1_1.createDataCollectionFromImageHeaders: %s %s" % ( self.__strPluginReadImageHeaderName, \ "Could not read header from image %s" % xsDataFileCopy.getPath().getValue()) self.error(strErrorMessage) self.addErrorMessage(strErrorMessage) self.setFailure() iIndex += 1 if (not self.isFailure()): xsDataInputSubWedgeMerge = XSDataInputSubWedgeMerge() for xsDataSubWedge in listSubWedge: xsDataInputSubWedgeMerge.addSubWedge(xsDataSubWedge) self.__edPluginSubWedgeMerge.setDataInput( xsDataInputSubWedgeMerge) self.__edPluginSubWedgeMerge.executeSynchronous()
def createDataCollectionFromImageHeaders(self, _edPlugin): """ This method creates a list of XSDataSubwedges by reading the header of the images given as a list of paths as input. """ EDVerbose.DEBUG("EDPluginControlSubWedgeAssemblev10.createDataCollectionFromImageHeaders") xsDataInputSubWedgeAssemble = _edPlugin.getDataInput() listXSDataFile = xsDataInputSubWedgeAssemble.getFile() if (len(listXSDataFile) > 0): listSubWedge = [] iIndex = 1 for xsDataFile in listXSDataFile: xsDataFileCopy = XSDataFile.parseString(xsDataFile.marshal()) xsDataInputReadImageHeader = XSDataInputReadImageHeader() xsDataInputReadImageHeader.setImage(xsDataFileCopy) self.__edPluginReadImageHeader = self.loadPlugin(self.__strPluginReadImageHeaderName, "ReadImageHeader_%d" % (iIndex)) self.__edPluginReadImageHeader.setDataInput(xsDataInputReadImageHeader) self.__edPluginReadImageHeader.executeSynchronous() xsDataResultReadImageHeader = self.__edPluginReadImageHeader.getDataOutput() xsDataSubWedge = xsDataResultReadImageHeader.getSubWedge() if (xsDataSubWedge is None): # Fix for bug #223: raise an error if an image could not be read errorMessage = EDMessage.ERROR_EXECUTION_03 % ("EDPluginControlSubWedgeAssemblev10.createDataCollectionFromImageHeaders", \ self.__strPluginReadImageHeaderName, \ "Could not read header from image %s" % xsDataFileCopy.getPath().getValue()) EDVerbose.error(errorMessage) self.addErrorMessage(errorMessage) raise RuntimeError, errorMessage else: listSubWedge.append(xsDataSubWedge) iIndex += 1 xsDataInputSubWedgeMerge = XSDataInputSubWedgeMerge() for xsDataSubWedge in listSubWedge: xsDataInputSubWedgeMerge.addSubWedge(xsDataSubWedge) self.__edPluginSubWedgeMerge.setDataInput(xsDataInputSubWedgeMerge) self.__edPluginSubWedgeMerge.executeSynchronous()