IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32819


Ignore:
Timestamp:
Nov 25, 2011, 11:17:01 AM (15 years ago)
Author:
rhenders
Message:

improved logic so that batches are only marked as 'successfully' processed once they are tar'd and zip'd

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/batch.py

    r32596 r32819  
    286286    Publishes this batch to the datastore
    287287    '''
    288     def tarZipAndpublishToDatastore(self):
     288    def tarAndZip(self):
    289289     
    290290        # set up filenams and paths
     
    295295
    296296        # tar directory
    297         p = Popen("tar -cvf " + tarPath + "\
    298                 -C " + self.subDir + " \
    299                 " + self.batchName, shell=True, stdout=PIPE)
     297        cmd = "tar -cvf " + tarPath + " -C " + self.subDir + " " + self.batchName
     298        self.logger.infoPair("Running", cmd)
     299        p = Popen(cmd, shell=True, stdout=PIPE)
    300300        p.wait()
    301301
     302        if p.returncode != 0:
     303            self.logger.errorPair("tar command", "failed")
     304            return False
     305
    302306        # zip tar archive
    303         p = Popen("gzip -c " + tarPath + " > " + tarballPath, shell=True, stdout=PIPE)
     307        cmd = "gzip -c " + tarPath + " > " + tarballPath
     308        self.logger.infoPair("Running", cmd)
     309        p = Popen(cmd, shell=True, stdout=PIPE)
    304310        p.wait()
     311
     312        if p.returncode != 0:
     313            self.logger.errorPair("gzip command", "failed")
     314            return False
     315
     316        # only now can we report that the batch has successfully processed
     317        self.logger.infoPair("Batch tar 'n zip successful", "setting batch to 'processed'")
     318        self.ippToPspsDb.updateProcessed(self.batchID, 1)
    305319
    306320        # delete tar file and original directory
     
    308322        shutil.rmtree(self.localOutPath)
    309323
    310         # now publish to the datastore
    311         Batch.publishToDatastore(self.datastore, self.batchID, self.batchName, self.subDir, tarballFile)
     324        return True
    312325
    313326    '''
     
    448461        try:
    449462            stilts.twrites(_tables, self.outputFitsPath, fmt='fits')
    450             self.ippToPspsDb.updateProcessed(self.batchID, 1)
    451463        except:
    452464            self.logger.exception("Could not write to FITS")
     
    494506        p = Popen(cmd, shell=True, stdout=PIPE)
    495507        p.wait()
    496         #        out = p.stdout.read()
    497508
    498509        rowCount = self.scratchDb.getRowCount("dvoDetection")
     
    507518    '''
    508519    Creates and publishes a batch
    509     TODO all methdds call below should throw exceptions on failure
     520    TODO all methods call below should throw exceptions on failure
    510521    '''
    511522    def run(self):
     
    530541            else:
    531542                self.writeBatchManifest()
    532                 if int(self.doc.find("options/publishToDatastore").text): self.tarZipAndpublishToDatastore()
     543                if int(self.doc.find("options/publishToDatastore").text):
     544                    # tar and zip ready for publication to datastore
     545                    if self.tarAndZip():
     546                        # now publish to the datastore
     547                        tarballFile = Batch.getTarballFile(self.batchID)
     548                        Batch.publishToDatastore(self.datastore, self.batchID, self.batchName, self.subDir, tarballFile)
     549
    533550                if int(self.doc.find("options/reportNulls").text): self.reportNullsInAllPspsTables(False)
    534551
Note: See TracChangeset for help on using the changeset viewer.