Ejemplo n.º 1
0
        def makeBrowses(self,processInfo):
            try:
                    browseSrcPath="%s/%s" % (processInfo.workFolder , processInfo.srcProduct.TIF_FILE_NAME)
                    browseExtension=definitions_EoSip.getBrowseExtension(0, definitions_EoSip.getDefinition('BROWSE_JPEG_EXT'))
                    browseDestPath="%s/%s.%s" % (processInfo.eosipTmpFolder, processInfo.destProduct.productShortName, browseExtension)
                    imageUtil.makeJpeg(browseSrcPath, browseDestPath, 50 )
                    processInfo.destProduct.addSourceBrowse(browseDestPath, [])

                    # create browse choice for browse metadata report
                    bmet=processInfo.destProduct.browse_metadata_dict[browseDestPath]
                    #reportBuilder=rep_rectifiedBrowse.rep_rectifiedBrowse()
                    #print "###\n###\n### BUILD BROWSE CHOICE FROM METADATA:%s" % (processInfo.destProduct.metadata.toString())
                    #browseChoiceBlock=reportBuilder.buildMessage(processInfo.destProduct.metadata, "rep:rectifiedBrowse").strip()
                    #if self.debug==0:
                    #        print "browseChoiceBlock:%s" % (browseChoiceBlock)
                    #bmet.setMetadataPair(browse_metadata.METADATA_BROWSE_CHOICE, browseChoiceBlock)
                    self.makeBrowseChoiceBlock(processInfo, bmet)
        
                    processInfo.addLog("  browse image created:%s" %  (browseDestPath))
                    self.logger.info("  browse image created:%s" % browseDestPath)
            except Exception, e:
                    try:
                            exc_type, exc_obj, exc_tb = sys.exc_info()
                            errorMsg="Error generating browse: error type:%s  exec_obj:%s" %  (exc_type, exc_obj)
                            self.logger.error(errorMsg)
                            processInfo.addLog("%s" %  (errorMsg))
                            processInfo.addLog("%s" %  (traceback.format_exc()))
                    except Exception, ee:
                            self.logger.error("  problem adding browse generation error in processInfo")
                            pass
Ejemplo n.º 2
0
        def makeBrowses(self,processInfo):
            try:
                    browseSrcPath=processInfo.srcProduct.preview_path
                    browseExtension=definitions_EoSip.getBrowseExtension(0, definitions_EoSip.getDefinition('BROWSE_JPEG_EXT'))
                    browseDestPath="%s/%s.%s" % (processInfo.eosipTmpFolder, processInfo.destProduct.productShortName, browseExtension)
                    shutil.copyfile(browseSrcPath, browseDestPath)
                    processInfo.destProduct.addSourceBrowse(browseDestPath, [])
                    processInfo.addLog("  browse image created:%s" %  (browseDestPath))
                    self.logger.info("  browse image created:%s" % browseDestPath)


                    # create browse choice for browse metadata report
                    bmet=processInfo.destProduct.browse_metadata_dict[browseDestPath]
                    print "######\n######\n%s" % dir(definitions_EoSip)

                    
                    reportBuilder=rep_footprint.rep_footprint()
                    #
                    print "###\n###\n### BUILD BROWSE CHOICE FROM METADATA:%s" % (processInfo.destProduct.metadata.toString())
                    browseChoiceBlock=reportBuilder.buildMessage(processInfo.destProduct.metadata, "rep:browseReport/rep:browse/rep:footprint").strip()
                    if self.debug!=-1:
                            print "browseChoiceBlock:%s" % (browseChoiceBlock)
                    bmet.setMetadataPair(browse_metadata.METADATA_BROWSE_CHOICE, browseChoiceBlock)

            except Exception, e:
                    exc_type, exc_obj, exc_tb = sys.exc_info()
                    errorMsg="Error generating browse:%s  %s\n%s" %  (exc_type, exc_obj, traceback.format_exc())
                    self.logger.error(errorMsg)
                    processInfo.addLog="%s" %  (errorMsg)
                    processInfo.addLog="%s" %  (traceback.format_exc())
