Index: trunk/ippToPsps/jython/batch.py
===================================================================
--- trunk/ippToPsps/jython/batch.py	(revision 31720)
+++ trunk/ippToPsps/jython/batch.py	(revision 31809)
@@ -34,15 +34,15 @@
     def __init__(self, 
                  logger, 
+                 doc,
                  gpc1Db,
                  ippToPspsDb,
-                 scratchDb,
                  id,
                  batchType, 
                  inputFitsPath="", 
-                 survey="", 
-                 useFullTables=False):
+                 survey=""): 
 
         self.everythingOK = False
         self.readHeader = False
+        self.doc = doc
 
         # set up logging
@@ -55,12 +55,16 @@
         self.gpc1Db = gpc1Db
         self.ippToPspsDb = ippToPspsDb
-        self.scratchDb = scratchDb
         self.batchType = batchType;
         self.pspsVoTableFilePath = "../config/" + batchType + "/tables.vot"
         self.inputFitsPath = inputFitsPath
         self.survey = survey
-        self.useFullTables = useFullTables
 
         if self.alreadyProcessed(): return
+
+        # get dvo info from config
+        dvoName = self.doc.find("dvo/name").text
+        self.dvoLocation = self.doc.find("dvo/location").text
+        self.useFullTables = int(self.doc.find("dvo/useFullTables").text)
+        self.scratchDb = ScratchDb(logger, self.useFullTables)
 
         # do we have an input file?
@@ -72,20 +76,13 @@
         self.tablesToExport = []
 
-        # open config
-        self.doc = ElementTree(file="config.xml")
-
         if self.survey != "":
             self.surveyID = self.scratchDb.getSurveyID(self.survey)
-   
-            # get dvo info from config
-            dvoName = self.doc.find("dvo_" + self.survey + "/name").text
-            self.dvoLocation = self.doc.find("dvo_" + self.survey + "/location").text
         else:
-            dvoName = ""
-            self.dvoLocation = ""
             self.surveyID = -1;
+
        
         # get some options from the config
-        self.dataRelease = self.doc.find("metadata/dataRelease").text
+        self.testMode = int(self.doc.find("options/testMode").text)
+        self.dataRelease = int(self.doc.find("metadata/dataRelease").text)
 
         # get datastore info from config
@@ -95,4 +92,5 @@
         self.batchID = self.ippToPspsDb.createNewBatch( 
                 self.getPspsBatchType(), 
+                self.id,
                 survey,
                 dvoName, 
@@ -120,4 +118,18 @@
 
         self.logger.debug("Batch destructor")
+
+    '''
+    Prints metadata to the log
+    '''
+    def printMe(self):
+
+        self.logger.info("New batch: ")
+        self.logger.info("Batch type:             " + self.batchType)
+        self.logger.info("Survey:                 " + self.survey)
+        self.logger.info("Survey ID:              %d" % self.surveyID)
+        self.logger.info("Test mode?              %d" % self.testMode)
+        self.logger.info("DVO location:           " + self.dvoLocation)
+        self.logger.info("Use full DVO tables?:   %d" % self.useFullTables)
+        self.logger.info("Input FITS file:        " + self.inputFitsPath)
 
 
@@ -240,16 +252,14 @@
 
     '''
-    tar and zips batch directory
-    '''
-    def createTarball(self):
+    Publishes this batch to the datastore
+    '''
+    def publishToDatastore(self):
       
-        if self.doc.find("options/createTarball").text == "false": return
-
         # set up filenams and paths
         tarFile = self.batchName + ".tar"
         tarPath = self.subDir + "/" + tarFile
 
-        self.tarballFile = tarFile + ".gz"
-        tarballPath = self.subDir + "/" + self.tarballFile
+        tarballFile = tarFile + ".gz"
+        tarballPath = self.subDir + "/" + tarballFile
 
         # tar directory
@@ -267,12 +277,6 @@
         shutil.rmtree(self.localOutPath)
 
-    '''
-    Publishes this batch to the datastore
-    '''
-    def publishToDatastore(self):
-
-        if self.doc.find("options/publishToDatastore").text == "false": return
-
-        if self.datastore.publish(self.batchName, self.subDir, self.tarballFile, "tgz"):
+        # now publish to the datastore
+        if self.datastore.publish(self.batchName, self.subDir, tarballFile, "tgz"):
             self.ippToPspsDb.updateLoadedToDatastore(self.batchID, 1)
 
@@ -282,6 +286,5 @@
     def getBatchFriendlySurveyType(self):
 
-        return "SCR" # TODO
-
+        #return "SCR" # TODO
         try:
             self.survey
@@ -395,5 +398,5 @@
     def importIppTables(self, filter=""):
 
-      self.logger.info("Attempting to import tables from input FITS file")
+      self.logger.info("Attempting to import tables from input FITS file with regex " + filter)
       tables = stilts.treads(self.inputFitsPath)
 
@@ -433,5 +436,5 @@
         _tables = []
 
-        self.logger.info("Selecting database tables")
+        self.logger.info("Selecting database tables for export")
         for table in self.tablesToExport:
 
@@ -472,6 +475,4 @@
     def reportNullsInAllPspsTables(self, showPartials):
 
-        if self.doc.find("options/reportNulls").text == "false": return
-
         for table in self.pspsTables:
             self.scratchDb.reportNulls(table.name, showPartials)
@@ -527,13 +528,13 @@
 
         self.createEmptyPspsTables()
-        #self.importIppTables()
+        self.importIppTables()
         if self.populatePspsTables():
             if self.exportPspsTablesToFits():
                 self.writeBatchManifest()
-                self.createTarball()
-                self.publishToDatastore()
-                self.reportNullsInAllPspsTables(False)
-                #sys.exit()
+                if int(self.doc.find("options/publishToDatastore").text): self.publishToDatastore()
+                if int(self.doc.find("options/reportNulls").text): self.reportNullsInAllPspsTables(False)
+
         self.logger.info("Finished.")
-
-
+        if self.testMode: sys.exit()
+
+
