Index: /branches/eam_branches/ipp-20140717/ippToPsps/jython/batch.py
===================================================================
--- /branches/eam_branches/ipp-20140717/ippToPsps/jython/batch.py	(revision 37231)
+++ /branches/eam_branches/ipp-20140717/ippToPsps/jython/batch.py	(revision 37232)
@@ -253,8 +253,22 @@
          if key in header: 
              value = format % float(header[key])
-             return value
          else:
              self.logger.errorPair("Missing header field", key)
-             return "NULL"
+             value = format % -999.9
+
+         return value
+
+    '''
+    Returns the string keyword value from this header or else "NULL"
+    '''
+    def getKeyInt(self, header, defValue, key):
+
+         if key in header: 
+             value = str(int(header[key]))
+         else:
+             self.logger.errorPair("Missing header field", key)
+             value = str(defValue)
+
+         return value
 
     '''
Index: /branches/eam_branches/ipp-20140717/ippToPsps/jython/detectionbatch.py
===================================================================
--- /branches/eam_branches/ipp-20140717/ippToPsps/jython/detectionbatch.py	(revision 37231)
+++ /branches/eam_branches/ipp-20140717/ippToPsps/jython/detectionbatch.py	(revision 37232)
@@ -171,7 +171,10 @@
 
         sql = sqlLine.make(") VALUES ( ", ")")
-        print "frame meta sql: ", sql
-
-        self.scratchDb.execute(sql)
+
+        try: self.scratchDb.execute(sql)
+        except:
+            self.logger.errorPair('failed sql: ', sql)
+            raise
+
         self.scratchDb.updateAllRows("FrameMeta", "batchID", str(self.batchID))
         self.scratchDb.updateAllRows("FrameMeta", "surveyID", str(self.surveyID))
@@ -195,10 +198,7 @@
         else: ccdID = 0
 
-        psfFwhmMajor = self.getKeyValue(header, 'FWHM_MAJ')
-        psfFwhmMinor = self.getKeyValue(header, 'FWHM_MIN')
-        if ((psfFwhmMajor == "NULL") or (psfFwhmMajor == "NULL")):
-            psfFwhm = "NULL"
-        else:
-            psfFwhm = 0.5*(float(psfFwhmMajor) + float(psfFwhmMinor))
+        psfFwhmMajor = self.getKeyFloat(header, "%.8f", 'FWHM_MAJ')
+        psfFwhmMinor = self.getKeyFloat(header, "%.8f", 'FWHM_MIN')
+        psfFwhm = 0.5*(float(psfFwhmMajor) + float(psfFwhmMinor))
 
         # insert image metadata into table
@@ -217,12 +217,12 @@
         sqlLine.group("numAstroRef",      self.getKeyValue(header, 'NASTRO'))
         sqlLine.group("numPhotoRef",      self.getKeyValue(header, 'NASTRO'))
-        sqlLine.group("nx",               self.getKeyValue(header, 'CNAXIS1'))
-        sqlLine.group("ny",               self.getKeyValue(header, 'CNAXIS2'))
+        sqlLine.group("nx",               self.getKeyInt(header, 0, 'CNAXIS1'))
+        sqlLine.group("ny",               self.getKeyInt(header, 0, 'CNAXIS2'))
         sqlLine.group("psfFwhm",          str(psfFwhm))
-        sqlLine.group("psfWidMajor",      str(psfFwhmMajor))
-        sqlLine.group("psfWidMinor",      str(psfFwhmMinor))
+        sqlLine.group("psfWidMajor",      psfFwhmMajor)
+        sqlLine.group("psfWidMinor",      psfFwhmMinor)
         sqlLine.group("psfTheta",         self.getKeyFloat(header, "%.8f", 'ANGLE'))
-        sqlLine.group("momentsMajor",     self.getKeyFloat(header, "%.8f", 'IQ_FW1'))
-        sqlLine.group("momentsMinor",     self.getKeyFloat(header, "%.8f", 'IQ_FW2'))
+        sqlLine.group("momentMajor",      self.getKeyFloat(header, "%.8f", 'IQ_FW1'))
+        sqlLine.group("momentMinor",      self.getKeyFloat(header, "%.8f", 'IQ_FW2'))
         sqlLine.group("momentM2C",        self.getKeyFloat(header, "%.8f", 'IQ_M2C'))
         sqlLine.group("momentM2S",        self.getKeyFloat(header, "%.8f", 'IQ_M2S'))
@@ -254,5 +254,5 @@
         sqlLine.group("pc002001",         self.getKeyFloat(header, "%.8e", 'PC002001'))
         sqlLine.group("pc002002",         self.getKeyFloat(header, "%.8e", 'PC002002'))
-        sqlLine.group("polyOrder",        self.getKeyValue(header, 'NPLYTERM'))
+        sqlLine.group("polyOrder",        self.getKeyInt(header, 0, 'NPLYTERM'))
 
         nPolyterm = int(self.getKeyValue(header, 'NPLYTERM'))
@@ -294,5 +294,7 @@
 
         try: self.scratchDb.execute(sql)
-        except: print sql
+        except:
+            self.logger.errorPair('failed sql: ', sql)
+            raise
 
         self.scratchDb.updateFilterID(tableName, self.filter)
@@ -818,17 +820,16 @@
     '''
     def importIppTables(self, filter=""):
