- Timestamp:
- Jul 28, 2014, 6:20:27 AM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140717/ippToPsps
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
jython/scratchdb.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140717/ippToPsps
- Property svn:mergeinfo set to
-
branches/eam_branches/ipp-20140717/ippToPsps/jython/scratchdb.py
r35417 r37129 51 51 Sets whether we are using normal or pre-ingested DVO tables 52 52 ''' 53 def setUseFullTables(self, useFull): 54 55 if useFull: 56 self.dvoImagesTable = "dvoImagesFull" 57 self.dvoDetectionTable = "dvoDetectionFull" 58 else: 59 self.dvoImagesTable = "dvoImages" 60 self.dvoDetectionTable = "dvoDetection" 53 def setDvoTableNames(self): 54 55 self.dvoImagesTable = "dvoImagesFull" 56 self.dvoDetectionTable = "dvoDetectionFull" 61 57 62 58 self.logger.debugPair("Using DVO images table", self.dvoImagesTable) … … 233 229 def alreadyImportedThisDvoTable(self, path): 234 230 231 print "***** alreadyImportedThisDvoTable *****" 232 print "path: " + path 233 235 234 fileStat = os.stat(path) 235 print "path: " + path 236 236 237 237 sql = "SELECT COUNT(*) FROM " + self.dvoDoneTable + " WHERE path = '" + path + "' AND modifiedDate = " + str(fileStat.st_mtime) 238 239 try: 240 rs = self.executeQuery(sql) 238 print "sql: " + sql 239 240 try: 241 rs = self.executeQuery(sql) 242 print "ran sql: " + sql 241 243 rs.first() 242 244 if rs.getInt(1) > 0: 245 print "***** DID import previously *****" 243 246 self.logger.debugPair("Already imported up-to-date version of", path) 244 247 return True 245 248 else: 249 print "***** did NOT import previously *****" 246 250 return False 247 251 except: 252 print "***** exception in alreadyImportedThisDvoTable *****" 248 253 self.logger.exception("Unable to check whether this DVO table has been imported") 254 255 print "***** done with alreadyImportedThisDvoTable *****" 249 256 250 257 … … 322 329 ''' 323 330 def isCorrectDvo(self, path): 331 332 sql = "show tables" 333 try: 334 rs = self.executeQuery(sql) 335 haveDone = False 336 while (rs.next()): 337 tableName = rs.getString(1) 338 # print "table: " + tableName 339 if tableName == self.dvoDoneTable: 340 haveDone = True 341 342 rs.close() 343 if not haveDone: 344 print "dvoDone not yet build" 345 return False 346 except: 347 print "failed to run query: " + sql 324 348 325 349 sql = "SELECT path FROM " + self.dvoDoneTable + " WHERE path LIKE '%SkyTable.fits'" … … 415 439 416 440 dvoImagesTable = "dvoImages" 417 dvoDetectionTable = "dvoDetection s"441 dvoDetectionTable = "dvoDetection" 418 442 419 443 # drop and create Images table 420 self.logger. debugPair("Creating DVO table", dvoImagesTable)444 self.logger.infoPair("Creating DVO table", dvoImagesTable) 421 445 sql = "DROP TABLE " + dvoImagesTable 422 446 … … 438 462 439 463 # now detection table 440 self.logger. debugPair("Creating DVO table", dvoDetectionTable)464 self.logger.infoPair("Dropping DVO table", dvoDetectionTable) 441 465 sql = "DROP TABLE " + dvoDetectionTable 442 466 try: self.execute(sql) 443 except: pass 444 445 self.logger.debugPair("Creating DVO table", "dvoDetection") 467 except: 468 print "problem dropping DVO " + dvoDetectionTable 469 pass 470 471 self.logger.infoPair("Creating DVO table", "dvoDetection") 446 472 sql = "CREATE TABLE dvoDetection ( \ 447 imageID INT, \ 448 ippDetectID BIGINT, \ 473 objID BIGINT, \ 449 474 detectID BIGINT, \ 450 475 ippObjID BIGINT, \ 451 objID BIGINT, \ 452 flags INT, \ 453 zp FLOAT, \ 454 zpErr FLOAT, \ 455 airMass FLOAT, \ 456 expTime FLOAT, \ 476 ippDetectID BIGINT, \ 477 imageID INT, \ 457 478 ra DOUBLE, \ 458 479 dec_ DOUBLE, \ 459 480 raErr FLOAT, \ 460 481 decErr FLOAT, \ 482 zp FLOAT, \ 483 telluricExt FLOAT, \ 484 airmass FLOAT, \ 485 expTime FLOAT, \ 486 flags INT, \ 461 487 PRIMARY KEY (imageID, ippDetectID), \ 462 488 KEY (objID, detectID) \ … … 466 492 except: 467 493 self.logger.error("Unable to create DVO detection database table") 494 self.sys.exit(1) 468 495 469 496 # XXX EAM : for the parallel mode, dvoDetection requires duplicate objID values! … … 550 577 self.logger.infoPair("Dropping table", self.dvoSkyTable) 551 578 self.dropTable(self.dvoSkyTable) 552 self.logger.infoPair("Dropping table", self.dvoDetectionTable)553 self.dropTable(self.dvoDetectionTable)554 579 self.logger.infoPair("Dropping table", self.dvoDoneTable) 555 580 self.dropTable(self.dvoDoneTable) 581 582 # blow away existing dvoDetection table & re-crate 583 if not self.resetDvoDetectionTable(): 584 self.logger.errorPair("Unable to reset scratch table", "DvoDetectionFull") 585 return False 556 586 557 587 # create dvoDone table … … 564 594 565 595 self.changeEngineToInnoDB(self.dvoDoneTable) 566 567 # blow away existing dvoDetection table & re-crate568 if not self.resetDvoDetectionTable():569 self.logger.errorPair("Unable to reset scratch table", "DvoDetectionFull")570 return False571 596 572 597 return True
Note:
See TracChangeset
for help on using the changeset viewer.
