Changeset 33948 for branches/eam_branches/ipp-20120405/ippToPsps
- Timestamp:
- May 29, 2012, 5:07:20 PM (14 years ago)
- Location:
- branches/eam_branches/ipp-20120405/ippToPsps
- Files:
-
- 6 deleted
- 28 edited
- 2 copied
-
config/ippToPspsDbSchema.sql (modified) (8 diffs)
-
config/settings.xml (modified) (1 diff)
-
docs (deleted)
-
jython/batch.py (modified) (4 diffs)
-
jython/batchRepublisher.py (copied) (copied from trunk/ippToPsps/jython/batchRepublisher.py )
-
jython/cleanup.py (modified) (9 diffs)
-
jython/config.py (modified) (2 diffs)
-
jython/console.py (copied) (copied from trunk/ippToPsps/jython/console.py )
-
jython/datastore.py (modified) (1 diff)
-
jython/datastoreRemover.py (modified) (1 diff)
-
jython/detectionbatch.py (modified) (6 diffs)
-
jython/dvo.py (modified) (6 diffs)
-
jython/dvoToMySQL.py (deleted)
-
jython/gpc1db.py (modified) (4 diffs)
-
jython/initbatch.py (modified) (2 diffs)
-
jython/ipptopsps.py (modified) (6 diffs)
-
jython/ipptopspsdb.py (modified) (4 diffs)
-
jython/loader.py (modified) (6 diffs)
-
jython/metrics.py (modified) (1 diff)
-
jython/mysql.py (modified) (6 diffs)
-
jython/objectbatch.py (modified) (11 diffs)
-
jython/odm.py (modified) (1 diff)
-
jython/plot.py (modified) (1 diff)
-
jython/plotter.py (modified) (1 diff)
-
jython/pollOdm.py (modified) (3 diffs)
-
jython/queue.py (modified) (5 diffs)
-
jython/regionTest.py (deleted)
-
jython/reportloadfailures.py (deleted)
-
jython/republishbatch.py (deleted)
-
jython/run.sh (modified) (1 diff)
-
jython/scratchdb.py (modified) (3 diffs)
-
jython/setupScratchDb.py (modified) (2 diffs)
-
jython/stackbatch.py (modified) (4 diffs)
-
jython/stilts.py (deleted)
-
perl/pspsSchema2xml.pl (modified) (9 diffs)
-
src/Dvo.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120405/ippToPsps/config/ippToPspsDbSchema.sql
r33593 r33948 45 45 `purged` tinyint(4) NOT NULL default '0', 46 46 PRIMARY KEY (`batch_id`) 47 ) ENGINE=InnoDB AUTO_INCREMENT=32 6479DEFAULT CHARSET=latin1;47 ) ENGINE=InnoDB AUTO_INCREMENT=328286 DEFAULT CHARSET=latin1; 48 48 SET character_set_client = @saved_cs_client; 49 49 … … 65 65 KEY `fk_config` (`config`), 66 66 CONSTRAINT `fk_config` FOREIGN KEY (`config`) REFERENCES `config` (`name`) ON DELETE CASCADE 67 ) ENGINE=InnoDB AUTO_INCREMENT= 25457DEFAULT CHARSET=latin1;67 ) ENGINE=InnoDB AUTO_INCREMENT=44588 DEFAULT CHARSET=latin1; 68 68 SET character_set_client = @saved_cs_client; 69 69 … … 87 87 PRIMARY KEY (`id`), 88 88 UNIQUE KEY `unique_key` (`host`,`pid`) 89 ) ENGINE=InnoDB AUTO_INCREMENT= 961DEFAULT CHARSET=latin1;89 ) ENGINE=InnoDB AUTO_INCREMENT=1227 DEFAULT CHARSET=latin1; 90 90 SET character_set_client = @saved_cs_client; 91 91 … … 110 110 `max_dec` double default '90', 111 111 `box_size` double default '4', 112 `base_path` varchar(1000) default NULL,112 `base_path` varchar(1000) default '/data/ipp005.0/ipptopsps/', 113 113 `data_release` smallint(6) default '0', 114 114 `delete_local` tinyint(1) default '0', … … 120 120 `queue_P2` tinyint(1) default '1', 121 121 `queue_ST` tinyint(1) default '0', 122 `queue_OB` tinyint(1) default '0', 123 `active` tinyint(1) default '1', 122 124 UNIQUE KEY `name` (`name`) 123 125 ) ENGINE=InnoDB DEFAULT CHARSET=latin1; … … 141 143 142 144 -- 145 -- Table structure for table `object` 146 -- 147 148 DROP TABLE IF EXISTS `object`; 149 SET @saved_cs_client = @@character_set_client; 150 SET character_set_client = utf8; 151 CREATE TABLE `object` ( 152 `batch_id` bigint(20) unsigned NOT NULL, 153 `region` varchar(50) default NULL, 154 KEY `batch_id` (`batch_id`), 155 CONSTRAINT `object_fk_1` FOREIGN KEY (`batch_id`) REFERENCES `batch` (`batch_id`) 156 ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 157 SET character_set_client = @saved_cs_client; 158 159 -- 143 160 -- Table structure for table `pending` 144 161 -- … … 151 168 `batch_type` varchar(10) default NULL, 152 169 `stage_id` bigint(20) default NULL, 153 `ra_bore` float default NULL,154 `dec_bore` float default NULL,155 170 UNIQUE KEY `a_key` (`box_id`,`stage_id`,`batch_type`), 171 UNIQUE KEY `stage_id_key` (`stage_id`), 156 172 CONSTRAINT `box_key` FOREIGN KEY (`box_id`) REFERENCES `box` (`id`) ON DELETE CASCADE 157 173 ) ENGINE=InnoDB DEFAULT CHARSET=latin1; … … 199 215 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 200 216 201 -- Dump completed on 2012-0 3-22 7:59:34217 -- Dump completed on 2012-04-10 6:00:59 -
branches/eam_branches/ipp-20120405/ippToPsps/config/settings.xml
r33594 r33948 5 5 6 6 <!-- path for storing logs --> 7 <logPath>/data/ipp005.0/ rhenders</logPath>7 <logPath>/data/ipp005.0/ipptopsps</logPath> 8 8 9 9 <!-- local scratch Db section --> -
branches/eam_branches/ipp-20120405/ippToPsps/jython/batch.py
r33672 r33948 39 39 useFullTables): 40 40 41 self.everythingOK = False42 41 self.readHeader = False 43 42 self.config = config … … 66 65 if not self.header: 67 66 logger.errorPair("Could not read FITS for id", "%d" % id) 68 r eturn67 raise 69 68 70 69 self.scratchDb.setUseFullTables(self.useFullTables) … … 115 114 self.logger.infoPair("Output path", self.localOutPath) 116 115 117 self.everythingOK = True118 116 119 117 ''' … … 510 508 def run(self): 511 509 512 if not self.everythingOK:513 self.logger.errorPair("Aborting this batch", "could not initialize")514 self.ippToPspsDb.updateProcessed(self.batchID, -1)515 return516 517 510 if not self.createEmptyPspsTables(): 518 511 self.logger.errorPair("Aborting this batch", "could not create empty PSPS tables") 519 512 self.ippToPspsDb.updateProcessed(self.batchID, -1) 520 r eturn513 raise 521 514 522 515 if not self.importIppTables(): 523 516 self.logger.errorPair("Aborting this batch", "could not import IPP tables") 524 517 self.ippToPspsDb.updateProcessed(self.batchID, -1) 525 r eturn518 raise 526 519 527 520 if not self.populatePspsTables(): 528 521 self.logger.errorPair("Aborting this batch", "unable to populate PSPS tables") 529 522 self.ippToPspsDb.updateProcessed(self.batchID, -1) 530 r eturn523 raise 531 524 532 525 if not self.exportPspsTablesToFits(): 533 526 self.logger.errorPair("Aborting this batch", "unable to export tables to FITS file") 534 527 self.ippToPspsDb.updateProcessed(self.batchID, -1) 535 r eturn528 raise 536 529 537 530 if self.writeBatchManifest(): -
branches/eam_branches/ipp-20120405/ippToPsps/jython/cleanup.py
r33708 r33948 7 7 import sys 8 8 import time 9 import traceback 9 10 import logging.config 10 11 … … 41 42 self.logger.infoPair("Config", self.config.name) 42 43 self.config.printDeletionPolicy() 44 self.clean("IN") 43 45 self.clean("P2") 44 46 self.clean("ST") … … 48 50 if not self.waitForPollTime(): break 49 51 52 ''' 53 Reports results of cleanup for this set of IDs 54 ''' 55 def reportResults(self, name, ids, success): 56 57 if len(ids) > 0: 58 self.logger.infoSeparator() 59 self.logger.infoPair("Removed from " + name, "%d of %d" % (success, len(ids))) 60 61 50 62 ''' 51 63 Finds stuff to delete for this batch type, then: … … 62 74 63 75 loadedDatastoreIDs = self.ippToPspsDb.getLoadedToODMButNotDeletedFromDatastore(batchType) 64 loadedDxlayerIDs = self.ippToPspsDb.getLoadedToODMButNotDeletedFromDXLayer(batchType)76 deleteFromDxLayerIDs = self.ippToPspsDb.getLoadedToODMButNotDeletedFromDXLayer(batchType) 65 77 mergedLocalIDs = self.ippToPspsDb.getMergedButNotDeletedFromLocalDisk(batchType) 66 78 … … 68 80 purgedLocalIDs = self.ippToPspsDb.getPurgedButNotDeletedFromLocalDisk(batchType) 69 81 70 self.logger.infoPair("Loaded to ODM but still on datastore", "%d" % len(loadedDatastoreIDs)) 71 self.logger.infoPair("Loaded to ODM but still in DXLayer", "%d" % len(loadedDxlayerIDs)) 72 self.logger.infoPair("Merged but still on local disk", "%d" % len(mergedLocalIDs)) 73 self.logger.infoPair("Purged but still on datastore", "%d" % len(purgedDatastoreIDs)) 74 self.logger.infoPair("Purged but still on local disk", "%d" % len(purgedLocalIDs)) 82 deleteFromDatastoreIDs = loadedDatastoreIDs + purgedDatastoreIDs 83 deleteFromLocalIDs = mergedLocalIDs + purgedLocalIDs 84 85 # report to log what we are going to do 86 self.logger.infoPair("To delete from datastore", "%d" % len(deleteFromDatastoreIDs)) 87 self.logger.infoPair("To delete from DXLayer", "%d" % len(deleteFromDxLayerIDs)) 88 self.logger.infoPair("To delete from local disk", "%d" % len(deleteFromLocalIDs)) 75 89 90 # delete stuff from local disk 76 91 if self.config.deleteLocal: 77 self.logger.infoSeparator()78 92 count = 0 79 ids = mergedLocalIDs + purgedLocalIDs 80 for id in ids: 93 for id in deleteFromLocalIDs: 81 94 82 95 if Batch.deleteFromDisk(self.logger, self.config.basePath, batchType, self.config.dvoLabel, id): … … 84 97 count = count + 1 85 98 86 self.logger.infoSeparator() 87 self.logger.infoPair("Removed from local disk", "%d" % count) 88 self.logger.infoPair("Remaining on local disk", "%d" % (len(ids) - count)) 89 99 self.reportResults("local disk", deleteFromLocalIDs, count) 90 100 101 # remove stuff from datastore 91 102 if self.config.deleteDatastore: 92 self.logger.infoSeparator()93 103 count = 0 94 ids = loadedDatastoreIDs + purgedDatastoreIDs 95 for id in ids: 104 for id in deleteFromDatastoreIDs: 96 105 97 106 batchName = Batch.getNameFromID(id) … … 100 109 count = count + 1 101 110 102 self.logger.infoSeparator() 103 self.logger.infoPair("Removed from datastore", "%d" % count) 104 self.logger.infoPair("Remaining on datastore", "%d" % (len(ids) - count)) 111 self.reportResults("datastore", deleteFromDatastoreIDs, count) 105 112 113 # remove stuff from DXLayer 106 114 if self.config.deleteDxLayer: 107 self.logger.infoSeparator()108 115 count = 0 109 for id in loadedDxlayerIDs:116 for id in deleteFromDxLayerIDs: 110 117 111 118 if self.dxlayer.deleteBatch(id): … … 113 120 count = count + 1 114 121 115 self.logger.infoSeparator() 116 self.logger.infoPair("Removed from DXLayer", "%d" % count) 117 self.logger.infoPair("Remaining on DXLayer", "%d" % (len(loadedDxlayerIDs) - count)) 122 self.reportResults("DXLayer", deleteFromDxLayerIDs, count) 118 123 119 120 124 ''' 121 125 Overrides base-class version … … 128 132 Start of program 129 133 ''' 130 cleanup = Cleanup(sys.argv) 131 cleanup.run() 132 cleanup.exitProgram("finished") 134 try: 135 cleanup = Cleanup(sys.argv) 136 cleanup.run() 137 cleanup.exitProgram("completed") 138 except Exception, e: 139 print str(e) 140 traceback.print_exc() -
branches/eam_branches/ipp-20120405/ippToPsps/jython/config.py
r33558 r33948 39 39 ''' 40 40 def printAll(self): 41 42 self.logger.infoTitle("Config") 41 43 42 44 try: … … 133 135 def getDbPassword(self, dbType): return self.settingsDoc.find(dbType +"/password").text 134 136 135 -
branches/eam_branches/ipp-20120405/ippToPsps/jython/datastore.py
r33259 r33948 102 102 103 103 firstInt = int(first[1:]) 104 lastInt = int(last[1:]) 104 lastInt = int(last[1:]) + 1 105 105 106 106 for i in range(firstInt, lastInt): -
branches/eam_branches/ipp-20120405/ippToPsps/jython/datastoreRemover.py
r33470 r33948 46 46 Start of program 47 47 ''' 48 datastoreRemover = DatastoreRemover(sys.argv) 49 datastoreRemover.run() 50 datastoreRemover.exitProgram("finished") 48 try: 49 datastoreRemover = DatastoreRemover(sys.argv) 50 datastoreRemover.run() 51 datastoreRemover.exitProgram("completed") 52 except: pass 51 53 -
branches/eam_branches/ipp-20120405/ippToPsps/jython/detectionbatch.py
r33353 r33948 53 53 useFullTables) 54 54 55 if not self.everythingOK: return56 57 55 # get camera meta data 58 56 meta = self.gpc1Db.getCameraStageMeta(self.id) 59 57 if not meta: 60 self. everythingOK = False61 r eturn58 self.logger.errorPair("Could not get", "camera metadata") 59 raise 62 60 63 61 self.expID = meta[0]; … … 93 91 # get a fre primary header values. if in test mode, then use defaults 94 92 if self.safeDictionaryAccessWithDefault(self.header, 'MJD-OBS', "1") == "NULL": 95 self. everythingOK = False96 r eturn93 self.logger.errorPair("Could not get", "MJD-OBS") 94 raise 97 95 98 96 if self.safeDictionaryAccessWithDefault(self.header, 'EXPTIME', "1") == "NULL": 99 self. everythingOK = False100 r eturn97 self.logger.errorPair("Could not get", "EXPTIME") 98 raise 101 99 102 100 if self.safeDictionaryAccessWithDefault(self.header, 'FILTERID', "g.0000") == "NULL": 103 self. everythingOK = False104 r eturn101 self.logger.errorPair("Could not get", "FILTERID") 102 raise 105 103 106 104 self.obsTime = float(self.header['MJD-OBS']) + (float(self.header['EXPTIME']) / 172800.0) … … 418 416 ,momentYY \ 419 417 ,apMag \ 418 ,kronFlux \ 419 ,kronFluxErr \ 420 420 ,infoFlag \ 421 421 ,sky \ … … 436 436 ,X_PSF_SIG \ 437 437 ,Y_PSF_SIG \ 438 ,POW(10.0, (-0.4*PSF_INST_MAG)) / " +self.header['EXPTIME']+" \439 ,ABS((PSF_INST_MAG_SIG*(POW(10.0, (-0.4*PSF_INST_MAG)) / " +self.header['EXPTIME']+")) / 1.085736) \440 ,POW(10.0, (-0.4*PEAK_FLUX_AS_MAG)) / " +self.header['EXPTIME']+" \438 ,POW(10.0, (-0.4*PSF_INST_MAG)) / " + self.header['EXPTIME'] + " \ 439 ,ABS((PSF_INST_MAG_SIG*(POW(10.0, (-0.4*PSF_INST_MAG)) / " + self.header['EXPTIME'] + ")) / 1.085736) \ 440 ,POW(10.0, (-0.4*PEAK_FLUX_AS_MAG)) / " + self.header['EXPTIME'] + " \ 441 441 ,PSF_MAJOR \ 442 442 ,PSF_MINOR \ … … 448 448 ,MOMENTS_YY \ 449 449 ,AP_MAG \ 450 ,KRON_FLUX / " + self.header['EXPTIME'] + " \ 451 ,KRON_FLUX_ERR / " + self.header['EXPTIME'] + " \ 450 452 ,FLAGS\ 451 453 ,SKY \ … … 755 757 else : regex = ".*.psf" 756 758 757 columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG PSF_INST_MAG PSF_INST_MAG_SIG PEAK_FLUX_AS_MAG PSF_MAJOR PSF_MINOR PSF_THETA EXT_NSIGMA PSF_QF MOMENTS_XX MOMENTS_XY MOMENTS_YY AP_MAG FLAGS SKY SKY_SIGMA EXT_NSIGMA"759 columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG PSF_INST_MAG PSF_INST_MAG_SIG PEAK_FLUX_AS_MAG PSF_MAJOR PSF_MINOR PSF_THETA EXT_NSIGMA PSF_QF MOMENTS_XX MOMENTS_XY MOMENTS_YY AP_MAG KRON_FLUX KRON_FLUX_ERR FLAGS SKY SKY_SIGMA EXT_NSIGMA" 758 760 759 761 return super(DetectionBatch, self).importIppTables(columns, regex) -
branches/eam_branches/ipp-20120405/ippToPsps/jython/dvo.py
r33676 r33948 17 17 from java.sql import * 18 18 19 20 19 ''' 21 20 Abstract base-class for DVO classes … … 48 47 49 48 # connect to the specified scratch database 50 self.scratchDb = ScratchDb(self.logger, self.config, scratchDbName) 49 try: 50 self.scratchDb = ScratchDb(self.logger, self.config, scratchDbName) 51 except: raise 52 51 53 self.scratchDb.setUseFullTables(True) 52 54 … … 90 92 return 91 93 92 93 94 ''' 94 95 Loads the DVO Photcodes.dat FITS file … … 218 219 self.regionsAlreadyIngested = [] 219 220 self.regionsIngestedButOutOfDate = [] 221 tablesToCleanup = [] 220 222 221 223 # loop through all regions in DVO inside this bounding-box … … 256 258 continue 257 259 260 # we have no record of ingesting this region, but does the table exist? 261 # May hev been left behind after a crash, and therefore needs to be cleaned-up 262 for fileType in self.ingestFileTypes: 263 tableName = self.scratchDb.getDbFriendlyTableName(regionPath + "." + fileType) 264 if self.scratchDb.tableExists(tableName): 265 tablesToCleanup.append(tableName) 266 258 267 # check if we have out-of-date versions of any interested files, if so, add region to the purge list 259 268 outOfDate = False … … 279 288 self.sizeOfRegionsToPurge = self.getDiskSizeOfRegions(self.regionsToPurge) 280 289 self.sizeOfRegionsToIngest = self.getDiskSizeOfRegions(self.regionsToIngest) 290 291 # any tables need cleaning up? 292 if len(tablesToCleanup) > 0: 293 self.logger.infoPair("Found tables to be cleaned up", "%d" % len(tablesToCleanup)) 294 self.scratchDb.dropTables(tablesToCleanup) 295 281 296 282 297 ''' -
branches/eam_branches/ipp-20120405/ippToPsps/jython/gpc1db.py
r33527 r33948 72 72 elif batchType == "ST": 73 73 74 stage = "staticsky _multi"75 sql = "SELECT DISTINCT stack_id, ra , declFROM staticskyInput \74 stage = "staticsky" 75 sql = "SELECT DISTINCT stack_id, radeg, decdeg FROM staticskyInput \ 76 76 JOIN addRun ON(staticskyInput.sky_id = addRun.stage_id) \ 77 77 JOIN minidvodbRun USING(minidvodb_name) \ 78 78 JOIN minidvodbProcessed USING(minidvodb_id) \ 79 JOIN stackRun USING(stack_id) JOIN skycell s.skycellUSING(skycell_id) \79 JOIN stackRun USING(stack_id) JOIN skycell USING(skycell_id) \ 80 80 WHERE minidvodbRun.minidvodb_group = '" + dvoDb + "' \ 81 81 AND minidvodbRun.state = 'merged' \ … … 83 83 AND addRun.stage = '" + stage + "' \ 84 84 AND addRun.state = 'full' \ 85 AND dec lBETWEEN " + str(minDec) + " AND " + str(maxDec) + " \86 AND ra BETWEEN " + str(minRA) + " AND " + str(maxRA)85 AND decdeg BETWEEN " + str(minDec) + " AND " + str(maxDec) + " \ 86 AND radeg BETWEEN " + str(minRA) + " AND " + str(maxRA) 87 87 88 88 try: … … 266 266 AND minidvodbRun.minidvodb_group = '" + dvoDb + "' \ 267 267 AND minidvodbRun.state = 'merged' \ 268 AND stage = 'staticsky _multi'"268 AND stage = 'staticsky'" 269 269 ''' 270 270 … … 282 282 AND mergedvodbRun.state = 'full' \ 283 283 AND mergedvodbRun.mergedvodb = '" + dvoDb + "' \ 284 AND stage = 'staticsky _multi'"284 AND stage = 'staticsky'" 285 285 286 286 -
branches/eam_branches/ipp-20120405/ippToPsps/jython/initbatch.py
r33353 r33948 50 50 ''' 51 51 def importIppTables(self, filter=""): 52 self.logger.debug("importIppTables method here to satidfy base-class") 52 self.logger.debug("importIppTables method here to satisfy base-class") 53 return True 53 54 54 55 ''' … … 63 64 def populatePspsTables(self): 64 65 self.logger.debug("No processing required for this batch type") 65 return 166 return True 66 67 -
branches/eam_branches/ipp-20120405/ippToPsps/jython/ipptopsps.py
r33711 r33948 38 38 self.SECONDS = None 39 39 40 self.createNewConfig = False 41 self.rotateConfigs = False 42 # a new config? 43 if CONFIGNAME == "edit": self.createNewConfig = True 40 44 # should we rotate configs for this program? 41 if CONFIGNAME == "all": self.rotateConfigs = True 42 else: self.rotateConfigs = False 45 elif CONFIGNAME == "all": self.rotateConfigs = True 43 46 44 47 # set up config object … … 47 50 48 51 # create connection to databases database 49 self.ippToPspsDb = IppToPspsDb(self.logger, self.config) 52 try: 53 self.ippToPspsDb = IppToPspsDb(self.logger, self.config) 54 except: 55 self.exitProgram("Could not connect to ipptopsps Db") 56 raise 50 57 51 58 self.checkClientStatus() … … 59 66 self.logger.infoPair("Host", self.HOST) 60 67 self.logger.infoPair("PID", "%d" % self.PID) 61 self.logger.infoPair("Config", CONFIGNAME)68 self.logger.infoPair("Config", self.config.name) 62 69 63 70 ''' … … 97 104 98 105 # write message to log or stdout if no logger set up 99 msg = sys.argv[0] + " <configName|all > " + extra106 msg = sys.argv[0] + " <configName|all|edit> " + extra 100 107 try: 101 108 self.logger.errorPair("Usage:", msg) … … 103 110 print "*** Usage: " + msg 104 111 105 106 112 ''' 107 113 Refreshes the config then recreates objects with new settings 108 114 ''' 109 115 def refreshConfig(self): 116 117 # new config? 118 if self.createNewConfig: 119 self.ippToPspsDb.editConfig() 120 self.ippToPspsDb.setConfigForThisClient(self.config.name, self.HOST, self.PID) 121 self.createNewConfig = False 110 122 111 123 # if we are rotating configs, then look for next active one in list … … 163 175 # write message to log or stdout if no logger set up 164 176 try: 165 self.logger.infoPair( "Programexited", exitReason)177 self.logger.infoPair(self.PROGNAME + " exited", exitReason) 166 178 except: 167 179 print "*** Program exited: " + exitReason -
branches/eam_branches/ipp-20120405/ippToPsps/jython/ipptopspsdb.py
r33710 r33948 854 854 return configs 855 855 856 857 ''' 858 Writes current Config object to Db 859 ''' 860 def writeConfig(self): 861 862 sql = "UPDATE config \ 863 SET \ 864 datastore_product = '" + self.config.datastoreProduct + "' \ 865 ,datastore_type = '" + self.config.datastoreType + "' \ 866 ,datastore_publish = " + self.config.datastorePublishing + " \ 867 ,dvo_label = '" + self.config.dvoLabel + "' \ 868 ,dvo_location = '" + self.config.dvoLocation + "' \ 869 ,min_ra = " + self.config.minRa + " \ 870 ,max_ra = " + self.config.maxRa + " \ 871 ,min_dec = " + self.config.minDec + " \ 872 ,max_dec = " + self.config.maxDec + " \ 873 ,box_size = " + self.config.boxSize + " \ 874 ,base_path = '" + self.config.basePath + "' \ 875 ,data_release = " + self.config.dataRelease + " \ 876 ,delete_local = " + self.config.deleteLocal + " \ 877 ,delete_datastore = " + self.config.deleteDatastore + " \ 878 ,delete_dxlayer = " + self.config.deleteDxLayer + " \ 879 ,epoch = '" + self.config.epoch + "' \ 880 ,survey = '" + self.config.survey + "' \ 881 ,psps_survey = '" + self.config.pspsSurvey + "' \ 882 ,queue_P2 = " + self.config.queuingThisBatchType("P2") + " \ 883 ,queue_ST = " + self.config.queuingThisBatchType("ST") + " \ 884 ,queue_OB = " + self.config.queuingThisBatchType("OB") + " \ 885 WHERE name = '" + self.config.name + "'" 886 887 self.execute(sql) 856 ''' 857 Prompts user for info about a new or existing config and lets them neter the various details 858 ''' 859 def editConfig(self): 860 861 print " ********************************************************************" 862 print " * Config editor" 863 print " *" 864 response = raw_input(" * Name for new config, or existing config to edit? ") 865 if response == "": return 866 self.config.name = response 867 868 # attempt to insert new config, if it already exists then carry on with update 869 sql = "INSERT INTO config (name) VALUES ('" + self.config.name + "')" 870 try: 871 self.execute(sql) 872 except: pass 873 874 # for each column in the config table 875 sql = "SHOW COLUMNS FROM config" 876 rs = self.executeQuery(sql) 877 while (rs.next()): 878 879 field = rs.getString(1) 880 type = rs.getString(2) 881 null = rs.getString(3) 882 883 # things we don;t want the user to edit 884 if field == 'timestamp': continue 885 if field == 'name': continue 886 887 # get current value for this field, if any 888 try: 889 rs2 = self.executeQuery("SELECT " + field + " FROM config WHERE name = '" + self.config.name + "'") 890 rs2.first() 891 default = rs2.getString(1) 892 except: pass 893 894 question = " * " + field + " (" + type + ")" 895 896 # there may not be a default value 897 try: question = question + " hit return to accept default of: '" + default + "'" 898 except: pass 899 900 # prompt the user for new value or to accept existing value 901 question = question + "? " 902 response = raw_input(question) 903 if response != "": 904 if type.find("varchar") != -1 or type.find("timestamp") != -1: quotes = "'" 905 else: quotes = "" 906 self.execute("UPDATE config SET " + field + " = " + quotes + response + quotes + " WHERE name = '" + self.config.name + "'") 907 908 print " *" 909 print " ********************************************************************" 888 910 889 911 ''' … … 951 973 else: self.config.datastorePublishing = False 952 974 self.config.dvoLabel = rs.getString(4) 975 976 # if dvoLabel is null is can break queries, so set to something 977 if not self.config.dvoLabel: self.config.dvoLabel = "none" 953 978 self.config.dvoLocation = rs.getString(5) 954 979 self.config.minRa = rs.getDouble(6) … … 1255 1280 1256 1281 self.execute("CREATE TEMPORARY TABLE all_pending (stage_id bigint(20), ra_bore float, dec_bore float)") 1257 count = 01258 1282 for row in rows: 1259 1283 … … 1262 1286 VALUES (%d, %f, %f)" % (row[0], row[1], row[2]) 1263 1287 self.execute(sql) 1264 count += 11265 1288 except: continue 1266 1289 1267 self.logger.infoPair("All items written to Db", "%d" % count) 1290 count = self.getRowCount("all_pending") 1291 self.logger.infoPair("Items written to Db", "%d" % count) 1268 1292 1269 1293 ''' -
branches/eam_branches/ipp-20120405/ippToPsps/jython/loader.py
r33677 r33948 45 45 self.scratchDb.disconnect() 46 46 continue 47 self.logger.infoPair("Using scratch Db", self.scratchDb.dbName)48 47 break 49 48 50 if not self.scratchDb.connected: 51 self.logger.errorPair("Cannot connect to a", "scratch database") 49 if not self.scratchDb.connected: 50 self.exitProgram("Cannot connect to a scratch database") 51 raise 52 52 53 53 # create Datastore objects … … 108 108 ''' 109 109 def run(self): 110 111 if not self.scratchDb.connected: return 110 112 111 113 numAttempts = 0 … … 152 154 if batchType != "OB": 153 155 # look in DVO for this box (with extra border) 154 #self.dvoDetections.setSkyAreaAsBox(boxDim['RA'], boxDim['DEC'], boxSizeWithBorder) 155 self.dvoDetections.setSkyArea() 156 self.logger.infoPair("Querying DVO for this sky area", "") 157 self.dvoDetections.setSkyAreaAsBox(boxDim['RA'], boxDim['DEC'], boxSizeWithBorder) 158 #self.dvoDetections.setSkyArea() 156 159 sizeToBeIngested = self.dvoDetections.getDiskSizeOfRegionsToBeIngested() 157 160 if sizeToBeIngested == 0.0: smfsPerGB = 999999999 … … 160 163 self.logger.infoPair("smfs-per-GB", "%.1f" % smfsPerGB) 161 164 # should do we pre-ingest stuff from DVO? 162 if smfsPerGB > 30:165 if batchType == 'P2' and smfsPerGB > 30: 163 166 if not self.dvoDetections.sync(): 164 167 self.logger.errorPair("Could not sync DVO with MySQL", "skipping") … … 195 198 196 199 self.ippToPspsDb.unlockTables() 200 self.ippToPspsDb.deletePendingItem(batchType, id) 201 202 # catch any raised exceptions in batch constructors 203 try: 204 if batchType == "P2": 205 batch = DetectionBatch(self.logger, 206 self.config, 207 self.gpc1Db, 208 self.ippToPspsDb, 209 self.scratchDb, 210 id, 211 batchID, 212 useFullTables) 213 elif batchType == "ST": 214 batch = StackBatch(self.logger, 215 self.config, 216 self.gpc1Db, 217 self.ippToPspsDb, 218 self.scratchDb, 219 id, 220 batchID, 221 useFullTables) 222 223 elif batchType == "OB": 224 batch = ObjectBatch(self.logger, 225 self.config, 226 self.gpc1Db, 227 self.ippToPspsDb, 228 self.scratchDb, 229 id, 230 batchID, 231 useFullTables) 232 233 batch.run() 197 234 198 self.ippToPspsDb.deletePendingItem(batchType, id) 199 200 if batchType == "P2": 201 batch = DetectionBatch(self.logger, 202 self.config, 203 self.gpc1Db, 204 self.ippToPspsDb, 205 self.scratchDb, 206 id, 207 batchID, 208 useFullTables) 209 elif batchType == "ST": 210 batch = StackBatch(self.logger, 211 self.config, 212 self.gpc1Db, 213 self.ippToPspsDb, 214 self.scratchDb, 215 id, 216 batchID, 217 useFullTables) 218 219 elif batchType == "OB": 220 batch = ObjectBatch(self.logger, 221 self.config, 222 self.gpc1Db, 223 self.ippToPspsDb, 224 self.scratchDb, 225 id, 226 batchID, 227 useFullTables) 228 229 batch.run() 230 235 # if batch fails, ignore and move on to the next one 236 except: 237 self.logger.errorPair("Problem with this %s batch (%d)" % (batchType, id), "skipping") 238 pass 239 231 240 if not self.checkClientStatus(): return False 232 241 … … 253 262 loader = Loader(sys.argv) 254 263 loader.run() 255 loader.exitProgram(" finished")264 loader.exitProgram("completed") 256 265 except Exception, e: 257 266 print str(e) 258 267 traceback.print_exc() 268 -
branches/eam_branches/ipp-20120405/ippToPsps/jython/metrics.py
r33712 r33948 191 191 Start of program. 192 192 ''' 193 metrics = Metrics(sys.argv) 194 metrics.run() 195 metrics.exitProgram("finished") 196 197 198 193 try: 194 metrics = Metrics(sys.argv) 195 metrics.run() 196 metrics.exitProgram("completed") 197 except: pass 198 199 200 -
branches/eam_branches/ipp-20120405/ippToPsps/jython/mysql.py
r33683 r33948 34 34 self.dbPass = config.getDbPassword(dbType) 35 35 36 # a user friendly connection sring 37 connectionStr = self.dbName + "@" + self.dbHost 38 36 39 # set up JDBC connection 37 40 self.url = "jdbc:mysql://"+self.dbHost+"/"+self.dbName+"?autoReconnect=true&user="+self.dbUser+"&password="+self.dbPass … … 39 42 self.con = DriverManager.getConnection(self.url) 40 43 self.connectionID = self.getLastConnectionID() 41 self.logger. debug("MySQL connection to %s with ID %d" % (dbType, self.connectionID))44 self.logger.infoPair("Connected to MySQL Db", connectionStr) 42 45 except: 43 self.logger.error("Unable to connect to " + self.url) 44 self.everythingOK = False # TODO need this? 46 self.logger.errorPair("Unable to connect to", connectionStr) 45 47 self.connected = False 46 return 47 48 self.everythingOK = True 48 raise 49 49 50 self.connected = True 50 51 … … 88 89 sql = "KILL %d" % connectionID 89 90 self.execute(sql) 91 92 ''' 93 Checks whether this table exists 94 ''' 95 def tableExists(self, tableName): 96 97 sql = "SELECT COUNT(*) \ 98 FROM information_schema.tables \ 99 WHERE table_schema = '" + self.dbName + "' \ 100 AND table_name = '" + tableName + "'" 101 102 try: 103 rs = self.executeQuery(sql) 104 rs.first() 105 if rs.getInt(1) > 0: return True 106 else: return False 107 except: 108 self.logger.errorPair("Could not check if table exists", sql) 109 pass 110 111 return False 90 112 91 113 ''' … … 159 181 160 182 ''' 183 Drops a list of tables 184 ''' 185 def dropTables(self, tables): 186 for table in tables: self.dropTable(table) 187 188 ''' 161 189 Drops a table 162 190 ''' … … 224 252 except: pass 225 253 #self.logger.warn("Index already in place on '" + column + "' for table '" + table + "'") 254 255 ''' 256 Checks that we have a connection 257 ''' 258 def isConnected(self): 259 260 try: 261 self.con 262 self.connected = True 263 except: 264 self.logger.errorPair("Not connected to", self.url) 265 self.connected = False 266 267 return self.connected 268 226 269 ''' 227 270 TODO 228 271 ''' 229 272 def execute(self, sql): 273 274 if not self.isConnected(): raise 230 275 231 276 stmt = self.con.createStatement() … … 238 283 def executeQuery(self, sql): 239 284 285 if not self.isConnected(): raise 286 240 287 stmt = self.con.createStatement() 241 288 rs = stmt.executeQuery(sql) -
branches/eam_branches/ipp-20120405/ippToPsps/jython/objectbatch.py
r33715 r33948 51 51 1) 52 52 53 if not self.everythingOK: return 54 55 self.dvoObjects = DvoObjects(self.logger, self.config, self.scratchDb.dbName) 53 try: 54 self.dvoObjects = DvoObjects(self.logger, self.config, self.scratchDb.dbName) 55 except: 56 self.logger.errorPair("Unable to create instance of", "DvoObjects") 57 raise 56 58 57 59 # create an output filename, which is {dvoINDEX}.FITS … … 78 80 def alterPspsTables(self): 79 81 80 self.logger.debug("Altering PSPS tables") 82 # dec is reserved in MySQL, so STILTS replaces if with dec_, which PSPS doesn't like. so, force it back again using `` 83 self.scratchDb.execute("ALTER TABLE Object CHANGE dec_ `dec` double") 84 81 85 return True 82 86 … … 95 99 def insertMags(self, cpsTable): 96 100 97 # list of all filters we areinterested in98 allFilters = ['g', 'r', 'i', 'z', 'y']101 # list of all filters PSPS is interested in 102 interestedFilters = ['g', 'r', 'i', 'z', 'y'] 99 103 100 # this loop looks into the DVO Photcodes tables and gets the 'CODE' for each the filters above that are listed 101 filters = [] 102 for filter in allFilters: 103 code = self.scratchDb.getCodeForThisFilter(filter) 104 if code < 0: continue 105 filters.append([code, filter]) 104 filters = self.scratchDb.getOrderedListOfFiltersFromPhotcodesTable(interestedFilters) 106 105 107 106 # get a count of the available filters 108 107 filterCount = len(filters) 109 108 110 self.logger.infoPair("Available filters ", filters)109 self.logger.infoPair("Available filters in Photcodes", filters) 111 110 112 111 # the 'code' now defines the order in the cps file that the mags are listed for a given filter 112 self.logger.infoPair("Adding magnitudes from", "cps table") 113 113 for filter in filters: 114 114 115 115 sql = "UPDATE Object \ 116 JOIN " + cpsTable + " AS cps ON (cps.row = (Object.row*" + str(filterCount) + ")- " + str(filter[0]) + ") \116 JOIN " + cpsTable + " AS cps ON (cps.row = (Object.row*" + str(filterCount) + ")-(" + str(filterCount) + " - " + str(filter[0]) + ")) \ 117 117 SET \ 118 118 n" + filter[1] + " = NCODE \ … … 120 120 ," + filter[1] + "MeanFlux = 3631 * POW(10.0, (-0.4*MAG)) \ 121 121 ," + filter[1] + "MeanMagErr = MAG_ERR \ 122 ," + filter[1] + "Min = MAG_20 \123 ," + filter[1] + "Max = MAG_80 \122 ," + filter[1] + "Min = MAG_20/1000 \ 123 ," + filter[1] + "Max = MAG_80/1000 \ 124 124 " 125 125 126 self.scratchDb.execute(sql) 127 128 # now set to null all MeanMagErr values > 0.5 (cut set by Gene, 2012-04-12) 129 cut = 0.5 130 self.logger.infoPair("Setting to NULL all MeanMagErr value >", "%f" % cut) 131 for filter in filters: 132 133 sql = "UPDATE Object \ 134 SET " + filter[1] + "MeanMagErr = null \ 135 WHERE " + filter[1] + "MeanMagErr > " + str(cut) 126 136 self.scratchDb.execute(sql) 127 137 … … 131 141 def updateColors(self): 132 142 143 self.logger.infoPair("Calculating", "colors") 133 144 sql = "UPDATE Object \ 134 145 SET \ … … 147 158 self.logger.errorPair("Couldn't calculate colors", sql) 148 159 149 150 ''' 151 Does the processing, i.e. pulling stuff from IPP tables into PSPS tables 152 ''' 153 def populatePspsTables(self): 160 ''' 161 Populates the Object table 162 ''' 163 def populateObjectTable(self): 154 164 155 165 cptTableName = self.scratchDb.getDbFriendlyTableName(self.region + ".cpt") 156 166 cpsTableName = self.scratchDb.getDbFriendlyTableName(self.region + ".cps") 157 167 158 self.logger.infoPair("Inserting objects from", "cpt") 159 sql = "INSERT INTO Object (\ 168 self.logger.infoPair("Populating", "ObjectCalColor") 169 self.logger.infoPair("Inserting objects from", "cpt file") 170 171 # note `` around dec here, as this is a reserved word in MySQL 172 sql = "INSERT IGNORE INTO Object (\ 160 173 objID \ 161 174 ,ippObjID \ 162 175 ,objInfoFlag \ 176 ,varFlag \ 163 177 ,surveyID \ 164 178 ,ra \ 165 , dec_\179 ,`dec` \ 166 180 ,raErr \ 167 181 ,decErr \ 168 182 ,nDetections \ 183 ,dataRelease \ 169 184 ) \ 170 185 SELECT \ … … 172 187 ,CAT_ID*1000000000 + OBJ_ID \ 173 188 ,FLAGS \ 189 ,0 \ 174 190 ," + str(self.surveyID) + " \ 175 191 ,RA \ … … 178 194 ,DEC_ERR \ 179 195 ,NMEASURE \ 196 , " + str(self.config.dataRelease) + "\ 180 197 FROM " + cptTableName 181 198 … … 184 201 except: 185 202 self.logger.errorPair("Couldn't populate Object table", sql) 203 return False 186 204 187 205 # add row count columns so we can perform joins to get colors … … 190 208 self.scratchDb.addRowCountColumn(cpsTableName, "row") 191 209 192 self.logger.infoPair("Adding magnitudes from", "cps table")193 210 self.insertMags(cpsTableName) 194 211 195 self.logger.infoPair("Calculating", "colors")196 212 self.updateColors() 197 213 … … 205 221 return True 206 222 223 ''' 224 Populates the ObjectCalColor table 225 ''' 226 def populateObjectCalColorTable(self): 227 228 self.logger.infoPair("Populating", "ObjectCalColor") 229 230 sql = "INSERT INTO ObjectCalColor ( \ 231 objID \ 232 ,ippObjID \ 233 ,dataRelease \ 234 ) \ 235 SELECT \ 236 objID \ 237 ,ippObjID \ 238 ,dataRelease \ 239 FROM Object" 240 try: 241 self.scratchDb.execute(sql) 242 except: 243 self.logger.errorPair("Couldn't populate ObjectCalColor table", sql) 244 return False 245 246 return True 247 248 ''' 249 Does the processing, i.e. pulling stuff from IPP tables into PSPS tables 250 ''' 251 def populatePspsTables(self): 252 253 if not self.populateObjectTable(): return False 254 #if not self.populateObjectCalColorTable(): return False 255 256 # now remove the objID duplicates. We could not do this before as cpt/cps tables relate by row number 257 self.logger.infoPair("Forcing uniqueness on", "objID in Object table") 258 rowCountBefore = self.scratchDb.getRowCount("Object") 259 self.scratchDb.execute("ALTER IGNORE TABLE Object ADD UNIQUE INDEX(objID)") 260 rowCountAfter = self.scratchDb.getRowCount("Object") 261 self.logger.infoPair("Number of duplicated objIDs removed", "%d out of %d" % ((rowCountBefore - rowCountAfter), rowCountBefore)) 262 263 return True 264 -
branches/eam_branches/ipp-20120405/ippToPsps/jython/odm.py
r33559 r33948 78 78 DETAILS = doc.find("{%s}OdmBatchState/{%s}Details" % (NAMESPACE, NAMESPACE)).text 79 79 results['DETAILS'] = DETAILS 80 if re.search("processing", STATE):80 elif re.search("processing", STATE): 81 81 loadedToODM = 1 82 82 if re.search("MergeWorthy", MESSAGE): -
branches/eam_branches/ipp-20120405/ippToPsps/jython/plot.py
r33685 r33948 62 62 63 63 f.flush() 64 f.close() 64 65 #os.remove(tempFilename) 65 66 -
branches/eam_branches/ipp-20120405/ippToPsps/jython/plotter.py
r33679 r33948 39 39 Start of program 40 40 ''' 41 plotter = Plotter(sys.argv) 42 plotter.exitProgram("finished") 41 try: 42 plotter = Plotter(sys.argv) 43 plotter.exitProgram("completed") 44 except: pass -
branches/eam_branches/ipp-20120405/ippToPsps/jython/pollOdm.py
r33709 r33948 42 42 else: self.stages = [self.STAGE] 43 43 44 if self.BATCHTYPE == "all": self.batchTypes = [' P2', 'ST', 'OB']44 if self.BATCHTYPE == "all": self.batchTypes = ['IN', 'P2', 'ST', 'OB'] 45 45 else: self.batchTypes = [self.BATCHTYPE] 46 46 … … 126 126 ''' 127 127 def printUsage(self): 128 super(PollOdm, self).printUsage("< P2|ST|OB|all> <unloaded|unmergeworthy|unmerged|all> [hours]")128 super(PollOdm, self).printUsage("<IN|P2|ST|OB|all> <unloaded|unmergeworthy|unmerged|all> [hours]") 129 129 130 130 … … 132 132 Program starts here 133 133 ''' 134 pollodm = PollOdm(sys.argv) 135 pollodm.run() 136 pollodm.exitProgram("finished") 134 try: 135 pollodm = PollOdm(sys.argv) 136 pollodm.run() 137 pollodm.exitProgram("completed") 138 except: pass -
branches/eam_branches/ipp-20120405/ippToPsps/jython/queue.py
r33674 r33948 27 27 super(Queue, self).__init__(argv) 28 28 29 30 29 # create various objects 31 30 self.gpc1Db = Gpc1Db(self.logger, self.config) 32 31 self.datastore = Datastore(self.logger, self.config, self.ippToPspsDb) 33 self.dvoObjects = DvoObjects(self.logger, self.config) 32 try: 33 self.dvoObjects = DvoObjects(self.logger, self.config) 34 except: 35 self.exitProgram("Unable to create instance of DvoObject") 36 raise 34 37 35 38 self.config.printAll() … … 115 118 while dec <= self.config.maxDec: 116 119 117 self.checkClientStatus()118 120 box_id = self.ippToPspsDb.insertBox(ra, dec) 119 121 … … 134 136 self.logger.info("+-------------+-------------+-------------+-------------+") 135 137 138 self.checkClientStatus() 136 139 if not self.waitForPollTime(): break 137 140 … … 158 161 ''' 159 162 def printUsage(self): 160 super( Cleanup, self).printUsage("[<repeat time in hours>]")163 super(Queue, self).printUsage("[<repeat time in hours>]") 161 164 162 165 … … 164 167 Start of program. 165 168 ''' 166 queue = Queue(sys.argv) 167 queue.run() 168 queue.exitProgram("finished") 169 try: 170 queue = Queue(sys.argv) 171 queue.run() 172 queue.exitProgram("completed") 173 except: pass 174 -
branches/eam_branches/ipp-20120405/ippToPsps/jython/run.sh
r33717 r33948 1 ~ /jre1.7.0/bin/java -Xbootclasspath/a:../jars/stilts.jar:../jars/commons-math-2.2.jar:../jars/mysql-connector-java-5.1.14-bin.jar -jar ~/jython2.5.3b1/jython.jar $1 $2 $3 $4 $5 $6 $7 $8 $91 ~ipp/jre1.7.0_03/bin/java -Xbootclasspath/a:../jars/stilts.jar:../jars/commons-math-2.2.jar:../jars/mysql-connector-java-5.1.14-bin.jar -jar ~/jython2.5.3b1/jython.jar $1 $2 $3 $4 $5 $6 $7 $8 $9 -
branches/eam_branches/ipp-20120405/ippToPsps/jython/scratchdb.py
r33689 r33948 278 278 rs.close() 279 279 except: 280 self.logger.errorPai ("Can't query for ingested regions", sql)280 self.logger.errorPair("Can't query for ingested regions", sql) 281 281 282 282 return regions … … 408 408 self.logger.errorPair("Unable to delete " + fileType + " file from", self.dvoDoneTable) 409 409 410 sql = "DROP TABLE " + self.getDbFriendlyTableName(region + "." + fileType) 411 self.execute(sql) 410 tableName = self.getDbFriendlyTableName(region + "." + fileType) 411 sql = "DROP TABLE " + tableName 412 try: self.execute(sql) 413 except: 414 self.logger.errorPair("Unable to drop table", tableName) 415 pass 412 416 413 417 deletedDetectionCount = detectionCount - self.getRowCount(self.dvoDetectionTable) … … 540 544 541 545 ''' 542 Gets the 'code' for the provided filter 543 ''' 544 def getCodeForThisFilter(self, filter): 545 546 code = -1 547 sql = "SELECT CODE FROM " + self.dvoPhotcodesTable + " WHERE NAME = '" + filter + "'" 548 try: 549 rs = self.executeQuery(sql) 550 rs.first() 551 code = rs.getInt(1) 546 Gets a list of filters ordered as thy are in the DVO Photcodes table, as this reflects the order they apper in the cps file 547 ''' 548 def getOrderedListOfFiltersFromPhotcodesTable(self, interestedFilters): 549 550 sql = "SELECT NAME FROM " + self.dvoPhotcodesTable + " WHERE " 551 552 count = 0 553 for filter in interestedFilters: 554 if count != 0: sql = sql + " OR " 555 sql = sql + " name = '" + filter + "'" 556 count += 1 557 558 sql = sql + " ORDER BY CODE" 559 560 orderedFilters = [] 561 try: 562 rs = self.executeQuery(sql) 563 row = 1 564 while (rs.next()): 565 orderedFilters.append([row,rs.getString(1)]) 566 row += 1 552 567 rs.close() 553 568 except: 554 self.logger.errorPair("Could not get filter code using", sql )555 556 return code557 569 self.logger.errorPair("Could not get ordered filter list", sql ) 570 571 return orderedFilters 572 -
branches/eam_branches/ipp-20120405/ippToPsps/jython/setupScratchDb.py
r33589 r33948 25 25 self.exitProgram("incorrect args") 26 26 27 self.scratchDb = ScratchDb(self.logger, self.config, argv[2]) 27 try: 28 self.scratchDb = ScratchDb(self.logger, self.config, argv[2]) 29 except: 30 self.exitProgram("Could not connect to a scratch Db") 31 raise 28 32 29 33 … … 52 56 Program starts here 53 57 ''' 54 setupScratchDb = SetupScratchDb(sys.argv) 55 setupScratchDb.run() 56 setupScratchDb.exitProgram("finished") 58 try: 59 setupScratchDb = SetupScratchDb(sys.argv) 60 setupScratchDb.run() 61 setupScratchDb.exitProgram("completed") 62 except: pass 57 63 58 64 -
branches/eam_branches/ipp-20120405/ippToPsps/jython/stackbatch.py
r33530 r33948 50 50 useFullTables) 51 51 52 if not self.everythingOK: return53 54 52 self.stackType = "DEEP_STACK" # TODO 55 53 … … 57 55 meta = self.gpc1Db.getStackStageMeta(self.id) 58 56 if not meta: 59 self. everythingOK = False60 r eturn57 self.logger.errorPair("Could not get stack", "metadata") 58 raise 61 59 62 60 self.filter = meta[0]; … … 366 364 ,X_PSF_SIG \ 367 365 ,Y_PSF_SIG \ 368 ,POW(10.0, (-0.4*PSF_INST_MAG)) / " +str(self.expTime)+" \369 ,ABS((PSF_INST_MAG_SIG*(POW(10.0, (-0.4*PSF_INST_MAG)) / " +str(self.expTime)+")) / 1.085736) \370 ,POW(10.0, (-0.4*PEAK_FLUX_AS_MAG)) / " +str(self.expTime)+" \366 ,POW(10.0, (-0.4*PSF_INST_MAG)) / " + str(self.expTime) + " \ 367 ,ABS((PSF_INST_MAG_SIG*(POW(10.0, (-0.4*PSF_INST_MAG)) / " + str(self.expTime) + ")) / 1.085736) \ 368 ,POW(10.0, (-0.4*PEAK_FLUX_AS_MAG)) / " + str(self.expTime) + " \ 371 369 ,SKY \ 372 370 ,SKY_SIGMA \ … … 389 387 ,AP_MAG \ 390 388 , NULL \ 391 ,KRON_FLUX \392 ,KRON_FLUX_ERR \389 ,KRON_FLUX / " + str(self.expTime) + " \ 390 ,KRON_FLUX_ERR / " + str(self.expTime) + " \ 393 391 , NULL \ 394 392 , NULL \ -
branches/eam_branches/ipp-20120405/ippToPsps/perl/pspsSchema2xml.pl
r31759 r33948 4 4 # 5 5 # Script that searches a dir containing PSPS schema files, finds those that comtain the 6 # tables on interest then parses them into an XML format. Also generates C-header files7 # containing enums that detail table column names and numbers.6 # tables on interest then parses them into the VOTable format. Also generates trac-wiki 7 # formatted tables. 8 8 # 9 9 ####################################################################################### … … 51 51 52 52 my $enumsHeader = ucfirst($type)."BatchEnums"; 53 open(OUT, ">".$enumsHeader.".h") or die("Error");54 55 print OUT "#ifndef ".uc($enumsHeader)."_H\n";56 print OUT "#define ".uc($enumsHeader)."_H\n\n";57 58 # tables file59 my $tablesOutput = new IO::File(">tables.xml");60 my $tablesWriter = new XML::Writer(OUTPUT => $tablesOutput, DATA_MODE => 1, DATA_INDENT=>2);61 $tablesWriter->xmlDecl('UTF-8');62 $tablesWriter->startTag('tableDescriptions', "type" => "$type");63 64 # map file65 my $mapOutput = new IO::File(">map.xml");66 my $mapWriter = new XML::Writer(OUTPUT => $mapOutput, DATA_MODE => 1, DATA_INDENT=>2);67 $mapWriter->xmlDecl('UTF-8');68 $mapWriter->startTag('tabledata', "type" => "$type");69 53 70 54 # VOTable file … … 82 66 83 67 # finish up XML 84 $tablesWriter->endTag();85 $tablesWriter->end();86 87 # finish up XML88 $mapWriter->endTag();89 $mapWriter->end();90 91 # finish up XML92 68 $votWriter->endTag(); # end RESOURCE tag 93 69 $votWriter->endTag(); # end of TABLE tag 94 70 $votWriter->end(); 95 71 96 print OUT "\n#endif";97 close OUT;98 72 close WIKI; 99 73 … … 208 182 209 183 parseTable("Object"); 184 #parseTable("ObjectCalColor"); 210 185 } 211 186 … … 230 205 print WIKI "|| '''!".$tableNameOut."''' ||||||||||||||\n"; 231 206 print WIKI "|| '''ODM attribute''' || '''units''' || '''Data type''' || '''Default''' || '''Description''' || '''IPP source''' || '''IPP variable/notes''' ||\n"; 232 print OUT "\ntypedef enum {\n";233 $tablesWriter->startTag('table', "name" => $tableNameOut);234 $mapWriter->startTag('table',235 "name" => $tableNameOut,236 "ippfitsextension" => "");237 207 $votWriter->startTag('TABLE', 238 208 "name" => "$tableNameOut"); … … 287 257 288 258 if (!$found) {print "Could not find table '$tableName'\n";} 289 $tablesWriter->endTag();290 $mapWriter->endTag();291 259 292 260 $votWriter->startTag('DATA'); … … 295 263 $votWriter->endTag(); # end DATA tag 296 264 $votWriter->endTag(); # end TABLE tag 297 print OUT "} ".$tableNameOut.";\n";298 265 299 266 close SCHEMA; … … 384 351 $colNum++; 385 352 386 print OUT " ".uc($tableName)."_".uc($name)." = ".$colNum.",\n";387 353 print WIKI "|| ".$name."||".$unit."||".$mstype."||".$default."||".$comment."|| || ||\n"; 388 389 $tablesWriter->startTag('column',390 "name" => $name,391 "type" => $type,392 "default" => $default,393 "comment" => $fullComment);394 $tablesWriter->endTag();395 354 396 355 # get VOTable type … … 413 372 $votWriter->endTag(); 414 373 415 $mapWriter->comment(" **MISSING** <map pspsName=\"$name\" ippType=\"$type\" ippName=\"\" comment=\"$fullComment\"/>");416 417 # $mapWriter->endTag();418 419 374 return $colNum; 420 375 } -
branches/eam_branches/ipp-20120405/ippToPsps/src/Dvo.c
r33595 r33948 188 188 this->dvoConfig = dvoConfigRead(&argc, argv); 189 189 190 for (int i=0; i<argc; i++) free(argv[i]);191 free(argv);190 //for (int i=0; i<argc; i++) free(argv[i]); 191 //free(argv); 192 192 193 193 // method pointers
Note:
See TracChangeset
for help on using the changeset viewer.
