Index: trunk/ippToPsps/jython/dvo.py
===================================================================
--- trunk/ippToPsps/jython/dvo.py	(revision 39763)
+++ trunk/ippToPsps/jython/dvo.py	(revision 39764)
@@ -152,4 +152,5 @@
         self.scratchDb.execute("ALTER TABLE " + self.scratchDb.dvoImagesTable + " ADD PRIMARY KEY (IMAGE_ID, EXTERN_ID)")
 
+        self.scratchDb.execute("CREATE INDEX externID_index ON dvoImagesFull (EXTERN_ID)")
         self.scratchDb.setImportedThisDvoTable(path)
         return True
Index: trunk/ippToPsps/jython/fits.py
===================================================================
--- trunk/ippToPsps/jython/fits.py	(revision 39763)
+++ trunk/ippToPsps/jython/fits.py	(revision 39764)
@@ -147,7 +147,8 @@
 
         if False:
+            self.logger.infoPair("running findAndReadHeaderRaw",name)
             status = self.findAndReadHeaderRaw(name, VERBOSE)
             return status
-
+        self.logger.infoPair("running findAndReadHeaderOhana",name)
         status = self.findAndReadHeaderOhana(name, VERBOSE)
         return status
Index: trunk/ippToPsps/jython/gpc1db.py
===================================================================
--- trunk/ippToPsps/jython/gpc1db.py	(revision 39763)
+++ trunk/ippToPsps/jython/gpc1db.py	(revision 39764)
@@ -659,4 +659,26 @@
 
 
+    '''
+    Gets the exp_id from teh exp_name
+    ''' 
+    def getExpIdFromExpName(self, expName):
+       sql = "SELECT exp_id from rawExp where exp_name = '"+expName+"'"
+       try:
+           rs = self.executeQuery(sql)
+       except:
+           self.logger.infoPair("failed sql:",sql)
+           self.logger.exception("Can't query for imageIDs")
+            
+
+       expIDs = []
+       while (rs.next()):
+           expIDs.append(rs.getString(1))
+       rs.close()
+       expID = expIDs[0]
+       return expID
+
+    
+
+
 
     '''
Index: trunk/ippToPsps/jython/ipptopspsdb.py
===================================================================
--- trunk/ippToPsps/jython/ipptopspsdb.py	(revision 39763)
+++ trunk/ippToPsps/jython/ipptopspsdb.py	(revision 39764)
@@ -1177,5 +1177,5 @@
         if rs.getInt(23) == 1: self.skychunk.batchTypes.append("DO")
         if rs.getInt(24) == 1: self.skychunk.batchTypes.append("FW")
-        if rs.getInt(25) == 1: self.skychunk.batchTypes.append("FG")
+###        if rs.getInt(25) == 1: self.skychunk.batchTypes.append("FG") fix this when P2 is done
         if rs.getInt(25) == 1: self.skychunk.batchTypes.append("FO")
 
Index: trunk/ippToPsps/jython/stackbatch.py
===================================================================
--- trunk/ippToPsps/jython/stackbatch.py	(revision 39763)
+++ trunk/ippToPsps/jython/stackbatch.py	(revision 39764)
@@ -129,12 +129,15 @@
            self.zpImage[filter] = self.getKeyFloat(header, "%.8f", 'ZPT_OBS')
            self.zpError[filter] = self.getKeyFloat(header, "%.8f", 'ZPT_ERR')
-
-           deteffHeader = self.fits[filter].findAndReadHeader("SkyChip.deteff", self.config.test)
-           if not deteffHeader:
-               if self.config.test: self.logger.errorPair("No header found for Skychip.deteff for", filter)
-               return False
-
-           self.magref[filter] = self.getKeyFloat(deteffHeader, "%.8f", 'DETEFF.MAGREF')
-           self.nInjected[filter] = int(self.getKeyInt(deteffHeader, 0, 'DETEFF.NUM'))
+           hasdeteff = 1           
+           try: deteffHeader = self.fits[filter].findAndReadHeader("SkyChip.deteff", self.config.test)
+           except:
+               hasdeteff = 0
+           #if not deteffHeader:
+           #    if self.config.test: self.logger.errorPair("No header found for Skychip.deteff for", filter)
+           #    return False
+               
+           if hasdeteff == 1:          
+               self.magref[filter] = self.getKeyFloat(deteffHeader, "%.8f", 'DETEFF.MAGREF')
+               self.nInjected[filter] = int(self.getKeyInt(deteffHeader, 0, 'DETEFF.NUM'))
 
 	   ## MEH -- md5sum test
@@ -1180,7 +1183,18 @@
                 # search the words for the o....g....o part
                 for j in range(len(words)):
-                    match = re.search('o\d\d\d\dg\d\d\d\d\o', words[j])
-                    if (match != None):
+                    match1 = re.search('^\d\d\d\dg\d\d\d\d\o', words[j]) #remove leading  o: then ones with borked no os and cs will work now 
+                    match2 = re.search('\o\d\d\d\dg\d\d\d\d\o', words[j]) #remove leading  o: then ones with borked no os and cs will work now 
+                    match3 = re.search('\c\d\d\d\dg\d\d\d\d\o', words[j]) #remove leading  o: then ones with borked no os and cs will work now 
+                    if (match1 != None):
                         ogo=j
+                        ogoname = 'o'+words[ogo]
+                        break
+                    if (match2 != None):
+                        ogo=j
+                        ogoname = words[ogo]
+                        break
+                    if (match3 != None):
+                        ogo=j
+                        ogoname = words[ogo]
                         break
                     # did we find it? if so, are there are least 2 more elements past the ogo?
@@ -1188,11 +1202,19 @@
 
                 if ogo > -1:
-                    if (ogo +1) < len(words):
+                    if (ogo +2) < len(words): #this was the mistake before
                         # there is a o....g....o element, and the next 2 exist
                         frameID = words[ogo+1]
                         
-                    else: 
-                        self.logger.infoPair("unable to find exp_id from", inputName)
-                        raise
+                    else:
+                        #ogoname = "o"+words[ogo]
+                        try: frameID = self.gpc1Db.getExpIdFromExpName(ogoname)
+                        except:
+                            self.logger.error("cant get expid")
+                            raise
+                        
+#                        frameID = str(rs.getInt(1))
+        
+#                        self.logger.infoPair("unable to find exp_id from", inputName)
+#                        raise
                         # and then raise an error and stop the program. I expect this to mostly work fine
         # for the extra long label (?) - can probably get it from just the o g o (if exp_id
@@ -1226,4 +1248,5 @@
 
         self.tablesToExport.append("StackToFrame")
+        return True
 
     ''' 
@@ -1506,5 +1529,5 @@
             if self.stackIDs[filter] > 0:        
                 self.populateStackMeta(filter)
-
+                
         self.populateStackObjectThin()
 
@@ -1539,7 +1562,13 @@
         self.logger.infoPair("populating","StackToImage") 
         self.populateStackToImage()
-        
+       
+ 
+       
         self.logger.infoPair("populating","StackToFrame") 
-        self.populateStackToFrame()
+
+#        self.populateStackToFrame()
+        if not self.populateStackToFrame():
+                    self.logger.errorPair("can't populate"," stack to frame")
+                    return False
         self.logger.infoPair("removing frameID"," duplicates")
         self.scratchDb.execute("ALTER IGNORE TABLE StackToFrame ADD UNIQUE INDEX(frameID)")
