Index: trunk/ippToPsps/jython/testCode.py
===================================================================
--- trunk/ippToPsps/jython/testCode.py	(revision 38939)
+++ trunk/ippToPsps/jython/testCode.py	(revision 38973)
@@ -5,9 +5,8 @@
 # import time
 import sys
-# import os
+import os
 import math
-# import logging.config
 
-# from sqlUtility import sqlUtility
+import stilts
 
 # testCode class
@@ -18,19 +17,83 @@
         super(testCode, self).__init__(argv)
 
-    def run(self):
+    def connectMysql(self, argv):
 
-        # tables = stilts.treads(fileName)
+        if len(sys.argv) != 6:
+            print "USAGE: ippjython testCode.py (dbHost) (dbUser) (dbPass) (dbName) (filename)"
+            os._exit(2)
 
-        for x in range(0, 8):
-            for y in range(0, 8):
+        # open config and grab database parameters
+        self.dbHost = sys.argv[1]
+        self.dbUser = sys.argv[2]
+        self.dbPass = sys.argv[3]
+        self.dbName = sys.argv[4]
 
-                if not ((x == 0) and (y == 1)):
-                    print "case 1"
-                    print "x : " + str(x)
-                    print "y : " + str(y)
-                else:
-                    print "case 2"
-                    print "x : " + str(x)
-                    print "y : " + str(y)
+        self.filename = sys.argv[5]
+
+        # url for mysql / stilts
+        self.url = "jdbc:mysql://"+self.dbHost+"/"+self.dbName+"?autoReconnect=true&user="+self.dbUser+"&password="+self.dbPass
+
+        ## no need to set up the connection for this test
+        ## try:
+        ##     self.con = DriverManager.getConnection(self.url)
+        ## except:
+        ##     raise
+
+    '''
+    Accepts a regular expression filter so not all tables need to be imported
+    '''
+    def importIppTables(self):
+
+        try:
+            tables = stilts.treads(self.filename)
+        except:
+            print "STILTS could not import from " + filename
+            os._exit(3)
+
+        for table in tables:
+
+            print "import smf table " + table.name
+
+            # need to generate an index on the IPP_IDET column
+            # table = stilts.tpipe(table, cmd='addcol table_index $0')
+            table = stilts.tpipe(table, cmd='explodeall')
+
+            print "read smf table " + table.name
+
+            # drop any previous tables before import
+            # self.scratchDb.dropTable(table.name)
+
+            # limit to specific columns
+            # table = stilts.tpipe(table, cmd='keepcols "' + columns + '"')
+
+            # IPP FITS files are littered with infinities, so remove these
+            print "Removing Infinity values from all columns"
+            table = stilts.tpipe(table, cmd='replaceval -Infinity null *')
+            table = stilts.tpipe(table, cmd='replaceval Infinity null *')
+
+            try:
+                table.write(self.url + '#' + table.name)
+            except:
+                print "Problem writing table '" + table.name + "' to the database"
+                os._exit(4)
+
+        return True
+
+    def run(self, argv):
+
+        self.connectMysql(argv)
+        self.importIppTables()
+
+        ## for x in range(0, 8):
+        ##     for y in range(0, 8):
+        ## 
+        ##         if not ((x == 0) and (y == 1)):
+        ##             print "case 1"
+        ##             print "x : " + str(x)
+        ##             print "y : " + str(y)
+        ##         else:
+        ##             print "case 2"
+        ##             print "x : " + str(x)
+        ##             print "y : " + str(y)
 
 '''
@@ -39,5 +102,4 @@
 try:
     testcode = testCode(sys.argv)
-    testcode.run()
-    testcode.exitProgram("completed")
+    testcode.run(sys.argv)
 except: pass
