Changeset 35097 for trunk/ippToPsps/jython/gpc1db.py
- Timestamp:
- Feb 6, 2013, 3:16:35 PM (13 years ago)
- Location:
- trunk/ippToPsps
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps
- Property svn:mergeinfo changed
-
trunk/ippToPsps/jython
- Property svn:ignore
-
old new 1 1 *.class 2 Makefile 3 Makefile.in
-
- Property svn:ignore
-
trunk/ippToPsps/jython/gpc1db.py
r34884 r35097 21 21 ''' 22 22 def __init__(self, logger, config): 23 super(Gpc1Db, self).__init__(logger, config, "gpc1database") 23 # define database type 24 if (config.test): 25 dbType = "gpc1database_test" 26 else: 27 dbType = "gpc1database" 28 29 super(Gpc1Db, self).__init__(logger, config, dbType) 24 30 25 31 ''' … … 93 99 94 100 try: 101 # XXX EAM : test output 102 self.logger.infoPair("sql for dvo items:", sql) 95 103 rs = self.executeQuery(sql) 96 104 while (rs.next()): … … 112 120 self.logger.debug("Querying GPC1 for image IDs for stack ID: " + str(stackID)) 113 121 122 # JOIN stackInputSkyfile shoule use stack_id as well as warp_id, right? (maybe not -- the join to warp is first) 114 123 sql = "SELECT DISTINCT CONCAT(exp_id, SUBSTR(class_id, 3, 4)) FROM ( \ 115 124 SELECT DISTINCT exp_id,class_id \ … … 226 235 if path.startswith("neb"): 227 236 237 # XXX EAM : this should just use the name (path.smf) instead of a wildcard, right? 228 238 f=os.popen("neb-ls -p "+path+"%smf") 229 239 for i in f.readlines(): … … 234 244 files = glob.glob(path + ".smf") 235 245 246 # XXX EAM : test output 247 self.logger.infoPair("smf files:", files) 236 248 if len(files) < 1: return None 237 249 … … 290 302 291 303 304 # print "staring stack stage cmf" 305 292 306 # get single path base for the directory containing all cmf files, one of which is hopefully for our stack_id 293 307 try: 294 308 rs = self.executeQuery(sql) 295 309 rs.first() 310 except: 311 self.logger.errorPair("Can't query for stack cmfs", "stack_id = %d" % stackID) 312 return None 313 314 try: 296 315 pathBase = rs.getString(1) 316 except: 317 self.logger.errorPair("No stack cmf files found for stack_id = %d" % stackID) 318 return None 319 320 # find the files (are they in nebulous or in the filesystem?) 321 files = [] 322 if pathBase.startswith("neb"): 323 # XXX EAM : this should just use the name (path.smf) instead of a wildcard, right? 324 f=os.popen("neb-ls -p " + pathBase + "%cmf") 325 for i in f.readlines(): 326 files.append(i.rstrip()) 327 328 # or not a neb path 329 else: 330 files = glob.glob(pathBase + ".cmf") 331 332 # print "stack cmf files:", files 333 if len(files) < 1: return None 334 335 # if we get here, then the cmf is readable, now check the stack_id 336 fits = Fits(self.logger, self.config, files[0]) 337 return fits 338 339 # XXX validate the file? 340 # if fits.getPrimaryHeaderValue("STK_ID") == str(stackID): 297 341 298 342 # now find and loop through all cmf files at this path_base 299 files=os.popen("neb-ls " + pathBase + "%cmf") 300 for i in files.readlines(): 301 302 nebPath = i.rstrip() 303 304 # now attempt to run 'neb-ls -p' to actually read this cmf file 305 try: 306 self.logger.debug("Trying to neb-ls -p on '" + nebPath + "'") 307 paths=os.popen("neb-ls -p " + nebPath) 308 path = paths.readline().rstrip() 309 if len(path) < 1: 310 self.logger.debug("zero length path - skipping") 311 raise 312 313 # if we get here, then the cmf is readable, now check the stack_id 314 fits = Fits(self.logger, self.config, path) 315 if fits.getPrimaryHeaderValue("STK_ID") == str(stackID): 316 # we have the right file! 317 self.logger.debug("SUCCESS!: %s == %s"% (fits.getPrimaryHeaderValue("STK_ID"), str(stackID))) 318 return fits 319 else: 320 # this is not the correct file 321 self.logger.debug("STACK ID: %s != %s"% (fits.getPrimaryHeaderValue("STK_ID"), str(stackID))) 322 323 # an exception here means that nebulous could not read this file, so we just skip it 324 except: 325 self.logger.debug("NEB FAILED SKIPPING") 326 pass 327 328 except: 329 self.logger.errorPair("Can't query for stack cmfs", "stack_id = %d" % stackID) 330 331 self.logger.errorPair("Couldn't find stack cmf for", "stack_id = %d" % stackID) 332 return None 343 344 ## XXX the code below was needed when we ingested from staticsky (N files per run) 345 ## XXX ingesting from skycal solves this problem (1 file per run) 346 ## files=os.popen("neb-ls " + pathBase + "%cmf") 347 ## for i in files.readlines(): 348 ## nebPath = i.rstrip() 349 ## 350 ## # now attempt to run 'neb-ls -p' to actually read this cmf file 351 ## try: 352 ## self.logger.debug("Trying to neb-ls -p on '" + nebPath + "'") 353 ## paths=os.popen("neb-ls -p " + nebPath) 354 ## path = paths.readline().rstrip() 355 ## if len(path) < 1: 356 ## self.logger.debug("zero length path - skipping") 357 ## raise 358 ## 359 ## print "starint stack stage cmf 3" 360 ## 361 ## # if we get here, then the cmf is readable, now check the stack_id 362 ## fits = Fits(self.logger, self.config, path) 363 ## if fits.getPrimaryHeaderValue("STK_ID") == str(stackID): 364 ## # we have the right file! 365 ## self.logger.debug("SUCCESS!: %s == %s"% (fits.getPrimaryHeaderValue("STK_ID"), str(stackID))) 366 ## return fits 367 ## else: 368 ## # this is not the correct file 369 ## self.logger.debug("STACK ID: %s != %s"% (fits.getPrimaryHeaderValue("STK_ID"), str(stackID))) 370 ## 371 ## # an exception here means that nebulous could not read this file, so we just skip it 372 ## except: 373 ## self.logger.debug("NEB FAILED SKIPPING") 374 ## pass 333 375 334 376 '''
Note:
See TracChangeset
for help on using the changeset viewer.