Ejemplo n.º 3
0
 def makeBrowses(self,processInfo):
     try:
             browseSrcPath="%s/%s" % (processInfo.workFolder , processInfo.srcProduct.TIF_FILE_NAME)
             browseExtension=definitions_EoSip.getBrowseExtension(0, definitions_EoSip.getDefinition('BROWSE_JPEG_EXT'))
             browseDestPath="%s/%s.%s" % (processInfo.eosipTmpFolder, processInfo.destProduct.productShortName, browseExtension)
             imageUtil.makeJpeg(browseSrcPath, browseDestPath, 50 )
             processInfo.destProduct.addSourceBrowse(browseDestPath, [])
             processInfo.addLog("  browse image created:%s" %  (browseDestPath))
             self.logger.info("  browse image created:%s" % browseDestPath)
     except Exception, e:
             exc_type, exc_obj, exc_tb = sys.exc_info()
             errorMsg="Error generating browse:%s  %s\n%s" %  (exc_type, exc_obj, traceback.format_exc())
             self.logger.error(errorMsg)
             processInfo.addLog="%s" %  (errorMsg)
             processInfo.addLog="%s" %  (traceback.format_exc())
             raise e
Ejemplo n.º 4
0
        def doOneProduct(self, processInfo):
                global OUTPUT_EO_SIP_PATTERN, OUTSPACE
                
                self.verifySourceProduct(processInfo)
                # create work folder
                workfolder=self.makeWorkingFolders(processInfo)
                # instanciate source product
                self.createSourceProduct(processInfo)
                # prepare it: move/decompress it in work folder
                self.prepareProducts(processInfo)
                # create empty metadata
                met=metadata.Metadata(mission_metadatas)
                if self.debug!=0:
                        print "\n###  initial metadata dump:\n%s" % met.toString()
                #
                self.extractMetadata(met, processInfo)
                if self.debug!=0:
                        print "\n###  final metadata dump:\n%s" % met.toString()

                # instanciate destination product
                self.createDestinationProduct(processInfo)

                # set metadata
                processInfo.destProduct.setMetadata(met)
                processInfo.destProduct.setXmlMappingMetadata(xmlMappingMetadata, xmlMappingBrowse)

                # build product name
                patternName = OUTPUT_EO_SIP_PATTERN
                processInfo.destProduct.buildProductNames(patternName, definitions_EoSip.getDefinition('PRODUCT_EXT'))
                self.logger.info("  Eo-Sip product name:%s"  % processInfo.destProduct.productShortName)
                processInfo.addLog("  Eo-Sip product name:%s"  % processInfo.destProduct.productShortName)

                # make Eo-Sip tmp folder
                processInfo.eosipTmpFolder = processInfo.workFolder + "/" + processInfo.destProduct.productShortName
                if not os.path.exists(processInfo.eosipTmpFolder):
                        self.logger.info("  will make tmpEosipFolder:%s" % processInfo.eosipTmpFolder)
                        processInfo.addLog("  will make tmpEosipFolder:%s" % processInfo.eosipTmpFolder)
                        os.makedirs(processInfo.eosipTmpFolder)

                # make browse file
                self.makeBrowses(processInfo)

                # make report files
                # SIP report
                tmp=processInfo.destProduct.buildSipReportFile()
                processInfo.addLog("  Sip report file built:%s" %  (tmp))
                self.logger.info("  Sip report file built:%s" %  (tmp))

                # browse reports
                tmp=processInfo.destProduct.buildBrowsesReportFile()
                n=0
                for item in tmp:
                    processInfo.addLog("  Browse[%d] report file built:%s\n" %  (n, item))
                    self.logger.info("  Browse[%d] report file built:%s" %  (n, item))
                    n=n+1

                # metadata report
                tmp=processInfo.destProduct.buildProductReportFile()
                processInfo.addLog("  Product report file built:%s" % tmp)
                self.logger.info("  Product report file built:%s" % tmp)

                #
                processInfo.destProduct.info()
                
                # output Eo-Sip product
                self.output_eoSip(processInfo, OUTSPACE, OUTPUT_RELATIVE_PATH_TREES)
                #processInfo.destProduct.writeToFolder(OUTSPACE)
                #processInfo.addLog("  Eo-Sip product writen in folder:%s\n" %  (OUTSPACE))
                #self.logger.info("  Eo-Sip product writen in folder:%s\n" %  (OUTSPACE))

                
                print "\n\n\n\nLog:%s\n" % processInfo.prodLog
