- Timestamp:
- Sep 19, 2014, 4:05:27 PM (12 years ago)
- Location:
- branches/eam_branches/ps2-tc3-20130727
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippToPsps/jython/batch.py (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ps2-tc3-20130727
- Property svn:mergeinfo changed
-
branches/eam_branches/ps2-tc3-20130727/ippToPsps/jython/batch.py
r36680 r37403 37 37 batchID, 38 38 batchType, 39 fits, 40 useFullTables): 41 42 # print "starting the batch" 43 44 # self.printline = 0 45 # self.testprint() 39 fits): 46 40 47 41 self.readHeader = False … … 49 43 self.skychunk = skychunk 50 44 self.fits = fits 51 self.useFullTables = useFullTables52 45 53 46 # set up logging … … 55 48 self.logger.infoSeparator() 56 49 self.logger.debug("Batch class constructor") 57 58 # self.testprint()59 50 60 51 # set up class variables … … 68 59 self.pspsVoTableFilePath = self.config.configDir + "tables." + batchType + ".vot" 69 60 70 # self.testprint()71 72 61 # check FITS file is ok 73 62 if self.fits: … … 79 68 raise 80 69 81 self.scratchDb.setUseFullTables(self.useFullTables) 70 # define the dvo table names 71 self.scratchDb.setDvoTableNames() 82 72 83 73 # TODO … … 107 97 if not os.path.exists(self.localOutPath): os.makedirs(self.localOutPath) 108 98 109 # self.testprint()110 111 99 # store today's date 112 100 now = datetime.datetime.now(); 113 101 self.dateStr = now.strftime("%Y-%m-%d") 114 102 115 # create DVO tables if accessing DVO directly116 if not self.useFullTables:self.scratchDb.createDvoTables()103 # create DVO tables (scratch database) 104 self.scratchDb.createDvoTables() 117 105 118 106 # dump stuff to the log … … 120 108 self.logger.infoPair("Batch name", self.batchName) 121 109 self.logger.infoPair("Survey ID", "%d" % self.surveyID) 122 self.logger.infoBool("Use full DVO tables?", self.useFullTables)123 110 124 111 if self.fits: 125 112 self.logger.infoPair("Input FITS file", self.fits.getOriginalPath()) 126 113 self.logger.infoPair("Input FITS primary header", "%s cards found" % self.fits.getPrimaryHeaderCardCount()) 127 128 # self.testprint()129 114 130 115 self.logger.infoPair("Output path", self.localOutPath) … … 237 222 self.logger.errorPair("Missing header field", key) 238 223 return "NULL" 224 225 ''' 226 Returns the string keyword value from this header or else "NULL" 227 ''' 228 def getKeyValue(self, header, key): 229 230 if key in header: return header[key] 231 else: 232 self.logger.errorPair("Missing header field", key) 233 return "NULL" 234 235 ''' 236 Returns the string keyword value from this header or else "NULL" 237 ''' 238 def getKeyFloat(self, header, format, key): 239 240 if key in header: 241 value = format % float(header[key]) 242 else: 243 self.logger.errorPair("Missing header field", key) 244 value = format % -999.9 245 246 return value 247 248 ''' 249 Returns the string keyword value from this header or else "NULL" 250 ''' 251 def getKeyInt(self, header, defValue, key): 252 253 if key in header: 254 value = str(int(header[key])) 255 else: 256 self.logger.errorPair("Missing header field", key) 257 value = str(defValue) 258 259 return value 239 260 240 261 ''' … … 373 394 self.tablesToExport.append(table.name) 374 395 375 return self.alterPspsTables();396 return True 376 397 377 398 ''' … … 383 404 384 405 ''' 385 Alter PSPS tables 406 Alter PSPS tables (Subclass implements this) 386 407 ''' 387 408 def alterPspsTables(self): … … 417 438 418 439 # print "read smf table ", table 440 self.logger.infoPair("read smf table", table) 419 441 420 442 # drop any previous tables before import … … 458 480 # get everything from table 459 481 try: 460 print "reading table from mysql ", table461 482 _table = stilts.tread(self.scratchDb.url + '#SELECT * FROM ' + table) 462 483 self.scratchDb.killLastConnectionID() … … 467 488 # replace nulls and empty fields with weird PSPS -999 pseudo-null 468 489 _table = stilts.tpipe(_table, cmd='replaceval "" -999 *') 469 470 match = re.match(regex, table) 490 self.logger.infoPair('regex', regex) 491 self.logger.infoPair('table', table) 492 match = re.search(regex, table) 471 493 newTableName = match.group(1) 472 494 … … 542 564 def run(self): 543 565 544 # this is badly named : it creates the tables and then fills in 545 # the ImageMeta tables for each ota (alterPspsTables) 566 # creates the empty PSPS tables 546 567 if not self.createEmptyPspsTables(): 547 568 self.logger.errorPair("Aborting this batch", "could not create empty PSPS tables") 569 self.ippToPspsDb.updateProcessed(self.batchID, -1) 570 raise 571 572 # fill in basic, not cmf/smf data (eg, ImageMeta for detectionbatch) 573 if not self.alterPspsTables(): 574 self.logger.errorPair("Aborting this batch", "could not alter PSPS tables for batch type") 548 575 self.ippToPspsDb.updateProcessed(self.batchID, -1) 549 576 raise … … 556 583 self.ippToPspsDb.updateProcessed(self.batchID, 1) 557 584 return True 558 559 585 self.logger.errorPair("Aborting this batch", "could not import IPP tables") 560 586 self.ippToPspsDb.updateProcessed(self.batchID, -1) 561 587 raise 562 588 589 self.logger.infoPair("populatePspsTables","ok") 563 590 if not self.populatePspsTables(): 564 591 if self.skipBatch: … … 593 620 tarballFile) 594 621 622 if self.config.onebatch: 623 self.logger.infoPair("onebatch requested", "exiting") 624 sys.exit(0) 625 626 # XXX why is this down here?? 595 627 from datastore import Datastore 596
Note:
See TracChangeset
for help on using the changeset viewer.
