- Timestamp:
- Jun 19, 2012, 5:24:19 PM (14 years ago)
- Location:
- branches/meh_branches/ppstack_test
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippToPsps/jython/batch.py (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/meh_branches/ppstack_test
- Property svn:mergeinfo changed
-
branches/meh_branches/ppstack_test/ippToPsps/jython/batch.py
r33415 r34041 10 10 import logging 11 11 from subprocess import call, PIPE, Popen 12 from java.lang import * 13 from java.sql import * 14 from xml.etree.ElementTree import ElementTree, Element, tostring 12 15 13 16 from scratchdb import ScratchDb … … 15 18 from ipptopspsdb import IppToPspsDb 16 19 from fits import Fits 17 18 from java.lang import *19 from java.sql import *20 from xml.etree.ElementTree import ElementTree, Element, tostring21 20 22 21 ''' … … 40 39 useFullTables): 41 40 42 self.everythingOK = False43 41 self.readHeader = False 44 42 self.config = config … … 67 65 if not self.header: 68 66 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 76 68 77 69 self.scratchDb.setUseFullTables(self.useFullTables) … … 122 114 self.logger.infoPair("Output path", self.localOutPath) 123 115 124 self.everythingOK = True125 116 126 117 ''' … … 241 232 root.attrib['type'] = self.batchType 242 233 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 244 237 try: self.minObjID 245 238 except: pass … … 260 253 261 254 # 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 265 266 266 267 … … 296 297 return False 297 298 298 # only now can we report that the batch has successfully processed299 self.ippToPspsDb.updateProcessed(self.batchID, 1)300 301 299 # delete tar file and original directory 302 300 os.remove(tarPath) … … 410 408 self.logger.infoPair("Done. Imported", "%d tables" % count) 411 409 self.indexIppTables() 410 411 return True 412 412 413 413 ''' … … 508 508 def run(self): 509 509 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") 512 512 self.ippToPspsDb.updateProcessed(self.batchID, -1) 513 r eturn514 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") 517 517 self.ippToPspsDb.updateProcessed(self.batchID, -1) 518 return 519 520 self.importIppTables() 518 raise 519 521 520 if not self.populatePspsTables(): 522 521 self.logger.errorPair("Aborting this batch", "unable to populate PSPS tables") 523 522 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) 535 547 536 548 from datastore import Datastore
Note:
See TracChangeset
for help on using the changeset viewer.