Ejemplo n.º 5
0
        def doOneProduct(self, pInfo):
                global OUTPUT_EO_SIP_PATTERN, OUTSPACE

                startProcessing=time.time()
                self.verifySourceProduct(pInfo)
                # create work folder
                workfolder=self.makeWorkingFolders(pInfo)
                # instanciate source product
                self.createSourceProduct(pInfo)
                # prepare it: move/decompress it in work folder
                self.prepareProducts(pInfo)
                # create empty metadata
                met=metadata.Metadata(mission_metadatas)
                if self.debug!=0:
                        print "\n###  initial metadata dump:\n%s" % met.toString()
                #
                self.extractMetadata(met, pInfo)
                if self.debug!=0:
                        print "\n###  final metadata dump:\n%s" % met.toString()

                # instanciate destination product
                self.createDestinationProduct(pInfo)
                # set the EOP typology used
                met.setOtherInfo("TYPOLOGY_SUFFIX", TYPOLOGY)


                # set metadata
                pInfo.destProduct.setMetadata(met)
                pInfo.destProduct.setXmlMappingMetadata(xmlMappingMetadata, xmlMappingBrowse)

                # build product name
                patternName = OUTPUT_EO_SIP_PATTERN
                pInfo.destProduct.buildProductNames(patternName, definitions_EoSip.getDefinition('PRODUCT_EXT'))
                self.logger.info("  Eo-Sip product name:%s"  % pInfo.destProduct.productShortName)
                pInfo.addLog("  Eo-Sip product name:%s"  % pInfo.destProduct.productShortName)

                # make Eo-Sip tmp folder
                pInfo.eosipTmpFolder = pInfo.workFolder + "/" + pInfo.destProduct.productShortName
                if not os.path.exists(pInfo.eosipTmpFolder):
                        self.logger.info("  will make tmpEosipFolder:%s" % pInfo.eosipTmpFolder)
                        pInfo.addLog("  will make tmpEosipFolder:%s" % pInfo.eosipTmpFolder)
                        os.makedirs(pInfo.eosipTmpFolder)
                #
                pInfo.destProduct.folder=pInfo.eosipTmpFolder

                # CODE MOVED FROM specialized ingested
                self.outputProductResolvedPaths = pInfo.destProduct.getOutputFolders(OUTSPACE, OUTPUT_RELATIVE_PATH_TREES)
                relativePathPart=self.outputProductResolvedPaths[0][len(OUTSPACE):]
                met.setMetadataPair(metadata.METADATA_PRODUCT_RELATIVE_PATH, relativePathPart)

                # make browse file
                self.makeBrowses(pInfo)

                # make report files
                # SIP report
                tmp=pInfo.destProduct.buildSipReportFile()
                pInfo.addLog("  Sip report file built:%s" %  (tmp))
                self.logger.info("  Sip report file built:%s" %  (tmp))

                # browse reports
                tmp=pInfo.destProduct.buildBrowsesReportFile()
                n=0
                for item in tmp:
                    pInfo.addLog("  Browse[%d] report file built:%s\n" %  (n, item))
                    self.logger.info("  Browse[%d] report file built:%s" %  (n, item))
                    n=n+1

                # metadata report
                tmp=pInfo.destProduct.buildProductReportFile()
                pInfo.addLog("  Product report file built:%s" % tmp)
                self.logger.info("  Product report file built:%s" % tmp)

                #
                pInfo.destProduct.info()
                
                # output Eo-Sip product
                self.output_eoSip(pInfo, OUTSPACE, OUTPUT_RELATIVE_PATH_TREES)

                processingDuration=time.time()-startProcessing
                # compute stats
                try:
                    # TODO: move get size into product??
                    size=os.stat(pInfo.destProduct.path).st_size
                    self.statsUtil.oneDone(processingDuration, size)
                    self.logger.info("  batch run will be completed at:%s" % self.statsUtil.getEndDate())
                except:
                    exc_type, exc_obj, exc_tb = sys.exc_info()
                    pInfo.addLog("Error:%s  %s\n%s\n" %  (exc_type, exc_obj, traceback.format_exc()))
                    self.logger.info("Error doing stats")
                    pass
                print "\n\n\n\nLog:%s\n" % pInfo.prodLog

                print "\n\n\n\nProcess info:%s\n" % pInfo.toString()