Changeset 35097 for trunk/ippToPsps/jython/setupScratchDb.py
- Timestamp:
- Feb 6, 2013, 3:16:35 PM (13 years ago)
- Location:
- trunk/ippToPsps
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps
- Property svn:mergeinfo changed
-
trunk/ippToPsps/jython
- Property svn:ignore
-
old new 1 1 *.class 2 Makefile 3 Makefile.in
-
- Property svn:ignore
-
trunk/ippToPsps/jython/setupScratchDb.py
r33787 r35097 2 2 3 3 import sys 4 import os 5 import socket 4 6 import stilts 5 7 from java.lang import * 6 8 from java.sql import * 7 9 8 9 from ipptopsps import IppToPsps 10 from config import Config 10 11 from scratchdb import ScratchDb 12 from ipptopspsdb import IppToPspsDb 11 13 12 14 ''' 13 15 SetupScratchDb class 14 16 ''' 15 class SetupScratchDb(IppToPsps): 17 class 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' 23 24 ## XXX note that setupScratchDb.py fails if there are no valid 25 ## entries in the config table (or if it is passed a non-existent 26 ## config) This is because ipptopsps.__init__ calls 27 ## checkClientStatus, which calls refreshConfig, which calls 28 ## readConfig, which attempts to select the matching entry from 29 ## the config table. if the select returns 0 rows, the code 30 ## crashes. even if it were not to crash (eg, if it returned 31 ## False), checkClientStatus would enter a waiting loop until the 32 ## config existed. 33 34 ## since a scratchDb is needed to do basically anything, it seems 35 ## like 'setupScratchDb' should not be dependent on the details of 36 ## the configs, etc. 37 38 ## what are the options? I think this is a problem of poor 39 ## factoring / dependencies, esp for 'config.py'. there are two 40 ## (or more) aspects to 'config.py' : management of the dynamic 41 ## 'config' information (basically, the regions / dvodbs of 42 ## interest) and manipulation of the static / system configuration 43 ## information. 44 45 ## these concepts should probably be split and the more general 46 ## part (settings & logger) placed in one module and the rest elsewhere. 47 48 ## as for setupScratchDb.py, it looks like it only uses the static 49 ## settings info and the logger functions, so it should not be a 50 ## child of the ipptopsps class 16 51 17 52 ''' … … 19 54 ''' 20 55 def __init__(self, argv): 21 super(SetupScratchDb, self).__init__(argv) 56 # set up config object 57 self.config = Config() 22 58 23 if len(argv) < 3:59 if len(argv) < 2: 24 60 self.printUsage() 25 61 self.exitProgram("incorrect args") 26 62 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 27 71 try: 28 self.scratchDb = ScratchDb(self.logger, self.config, argv[ 2])72 self.scratchDb = ScratchDb(self.logger, self.config, argv[1]) 29 73 except: 30 74 self.exitProgram("Could not connect to a scratch Db") 31 75 raise 32 33 76 34 77 def run(self): … … 42 85 # install IN tables 43 86 self.logger.infoPair("Installing", "initialization tables") 44 tables = stilts.treads("../config/IN/tables.vot") 87 tablepath = self.config.configDir + "tables.IN.vot" 88 tables = stilts.treads(tablepath) 89 45 90 for table in tables: 91 # EAM TEST I/O 92 self.logger.infoPair("Creating IN table: ", table.name) 46 93 self.logger.debug("Creating IN table: " + table.name) 47 94 table.write(self.scratchDb.url + '#' + table.name) 48 95 49 ''' 50 Overrides base-class version 51 ''' 96 # create basic DVO tables 97 self.logger.infoPair("Installing", "initialization tables") 98 self.scratchDb.createDvoTables() 99 52 100 def printUsage(self): 53 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 54 107 55 108 ''' … … 61 114 setupScratchDb.exitProgram("completed") 62 115 except: pass 63 64
Note:
See TracChangeset
for help on using the changeset viewer.
