Changeset 35010
- Timestamp:
- Jan 22, 2013, 5:08:39 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20121219/ippToPsps/jython/gpc1db.py
r34947 r35010 229 229 if path.startswith("neb"): 230 230 231 # XXX EAM : this should just use the name (path.smf) instead of a wildcard, right? 231 232 f=os.popen("neb-ls -p "+path+"%smf") 232 233 for i in f.readlines(): … … 297 298 298 299 300 # print "staring stack stage cmf" 301 299 302 # get single path base for the directory containing all cmf files, one of which is hopefully for our stack_id 300 303 try: 301 304 rs = self.executeQuery(sql) 302 305 rs.first() 306 except: 307 self.logger.errorPair("Can't query for stack cmfs", "stack_id = %d" % stackID) 308 return None 309 310 try: 303 311 pathBase = rs.getString(1) 312 except: 313 self.logger.errorPair("No stack cmf files found for stack_id = %d" % stackID) 314 return None 315 316 # find the files (are they in nebulous or in the filesystem?) 317 files = [] 318 if pathBase.startswith("neb"): 319 # XXX EAM : this should just use the name (path.smf) instead of a wildcard, right? 320 f=os.popen("neb-ls -p " + pathBase + "%cmf") 321 for i in f.readlines(): 322 files.append(i.rstrip()) 323 324 # or not a neb path 325 else: 326 files = glob.glob(pathBase + ".cmf") 327 328 # print "stack cmf files:", files 329 if len(files) < 1: return None 330 331 # if we get here, then the cmf is readable, now check the stack_id 332 fits = Fits(self.logger, self.config, files[0]) 333 return fits 334 335 # XXX validate the file? 336 # if fits.getPrimaryHeaderValue("STK_ID") == str(stackID): 304 337 305 338 # now find and loop through all cmf files at this path_base 306 files=os.popen("neb-ls " + pathBase + "%cmf") 307 for i in files.readlines(): 308 309 nebPath = i.rstrip() 310 311 # now attempt to run 'neb-ls -p' to actually read this cmf file 312 try: 313 self.logger.debug("Trying to neb-ls -p on '" + nebPath + "'") 314 paths=os.popen("neb-ls -p " + nebPath) 315 path = paths.readline().rstrip() 316 if len(path) < 1: 317 self.logger.debug("zero length path - skipping") 318 raise 319 320 # if we get here, then the cmf is readable, now check the stack_id 321 fits = Fits(self.logger, self.config, path) 322 if fits.getPrimaryHeaderValue("STK_ID") == str(stackID): 323 # we have the right file! 324 self.logger.debug("SUCCESS!: %s == %s"% (fits.getPrimaryHeaderValue("STK_ID"), str(stackID))) 325 return fits 326 else: 327 # this is not the correct file 328 self.logger.debug("STACK ID: %s != %s"% (fits.getPrimaryHeaderValue("STK_ID"), str(stackID))) 329 330 # an exception here means that nebulous could not read this file, so we just skip it 331 except: 332 self.logger.debug("NEB FAILED SKIPPING") 333 pass 334 335 except: 336 self.logger.errorPair("Can't query for stack cmfs", "stack_id = %d" % stackID) 337 338 self.logger.errorPair("Couldn't find stack cmf for", "stack_id = %d" % stackID) 339 return None 339 340 ## XXX the code below was needed when we ingested from staticsky (N files per run) 341 ## XXX ingesting from skycal solves this problem (1 file per run) 342 ## files=os.popen("neb-ls " + pathBase + "%cmf") 343 ## for i in files.readlines(): 344 ## nebPath = i.rstrip() 345 ## 346 ## # now attempt to run 'neb-ls -p' to actually read this cmf file 347 ## try: 348 ## self.logger.debug("Trying to neb-ls -p on '" + nebPath + "'") 349 ## paths=os.popen("neb-ls -p " + nebPath) 350 ## path = paths.readline().rstrip() 351 ## if len(path) < 1: 352 ## self.logger.debug("zero length path - skipping") 353 ## raise 354 ## 355 ## print "starint stack stage cmf 3" 356 ## 357 ## # if we get here, then the cmf is readable, now check the stack_id 358 ## fits = Fits(self.logger, self.config, path) 359 ## if fits.getPrimaryHeaderValue("STK_ID") == str(stackID): 360 ## # we have the right file! 361 ## self.logger.debug("SUCCESS!: %s == %s"% (fits.getPrimaryHeaderValue("STK_ID"), str(stackID))) 362 ## return fits 363 ## else: 364 ## # this is not the correct file 365 ## self.logger.debug("STACK ID: %s != %s"% (fits.getPrimaryHeaderValue("STK_ID"), str(stackID))) 366 ## 367 ## # an exception here means that nebulous could not read this file, so we just skip it 368 ## except: 369 ## self.logger.debug("NEB FAILED SKIPPING") 370 ## pass 340 371 341 372 '''
Note:
See TracChangeset
for help on using the changeset viewer.
