Changeset 33678
- Timestamp:
- Apr 3, 2012, 4:35:55 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/scratchdb.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/scratchdb.py
r33492 r33678 24 24 self.dvoDoneTable = "dvoDone" 25 25 self.dvoSkyTable = "dvoSkyTable" 26 26 self.dvoPhotcodesTable = "dvoPhotcodes" 27 27 28 28 ''' … … 249 249 250 250 ''' 251 Gets the id for the cpm file for the provided region252 '''253 def getDvoCpmFileIdForRegion(self, region):254 255 id = -1256 sql = "SELECT id FROM " + self.dvoDoneTable + " WHERE region = '" + region + "' AND path LIKE '%.cpm'";257 try:258 rs = self.executeQuery(sql)259 rs.first()260 id = rs.getInt(1)261 except:262 self.logger.errorPair("Could not get file id from " + self.dvoDoneTable, "for region: " + region)263 264 return id265 266 267 '''268 251 Gets the id for the provided file 269 252 ''' … … 277 260 id = rs.getInt(1) 278 261 except: 279 self.logger.err prPair("Could not get file id from " + self.dvoDoneTable + "for", path)262 self.logger.errorPair("Could not get file id from " + self.dvoDoneTable + "for", path) 280 263 281 264 return id … … 337 320 return False 338 321 339 except: 322 except Exception, e: 323 print str(e) 340 324 self.logger.errorPair("No DVO files ingested for this path", path) 341 325 return False … … 343 327 ''' 344 328 Checks whether the astrometric solution is ok for this chip 345 TODO the value of 50 for numAstroRef is hardcoded here, but this should be temporary anyway329 TODO the value of 50 for numAstroRef (provided by Gene) is hardcoded here, but this should be temporary anyway 346 330 ''' 347 331 def astrometricSolutionOK(self, ota): … … 411 395 ''' 412 396 Removes the provided DVO FITS files from from dvoDone and dvoDetection tables 413 Returns a count of the number of detections deleted 414 ''' 415 def purgeTheseDvoRegions(self, regions ):397 Returns a count of the number of detections deleted, if any 398 ''' 399 def purgeTheseDvoRegions(self, regions, fileTypes): 416 400 417 401 detectionCount = self.getRowCount(self.dvoDetectionTable) 418 402 for region in regions: 419 420 fileId = self.getDvoCpmFileIdForRegion(region) 421 422 if fileId < 0: 423 self.logger.errorPair("Unable to get file ID to delete " + region + " from", self.dvoDoneTable) 424 continue 425 426 sql = "DELETE FROM " + self.dvoDoneTable + " WHERE region = '" + region + "'" 427 try: self.execute(sql) 428 except: 429 self.logger.errorPair("Unable to delete " + region + " from", self.dvoDoneTable) 430 431 finalCount = detectionCount - self.getRowCount(self.dvoDetectionTable) 432 433 # after a big delete, we should OPTIMIZE the table 434 self.logger.infoPair("Running OPTIMIZE on ", self.dvoDetectionTable) 435 if finalCount > 0: self.optimizeTable(self.dvoDetectionTable) 436 437 return finalCount 403 404 for fileType in fileTypes: 405 sql = "DELETE FROM " + self.dvoDoneTable + " WHERE region = '" + region + "' AND path LIKE '%" + fileType + "'" 406 try: self.execute(sql) 407 except: 408 self.logger.errorPair("Unable to delete " + fileType + " file from", self.dvoDoneTable) 409 410 sql = "DROP TABLE " + self.getDbFriendlyTableName(region + "." + fileType) 411 self.execute(sql) 412 413 deletedDetectionCount = detectionCount - self.getRowCount(self.dvoDetectionTable) 414 415 # after a big detection delete, we should OPTIMIZE the table 416 if deletedDetectionCount > 0: 417 self.logger.infoPair("Running OPTIMIZE on ", self.dvoDetectionTable) 418 self.optimizeTable(self.dvoDetectionTable) 419 420 return deletedDetectionCount 438 421 439 422 ''' … … 515 498 def getDvoRegionsForThisBox(self, regions, minRa, maxRa, minDec, maxDec): 516 499 517 sql = "SELECT name FROM " + self.dvoSkyTable + " \ 500 sql = "SELECT \ 501 INDEX_, \ 502 R_MIN+ (R_MAX - R_MIN)/2.0, \ 503 D_MIN + (D_MAX - D_MIN)/2.0, \ 504 NAME \ 505 FROM " + self.dvoSkyTable + " \ 518 506 WHERE NOT ((" + str(maxRa) + " <= R_MIN) OR \ 519 507 (" + str(minRa) + " >= R_MAX) OR \ … … 523 511 try: 524 512 rs = self.executeQuery(sql) 525 while (rs.next()): regions.append(rs.getString(1)) 513 while (rs.next()): regions.append([ 514 rs.getInt(1), 515 rs.getFloat(2), 516 rs.getFloat(3), 517 rs.getString(4)]) 518 526 519 rs.close() 527 520 except: … … 529 522 530 523 524 ''' 525 Gets the id for the provided file 526 ''' 527 def getRegionNameFromThisDvoIndex(self, index): 528 529 region = "" 530 sql = "SELECT NAME FROM " + self.dvoSkyTable + " WHERE INDEX_ = " + str(index) 531 try: 532 rs = self.executeQuery(sql) 533 rs.first() 534 region = rs.getString(1) 535 rs.close() 536 except: 537 self.logger.errorPair("Could not get region using index", sql ) 538 539 return region 540
Note:
See TracChangeset
for help on using the changeset viewer.
