IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 8, 2011, 2:44:12 PM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20110906
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110906

  • branches/eam_branches/ipp-20110906/ippToPsps/jython/batch.py

    r32332 r32630  
    3939                 ippToPspsDb,
    4040                 id,
     41                 batchID,
    4142                 batchType,
    4243                 fits):
     
    5354        self.logger.debug("Batch class constructor")
    5455
    55         # check FITS file is ok - TODO could be neater
    56         if self.fits:
    57             self.header = self.fits.getPrimaryHeader()
    58             if not self.header: return
    59 
    6056        # set up class variables
    6157        self.id = id
     58        self.batchID = batchID
    6259        self.gpc1Db = gpc1Db
    6360        self.ippToPspsDb = ippToPspsDb
    6461        self.batchType = batchType;
    6562        self.pspsVoTableFilePath = "../config/" + batchType + "/tables.vot"
     63
     64        # check FITS file is ok
     65        if self.fits:
     66            self.header = self.fits.getPrimaryHeader()
     67
     68            # now check that the fits header is readable
     69            if not self.header:
     70                logger.errorPair("Could not read FITS for id", "%d" % id)
     71                return
     72
     73        # if no fits file, and this is not an IN batch, then get out of here
     74        else:
     75           if batchType != "IN":
     76               logger.errorPair("Could not read FITS for id", "%d" % id)
     77               return
    6678
    6779        # get info from config
     
    88100
    89101        # create datastore object
    90         self.datastore = Datastore(self.logger, self.doc)
    91 
    92         # create a new batch
    93         self.batchID = self.ippToPspsDb.createNewBatch(
    94                 self.batchType,
    95                 self.id,
    96                 self.survey,
    97                 self.dvoGpc1Label,
    98                 self.datastore.product)
     102        self.datastore = Datastore(self.logger, self.doc, self.ippToPspsDb)
    99103
    100104        # get local storage location from config
     
    247251
    248252        outPath = self.localOutPath + "/BatchManifest.xml"
    249         tmpPath = "./tmp.xml"
     253        tmpPath = self.localOutPath + "/tmp.xml"
    250254        self.logger.infoPair("Creating manifest", outPath)
    251255        root = Element('manifest')
     
    263267        else: root.attrib['maxObjId'] = str(self.maxObjID)
    264268
    265         # get md5sum
    266         #p = Popen("md5sum " + self.outputFitsPath, shell=True, stdout=PIPE)
    267         #p.wait()
    268         #out = p.stdout.read()
    269         #md5sum = out[0:out.rfind(" ")]
    270 
    271         # get file size
    272         #fileSize = os.path.getsize(self.outputFitsPath)
    273 
    274269        # file information
    275270        child = Element('file')
    276271        root.append(child)
    277272        child.attrib['name'] = self.outputFitsFile
    278         #child.attrib['bytes'] = str(fileSize)
    279         #child.attrib['md5'] = md5sum
    280273
    281274        # now create doc and write to file
     
    316309
    317310        # now publish to the datastore
    318         Batch.publishToDatastore(self.datastore, self.ippToPspsDb, self.batchID, self.batchName, self.subDir, tarballFile)
     311        Batch.publishToDatastore(self.datastore, self.batchID, self.batchName, self.subDir, tarballFile)
    319312
    320313    '''
     
    322315    '''
    323316    @staticmethod
    324     def publishToDatastore(datastore, ippToPspsDb, batchID, batchName, subDir, tarballFile):
    325 
    326         if datastore.publish(batchName, subDir, tarballFile, "tgz"):
    327             ippToPspsDb.updateLoadedToDatastore(batchID, 1)
    328         else:
    329             ippToPspsDb.updateLoadedToDatastore(batchID, -1)
    330            
     317    def publishToDatastore(datastore, batchID, batchName, subDir, tarballFile):
     318        datastore.publish(batchName, subDir, tarballFile, "tgz")
    331319
    332320    '''
Note: See TracChangeset for help on using the changeset viewer.