Changeset 31809 for trunk/ippToPsps/jython/batch.py
- Timestamp:
- Jul 1, 2011, 8:54:16 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/batch.py (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/batch.py
r31720 r31809 34 34 def __init__(self, 35 35 logger, 36 doc, 36 37 gpc1Db, 37 38 ippToPspsDb, 38 scratchDb,39 39 id, 40 40 batchType, 41 41 inputFitsPath="", 42 survey="", 43 useFullTables=False): 42 survey=""): 44 43 45 44 self.everythingOK = False 46 45 self.readHeader = False 46 self.doc = doc 47 47 48 48 # set up logging … … 55 55 self.gpc1Db = gpc1Db 56 56 self.ippToPspsDb = ippToPspsDb 57 self.scratchDb = scratchDb58 57 self.batchType = batchType; 59 58 self.pspsVoTableFilePath = "../config/" + batchType + "/tables.vot" 60 59 self.inputFitsPath = inputFitsPath 61 60 self.survey = survey 62 self.useFullTables = useFullTables63 61 64 62 if self.alreadyProcessed(): return 63 64 # get dvo info from config 65 dvoName = self.doc.find("dvo/name").text 66 self.dvoLocation = self.doc.find("dvo/location").text 67 self.useFullTables = int(self.doc.find("dvo/useFullTables").text) 68 self.scratchDb = ScratchDb(logger, self.useFullTables) 65 69 66 70 # do we have an input file? … … 72 76 self.tablesToExport = [] 73 77 74 # open config75 self.doc = ElementTree(file="config.xml")76 77 78 if self.survey != "": 78 79 self.surveyID = self.scratchDb.getSurveyID(self.survey) 79 80 # get dvo info from config81 dvoName = self.doc.find("dvo_" + self.survey + "/name").text82 self.dvoLocation = self.doc.find("dvo_" + self.survey + "/location").text83 80 else: 84 dvoName = ""85 self.dvoLocation = ""86 81 self.surveyID = -1; 82 87 83 88 84 # get some options from the config 89 self.dataRelease = self.doc.find("metadata/dataRelease").text 85 self.testMode = int(self.doc.find("options/testMode").text) 86 self.dataRelease = int(self.doc.find("metadata/dataRelease").text) 90 87 91 88 # get datastore info from config … … 95 92 self.batchID = self.ippToPspsDb.createNewBatch( 96 93 self.getPspsBatchType(), 94 self.id, 97 95 survey, 98 96 dvoName, … … 120 118 121 119 self.logger.debug("Batch destructor") 120 121 ''' 122 Prints metadata to the log 123 ''' 124 def printMe(self): 125 126 self.logger.info("New batch: ") 127 self.logger.info("Batch type: " + self.batchType) 128 self.logger.info("Survey: " + self.survey) 129 self.logger.info("Survey ID: %d" % self.surveyID) 130 self.logger.info("Test mode? %d" % self.testMode) 131 self.logger.info("DVO location: " + self.dvoLocation) 132 self.logger.info("Use full DVO tables?: %d" % self.useFullTables) 133 self.logger.info("Input FITS file: " + self.inputFitsPath) 122 134 123 135 … … 240 252 241 253 ''' 242 tar and zips batch directory243 ''' 244 def createTarball(self):254 Publishes this batch to the datastore 255 ''' 256 def publishToDatastore(self): 245 257 246 if self.doc.find("options/createTarball").text == "false": return247 248 258 # set up filenams and paths 249 259 tarFile = self.batchName + ".tar" 250 260 tarPath = self.subDir + "/" + tarFile 251 261 252 self.tarballFile = tarFile + ".gz"253 tarballPath = self.subDir + "/" + self.tarballFile262 tarballFile = tarFile + ".gz" 263 tarballPath = self.subDir + "/" + tarballFile 254 264 255 265 # tar directory … … 267 277 shutil.rmtree(self.localOutPath) 268 278 269 ''' 270 Publishes this batch to the datastore 271 ''' 272 def publishToDatastore(self): 273 274 if self.doc.find("options/publishToDatastore").text == "false": return 275 276 if self.datastore.publish(self.batchName, self.subDir, self.tarballFile, "tgz"): 279 # now publish to the datastore 280 if self.datastore.publish(self.batchName, self.subDir, tarballFile, "tgz"): 277 281 self.ippToPspsDb.updateLoadedToDatastore(self.batchID, 1) 278 282 … … 282 286 def getBatchFriendlySurveyType(self): 283 287 284 return "SCR" # TODO 285 288 #return "SCR" # TODO 286 289 try: 287 290 self.survey … … 395 398 def importIppTables(self, filter=""): 396 399 397 self.logger.info("Attempting to import tables from input FITS file ")400 self.logger.info("Attempting to import tables from input FITS file with regex " + filter) 398 401 tables = stilts.treads(self.inputFitsPath) 399 402 … … 433 436 _tables = [] 434 437 435 self.logger.info("Selecting database tables ")438 self.logger.info("Selecting database tables for export") 436 439 for table in self.tablesToExport: 437 440 … … 472 475 def reportNullsInAllPspsTables(self, showPartials): 473 476 474 if self.doc.find("options/reportNulls").text == "false": return475 476 477 for table in self.pspsTables: 477 478 self.scratchDb.reportNulls(table.name, showPartials) … … 527 528 528 529 self.createEmptyPspsTables() 529 #self.importIppTables()530 self.importIppTables() 530 531 if self.populatePspsTables(): 531 532 if self.exportPspsTablesToFits(): 532 533 self.writeBatchManifest() 533 self.createTarball() 534 self.publishToDatastore() 535 self.reportNullsInAllPspsTables(False) 536 #sys.exit() 534 if int(self.doc.find("options/publishToDatastore").text): self.publishToDatastore() 535 if int(self.doc.find("options/reportNulls").text): self.reportNullsInAllPspsTables(False) 536 537 537 self.logger.info("Finished.") 538 539 538 if self.testMode: sys.exit() 539 540
Note:
See TracChangeset
for help on using the changeset viewer.
