IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 22, 2013, 11:40:04 AM (13 years ago)
Author:
heather
Message:

changes for current version of ipptopsps

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/gpc1db.py

    r35417 r35994  
    212212    Gets a camera-stage smf for this cam_id
    213213    '''
    214     def getCameraStageSmf(self, camID):
    215 
     214    def getCameraStageSmf(self, camID, smfversion):
     215        self.logger.infoPair("using", smfversion)
    216216        self.logger.debug("Querying GPC1 for camera smf files with cam_id = " + str(camID))
    217217
     
    237237        # list all smf files if a neb path
    238238        files = []
    239         if path.startswith("neb"):
    240 
    241             # XXX EAM : this should just use the name (path.smf) instead of a wildcard, right?
    242             f=os.popen("neb-ls -p "+path+"%smf")
    243             for i in f.readlines():
    244                 files.append(i.rstrip())
    245 
    246         # or not a neb path
    247         else:
    248             files = glob.glob(path + ".smf")
     239
     240
     241        #there are a couple of states for smfversion
     242
     243        # "use_new" => we have reprocessed the data, use the .smf file
     244
     245        # "not_reproc" => this has not been reprocessed, use the .smf file
     246
     247        # "use_original" => we *may* have reprocessed the data,
     248        #    use (file).smf.original if camRun.state = 'full' and if there is a .smf and .orig
     249        #    use (file).smf if camRun.state = 'full' and if there is only a .smf
     250        #    fault out if camRun.state != 'full' -- that is a race condition we don't want.
     251       
     252       
     253        if (smfversion == "not_reproc") or (smfversion == "use_new"):
     254            if path.startswith("neb"):
     255
     256                # XXX EAM : this should just use the name (path.smf) instead of a wildcard, right?
     257                f=os.popen("neb-ls -p "+path+"%smf")
     258                for i in f.readlines():
     259                    files.append(i.rstrip())
     260
     261                # or not a neb path
     262            else:
     263                files = glob.glob(path + ".smf")
     264
     265        if (smfversion == "use_original"):
     266            # get state of camRun
     267            sql = "SELECT state \
     268               FROM camProcessedExp \
     269               JOIN camRun USING(cam_id) \
     270               WHERE camRun.cam_id = %d" % camID
     271            try:
     272                rs = self.executeQuery(sql)
     273                rs.first()
     274            except:
     275                self.logger.errorPair("Can't query for camRun.state for cam_id",  str(camID))
     276                return None
     277
     278            try:
     279                # get state of camRun.cam_id
     280                camrunstate = rs.getString(1)
     281            except:
     282                self.logger.errorPair("No state found for cam_id", str(camID) )
     283                return None
     284           
     285            if (camrunstate == "full"):
     286              self.logger.infoPair("camRun.state is ",camrunstate)   
     287                 # if full find smf files
     288              if path.startswith("neb"):
     289
     290                 # XXX EAM : this should just use the name (path.smf) instead of a wildcard, right?
     291                 fsmf=os.popen("neb-ls -p "+path+"%smf")
     292                 fsmfs = fsmf.readlines()
     293                 fsmforig=os.popen("neb-ls -p "+path+"%smf.original")
     294                 fsmforigs = fsmforig.readlines()
     295                 smfCount = len(fsmfs)
     296                 smfOrigCount = len (fsmforigs)
     297
     298                 if (smfCount > 0  and smfOrigCount > 0):
     299                     #smf and original  so use original
     300                     self.logger.infoPair("using:", path+"%smf.original")
     301                     for i in fsmforigs:
     302                         files.append(i.rstrip())
     303
     304                 if (smfCount > 0 and smfOrigCount == 0):
     305                     self.logger.infoPair("using:", path+"%smf")
     306                     #smf file and no smf.original use .smf
     307                     for i in fsmfs:
     308                         files.append(i.rstrip())
     309
     310                 #if not smf dont' find files ??)       
     311                 # or not a neb path
     312
     313              else:
     314                # this is broken for non neb - on the other hand we probably won't do .original if so
     315                files = glob.glob(path + ".smf")
     316
     317
     318
     319            # if .smf and .original use .original
     320            else:
     321                self.logger.infoPair("camRun.state not full, can't ingest", str(camID) )
     322                return None
     323
    249324
    250325        # XXX EAM : test output
Note: See TracChangeset for help on using the changeset viewer.