- Timestamp:
- Mar 13, 2012, 9:48:05 AM (14 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/loader.py (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/loader.py
r33346 r33487 49 49 if not self.scratchDb.connected: 50 50 self.logger.errorPair("Cannot connect to a", "scratch database") 51 raise Exception("No scratch Db")51 exitProgram("no available scratch database") 52 52 53 53 # now pass scratch Db to dvo object 54 self.dvo = Dvo(self.logger, self.config) 54 55 self.dvo.setScratchDb(self.scratchDb.dbName) 55 56 56 57 # if an IN batch is requested, create and quit 57 58 if len(sys.argv) > 2 and sys.argv[2] == "init": 58 batchID = self.ippToPspsDb.createNewBatch("IN", 0 , self.config)59 batchID = self.ippToPspsDb.createNewBatch("IN", 0) 59 60 if batchID > 0: 60 61 batch = InitBatch(self.logger, … … 65 66 batchID) 66 67 batch.run() 67 68 else: 69 self.logger.errorPair("Could not create batch ID", "%d" % batchID) 70 self.exitProgram("failed to create init batch") 71 68 72 self.exitProgram("init batch created") 69 73 … … 80 84 81 85 ret = super(Loader, self).refreshConfig() 82 self.dvo = Dvo(self.logger, self.config)86 83 87 try: self.dvo.setScratchDb(self.scratchDb.dbName) 84 88 except: pass … … 92 96 def run(self): 93 97 98 numAttempts = 0 94 99 while True: 95 100 96 boxIds = self.ippToPspsDb.getBoxIds(self.config.name) 97 98 self.logger.infoPair("Boxes with unprocessed data", "%d" % len(boxIds)) 99 100 for boxId in boxIds: 101 102 self.checkClientStatus() 103 104 # get box info. if boxes have changed, break and start again 105 try: 106 boxDim = self.ippToPspsDb.getBoxDimensions(boxId) 107 except: 108 self.logger.infoPair("Can't get details for this box", "%d" % boxId) 109 break 110 111 for batchType in self.config.batchTypes: 112 113 ids = self.ippToPspsDb.getPendingIds(boxId, batchType) 114 101 for batchType in self.config.batchTypes: 102 103 # get a stripe's worth of box IDs 104 boxIds = self.ippToPspsDb.getStripeBoxIds(self.HOST, self.PID, batchType) 105 106 numAttempts += 1 107 108 self.logger.infoPair("Boxes with unprocessed data", "%d" % len(boxIds)) 109 110 if len(boxIds) > 0: numAttempts = 0 111 112 for boxId in boxIds: 113 114 self.checkClientStatus() 115 116 # get box info. if boxes have changed, break and start again 117 try: 118 boxDim = self.ippToPspsDb.getBoxDimensions(boxId) 119 except: 120 self.logger.infoPair("Can't get details for this box", "%d" % boxId) 121 break 122 123 ids = self.ippToPspsDb.getPendingIdsForThisBox(boxId, batchType) 124 115 125 if len(ids) < 1: 116 126 self.logger.debugPair("No " + batchType + " items found in this box", "skipping") 117 127 continue 118 128 119 129 self.logger.infoSeparator() 130 self.logger.infoTitle("New box") 120 131 self.logger.infoPair("Box dimensions", "%.1f / %.1f / %.1f" % (boxDim['RA'], boxDim['DEC'], boxDim['SIDE'])) 121 132 self.logger.infoPair(batchType + " items found in this box", "%d" % len(ids)) 122 133 boxSizeWithBorder = boxDim['SIDE'] + (self.config.BORDER * 2) 123 134 124 135 # look in DVO for this box (with extra border) 125 136 self.dvo.setSkyAreaAsBox(boxDim['RA'], boxDim['DEC'], boxSizeWithBorder) … … 138 149 useFullTables = 1 139 150 else: useFullTables = 0 140 151 141 152 self.logger.infoBool("Using pre-ingested DVO data?", useFullTables) 142 153 self.processTheseItems(batchType, ids, useFullTables) 143 154 144 155 self.checkClientStatus() 145 if n ot self.waitForPollTime(): break156 if numAttempts > 1 and not self.waitForPollTime(): break 146 157 147 158 … … 158 169 for id in ids: 159 170 160 batchID = self.ippToPspsDb.createNewBatch(batchType, id , self.config)171 batchID = self.ippToPspsDb.createNewBatch(batchType, id) 161 172 162 173 if batchID < 0: … … 165 176 166 177 self.ippToPspsDb.unlockTables() 167 178 179 self.ippToPspsDb.deletePendingItem(batchType, id) 180 168 181 if batchType == "P2": 169 182 batch = DetectionBatch(self.logger, … … 194 207 self.logger.infoSeparator() 195 208 196 # if in test mode, then quit after one batch 209 # if in test mode, then quit after one batch # TODO remove 197 210 if self.config.test: break 198 211 … … 204 217 ''' 205 218 def printUsage(self): 206 super(Cleanup, self).printUsage() 207 print " [init]" 219 super(Cleanup, self).printUsage("<[init]>") 208 220 209 221 … … 217 229 except Exception, e: 218 230 print str(e) 219 traceback.print_exc() 231 traceback.print_exc()
Note:
See TracChangeset
for help on using the changeset viewer.
