Index: trunk/ippToPsps/jython/setupScratchDb.py
===================================================================
--- trunk/ippToPsps/jython/setupScratchDb.py	(revision 33787)
+++ trunk/ippToPsps/jython/setupScratchDb.py	(revision 35097)
@@ -2,16 +2,51 @@
 
 import sys
+import os
+import socket
 import stilts
 from java.lang import *
 from java.sql import *
 
-
-from ipptopsps import IppToPsps
+from config import Config
 from scratchdb import ScratchDb
+from ipptopspsdb import IppToPspsDb
 
 '''
 SetupScratchDb class
 '''
-class SetupScratchDb(IppToPsps):
+class SetupScratchDb(object):
+
+    ## XXX EAM : 2013.01.31 - i have changed the 'config.py' concept
+    ## to only include the global static information (from
+    ## settings.xml), and stripped out the dynamic information to a
+    ## new entity called 'skychunk'
+
+    ## XXX note that setupScratchDb.py fails if there are no valid
+    ## entries in the config table (or if it is passed a non-existent
+    ## config) This is because ipptopsps.__init__ calls
+    ## checkClientStatus, which calls refreshConfig, which calls
+    ## readConfig, which attempts to select the matching entry from
+    ## the config table.  if the select returns 0 rows, the code
+    ## crashes.  even if it were not to crash (eg, if it returned
+    ## False), checkClientStatus would enter a waiting loop until the
+    ## config existed.
+    
+    ## since a scratchDb is needed to do basically anything, it seems
+    ## like 'setupScratchDb' should not be dependent on the details of
+    ## the configs, etc.
+
+    ## what are the options?  I think this is a problem of poor
+    ## factoring / dependencies, esp for 'config.py'.  there are two
+    ## (or more) aspects to 'config.py' : management of the dynamic
+    ## 'config' information (basically, the regions / dvodbs of
+    ## interest) and manipulation of the static / system configuration
+    ## information.
+
+    ## these concepts should probably be split and the more general
+    ## part (settings & logger) placed in one module and the rest elsewhere.
+
+    ## as for setupScratchDb.py, it looks like it only uses the static
+    ## settings info and the logger functions, so it should not be a
+    ## child of the ipptopsps class
 
     '''
@@ -19,16 +54,24 @@
     '''
     def __init__(self, argv):
-        super(SetupScratchDb, self).__init__(argv)
+        # set up config object
+        self.config = Config()
 
-        if len(argv) < 3:
+        if len(argv) < 2:
             self.printUsage()
             self.exitProgram("incorrect args")
 
+        # some class constants
+        self.HOST = socket.gethostname()
+        self.PID = os.getpid()
+
+        # XXX Shouldn't config set up logger? 
+        # (not yet, since we set HOST & PID with program...)
+        self.logger = self.config.getLogger(self.HOST, self.PID, 1, 0)
+
         try:
-            self.scratchDb = ScratchDb(self.logger, self.config, argv[2])
+            self.scratchDb = ScratchDb(self.logger, self.config, argv[1])
         except:
             self.exitProgram("Could not connect to a scratch Db")
             raise
-
 
     def run(self):
@@ -42,14 +85,24 @@
         # install IN tables
         self.logger.infoPair("Installing", "initialization tables")
-        tables = stilts.treads("../config/IN/tables.vot")
+        tablepath = self.config.configDir + "tables.IN.vot"
+        tables = stilts.treads(tablepath)
+
         for table in tables:
+            # EAM TEST I/O
+            self.logger.infoPair("Creating IN table: ", table.name)
             self.logger.debug("Creating IN table: " + table.name)
             table.write(self.scratchDb.url + '#' + table.name)
 
-    '''
-    Overrides base-class version
-    '''
+        # create basic DVO tables
+        self.logger.infoPair("Installing", "initialization tables")
+        self.scratchDb.createDvoTables()
+
     def printUsage(self):
-        super(SetupScratchDb, self).printUsage("<scratchdb_name>")
+        # write message to log or stdout if no logger set up
+        msg = os.path.basename(sys.argv[0]) + " <scratchdb_version> "
+        try:
+            self.logger.errorPair("Usage:", msg)
+        except: 
+            print "*** Usage: " + msg
 
 '''
@@ -61,4 +114,2 @@
     setupScratchDb.exitProgram("completed")
 except: pass
-
-
