IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 31, 2013, 4:13:09 PM (13 years ago)
Author:
eugene
Message:

split out config (static info) and skychunk (area being processed)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/setupScratchDb.py

    r35073 r35076  
    22
    33import sys
     4import os
     5import socket
    46import stilts
    57from java.lang import *
    68from java.sql import *
    79
    8 
    9 from ipptopsps import IppToPsps
     10from config import Config
    1011from scratchdb import ScratchDb
     12from ipptopspsdb import IppToPspsDb
    1113
    1214'''
    1315SetupScratchDb class
    1416'''
    15 class SetupScratchDb(IppToPsps):
     17class SetupScratchDb(object):
     18
     19    ## XXX EAM : 2013.01.31 - i have changed the 'config.py' concept
     20    ## to only include the global static information (from
     21    ## settings.xml), and stripped out the dynamic information to a
     22    ## new entity called 'skychunk'
    1623
    1724    ## XXX note that setupScratchDb.py fails if there are no valid
     
    4754    '''
    4855    def __init__(self, argv):
    49         super(SetupScratchDb, self).__init__(argv)
     56        # set up config object
     57        self.config = Config()
    5058
    51         if len(argv) < 3:
     59        if len(argv) < 2:
    5260            self.printUsage()
    5361            self.exitProgram("incorrect args")
    5462
     63        # some class constants
     64        self.HOST = socket.gethostname()
     65        self.PID = os.getpid()
     66
     67        # XXX Shouldn't config set up logger?
     68        # (not yet, since we set HOST & PID with program...)
     69        self.logger = self.config.getLogger(self.HOST, self.PID, 1, 0)
     70
    5571        try:
    56             self.scratchDb = ScratchDb(self.logger, self.config, '0', argv[2])
     72            self.scratchDb = ScratchDb(self.logger, self.config, argv[1])
    5773        except:
    5874            self.exitProgram("Could not connect to a scratch Db")
    5975            raise
    60 
    6176
    6277    def run(self):
     
    7085        # install IN tables
    7186        self.logger.infoPair("Installing", "initialization tables")
    72         if self.configDir is None:
    73             tables = stilts.treads("../config/tables.IN.vot")
    74         else:
    75             tablepath = self.configDir + "tables.IN.vot"
    76             tables = stilts.treads(tablepath)
     87        tablepath = self.config.configDir + "tables.IN.vot"
     88        tables = stilts.treads(tablepath)
    7789
    7890        for table in tables:
     
    8698        self.scratchDb.createDvoTables()
    8799
    88     '''
    89     Overrides base-class version
    90     '''
    91100    def printUsage(self):
    92         super(SetupScratchDb, self).printUsage("<scratchdb_name>")
     101        # write message to log or stdout if no logger set up
     102        msg = os.path.basename(sys.argv[0]) + " <scratchdb_version> "
     103        try:
     104            self.logger.errorPair("Usage:", msg)
     105        except:
     106            print "*** Usage: " + msg
    93107
    94108'''
     
    100114    setupScratchDb.exitProgram("completed")
    101115except: pass
    102 
    103 
Note: See TracChangeset for help on using the changeset viewer.