IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 19, 2012, 5:24:19 PM (14 years ago)
Author:
mhuber
Message:

merging latest r34040 trunk changes to branch

Location:
branches/meh_branches/ppstack_test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/meh_branches/ppstack_test

  • branches/meh_branches/ppstack_test/ippToPsps/jython/batch.py

    r33415 r34041  
    1010import logging
    1111from subprocess import call, PIPE, Popen
     12from java.lang import *
     13from java.sql import *
     14from xml.etree.ElementTree import ElementTree, Element, tostring
    1215
    1316from scratchdb import ScratchDb
     
    1518from ipptopspsdb import IppToPspsDb
    1619from fits import Fits
    17 
    18 from java.lang import *
    19 from java.sql import *
    20 from xml.etree.ElementTree import ElementTree, Element, tostring
    2120
    2221'''
     
    4039                 useFullTables):
    4140
    42         self.everythingOK = False
    4341        self.readHeader = False
    4442        self.config = config
     
    6765            if not self.header:
    6866                logger.errorPair("Could not read FITS for id", "%d" % id)
    69                 return
    70 
    71         # if no fits file, and this is not an IN batch, then get out of here
    72         else:
    73            if batchType != "IN":
    74                logger.errorPair("Could not read FITS for id", "%d" % id)
    75                return
     67                raise
    7668
    7769        self.scratchDb.setUseFullTables(self.useFullTables)
     
    122114        self.logger.infoPair("Output path", self.localOutPath)
    123115
    124         self.everythingOK = True
    125116   
    126117    '''
     
    241232        root.attrib['type'] = self.batchType
    242233        root.attrib['timestamp'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    243         if self.batchType != "IN": root.attrib['survey'] = self.config.pspsSurvey
     234        root.attrib['survey'] = self.config.pspsSurvey
     235
     236        # min/max object IDs
    244237        try: self.minObjID
    245238        except: pass
     
    260253
    261254        # clunky way to prettify XML
    262         p = Popen("xmllint --format " + tmpPath + " > " + outPath, shell=True, stdout=PIPE)
    263         p.wait()
    264         os.remove(tmpPath)
     255        try:
     256            cmd = "xmllint --format " + tmpPath + " > " + outPath
     257            p = Popen(cmd, shell=True, stdout=PIPE)
     258            p.wait()
     259        except:
     260            self.logger.errorPair("Popen failed", cmd)
     261            return False
     262        finally:
     263            os.remove(tmpPath)
     264
     265        return True
    265266
    266267
     
    296297            return False
    297298
    298         # only now can we report that the batch has successfully processed
    299         self.ippToPspsDb.updateProcessed(self.batchID, 1)
    300 
    301299        # delete tar file and original directory
    302300        os.remove(tarPath)
     
    410408      self.logger.infoPair("Done. Imported", "%d tables" % count)
    411409      self.indexIppTables()
     410
     411      return True
    412412
    413413    '''
     
    508508    def run(self):
    509509
    510         if not self.everythingOK:
    511             self.logger.error("Aborting this batch due to (hopefully) previously reported errors")
     510        if not self.createEmptyPspsTables():
     511            self.logger.errorPair("Aborting this batch", "could not create empty PSPS tables")
    512512            self.ippToPspsDb.updateProcessed(self.batchID, -1)
    513             return
    514 
    515         if not self.createEmptyPspsTables():
    516             self.logger.error("Aborting this batch due to (hopefully) previously reported errors")
     513            raise
     514
     515        if not self.importIppTables():
     516            self.logger.errorPair("Aborting this batch", "could not import IPP tables")
    517517            self.ippToPspsDb.updateProcessed(self.batchID, -1)
    518             return
    519 
    520         self.importIppTables()
     518            raise
     519
    521520        if not self.populatePspsTables():
    522521            self.logger.errorPair("Aborting this batch", "unable to populate PSPS tables")
    523522            self.ippToPspsDb.updateProcessed(self.batchID, -1)
    524         else:
    525             if not self.exportPspsTablesToFits():
    526                 self.logger.errorPair("Aborting this batch", "unable to export tables to FITS file")
    527             else:
    528                 self.writeBatchManifest()
    529                 if self.config.datastorePublishing:
    530                     # tar and zip ready for publication to datastore
    531                     if self.tarAndZip():
    532                         # now publish to the datastore
    533                         tarballFile = Batch.getTarballFile(self.batchID)
    534                         Batch.publishToDatastore(self.datastore, self.batchID, self.batchName, self.subDir, tarballFile)
     523            raise
     524
     525        if not self.exportPspsTablesToFits():
     526            self.logger.errorPair("Aborting this batch", "unable to export tables to FITS file")
     527            self.ippToPspsDb.updateProcessed(self.batchID, -1)
     528            raise
     529   
     530        if self.writeBatchManifest():
     531            if self.config.datastorePublishing:
     532
     533                # tar and zip ready for publication to datastore
     534                if self.tarAndZip():
     535
     536                    # only now can we report that the batch has successfully processed
     537                    self.ippToPspsDb.updateProcessed(self.batchID, 1)
     538                   
     539                    # now publish to the datastore
     540                    tarballFile = Batch.getTarballFile(self.batchID)
     541                    Batch.publishToDatastore(
     542                            self.datastore,
     543                            self.batchID,
     544                            self.batchName,
     545                            self.subDir,
     546                            tarballFile)
    535547
    536548from datastore import Datastore
Note: See TracChangeset for help on using the changeset viewer.