-
-       if self.config.test:
-           regex = "XY01.psf"
-       else: 
-           regex = ".*.psf"
-  
-       # XXX EAM NOTE : this is fragile : requires PS1_V4
-       # columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG PSF_INST_MAG PSF_INST_MAG_SIG PSF_INST_FLUX PSF_INST_FLUX_SIG PEAK_FLUX_AS_MAG PSF_MAJOR PSF_MINOR PSF_THETA EXT_NSIGMA PSF_QF MOMENTS_XX MOMENTS_XY MOMENTS_YY AP_MAG AP_FLUX KRON_FLUX KRON_FLUX_ERR FLAGS FLAGS2 SKY SKY_SIGMA EXT_NSIGMA PSF_QF_PERFECT PSF_CHISQ"
-
-       # XXX EAM NOTE : this is fragile : requires PS1_V5
-       columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG POSANGLE PLTSCALE PSF_INST_FLUX PSF_INST_FLUX_SIG PSF_FWHM_MAJ PSF_FWHM_MIN PSF_THETA PSF_CORE PSF_QF PSF_QF_PERFECT PSF_CHISQ EXT_NSIGMA MOMENTS_XX MOMENTS_XY MOMENTS_YY MOMENTS_R1 MOMENTS_RH MOMENTS_M3C MOMENTS_M3S MOMENTS_M4C MOMENTS_M4S AP_FLUX AP_FLUX_SIG AP_NPIX AP_MAG_RADIUS KRON_FLUX KRON_FLUX_ERR SKY SKY_SIGMA FLAGS FLAGS2"
-
-       return super(DetectionBatch, self).importIppTables(columns, regex)
+        
+        regex = ".*.psf"
+        if self.config.test and self.config.camera == "gpc1":
+            regex = "XY01.psf"
+            
+        # XXX EAM NOTE : this is fragile : requires PS1_V4
+        # columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG PSF_INST_MAG PSF_INST_MAG_SIG PSF_INST_FLUX PSF_INST_FLUX_SIG PEAK_FLUX_AS_MAG PSF_MAJOR PSF_MINOR PSF_THETA EXT_NSIGMA PSF_QF MOMENTS_XX MOMENTS_XY MOMENTS_YY AP_MAG AP_FLUX KRON_FLUX KRON_FLUX_ERR FLAGS FLAGS2 SKY SKY_SIGMA EXT_NSIGMA PSF_QF_PERFECT PSF_CHISQ"
+
+        # XXX EAM NOTE : this is fragile : requires PS1_V5
+        columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG POSANGLE PLTSCALE PSF_INST_FLUX PSF_INST_FLUX_SIG PSF_FWHM_MAJ PSF_FWHM_MIN PSF_THETA PSF_CORE PSF_QF PSF_QF_PERFECT PSF_CHISQ EXT_NSIGMA MOMENTS_XX MOMENTS_XY MOMENTS_YY MOMENTS_R1 MOMENTS_RH MOMENTS_M3C MOMENTS_M3S MOMENTS_M4C MOMENTS_M4S AP_FLUX AP_FLUX_SIG AP_NPIX AP_MAG_RADIUS KRON_FLUX KRON_FLUX_ERR SKY SKY_SIGMA FLAGS FLAGS2"
+
+        return super(DetectionBatch, self).importIppTables(columns, regex)
 
     '''
Index: /branches/eam_branches/ipp-20140717/ippToPsps/jython/ipptopspsdb.py
===================================================================
--- /branches/eam_branches/ipp-20140717/ippToPsps/jython/ipptopspsdb.py	(revision 37231)
+++ /branches/eam_branches/ipp-20140717/ippToPsps/jython/ipptopspsdb.py	(revision 37232)
@@ -1252,5 +1252,5 @@
     def insertPending(self, box_id, batchType, ids):
 
-        # print "starting insert pending"
+        print "starting insert pending"
 
         # first delete old pending items
@@ -1259,5 +1259,5 @@
                 AND batch_type = '" + batchType + "'")
 
-        # print "deleted old items"
+        print "deleted old items"
 
         for id in ids:
@@ -1267,6 +1267,10 @@
                (" + str(box_id) + ", '" + batchType + "', " + str(id) + ")"
 
-            # print "sql: ", sql
-            self.execute(sql)
+            print "sql: ", sql
+
+            try: self.execute(sql)
+            except:
+                print "failed to insert into pending"
+                raise
 
     '''
Index: /branches/eam_branches/ipp-20140717/ippToPsps/jython/loader.py
===================================================================
--- /branches/eam_branches/ipp-20140717/ippToPsps/jython/loader.py	(revision 37231)
+++ /branches/eam_branches/ipp-20140717/ippToPsps/jython/loader.py	(revision 37232)
@@ -202,7 +202,9 @@
                 continue
             #self.logger.infoPair("heather:","passed logic")
+
             self.ippToPspsDb.unlockTables()
             #self.logger.infoPair("heather:","unlock table")
-            # self.ippToPspsDb.deletePendingItem(batchType, id)
+
+            self.ippToPspsDb.deletePendingItem(batchType, id)
             #self.logger.infoPair("heather:","deleted pending item")
 
Index: /branches/eam_branches/ipp-20140717/ippToPsps/jython/sqlUtility.py
===================================================================
--- /branches/eam_branches/ipp-20140717/ippToPsps/jython/sqlUtility.py	(revision 37231)
+++ /branches/eam_branches/ipp-20140717/ippToPsps/jython/sqlUtility.py	(revision 37232)
@@ -16,5 +16,4 @@
     
     def group(self,field,value):
-        print "group field: " + field + ", value: " + value
         self.fields.append(field)
         self.values.append(value)
