IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 6, 2013, 3:16:35 PM (13 years ago)
Author:
eugene
Message:

upgrade to ippToPsps (see doc/upgrade.txt): adds native dvo to mysql ingest operations, adds autogen configuration & installation, splits out global config information from new "skychunk" information (current region on the sky being processed), adds test suites

Location:
trunk/ippToPsps
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps

  • trunk/ippToPsps/jython

    • Property svn:ignore
      •  

        old new  
        11*.class
         2Makefile
         3Makefile.in
  • trunk/ippToPsps/jython/ipptopsps.py

    r33790 r35097  
    11#!/usr/bin/env jython
     2# EAM : config -> skychunk DONE
    23
    34import signal
     
    910
    1011from config import Config
     12from skychunk import Skychunk
    1113from pslogger import PSLogger
    1214from ipptopspsdb import IppToPspsDb
     
    2325    def __init__(self, argv, logToStdout=1, logToFile=0):
    2426
    25         # are the arsg ok? all programs require a config name
     27        # set up config object (global config information, also parse command-line options, eg -test / -t)
     28        self.config = Config()
     29
     30        # are the args ok? all programs require a config name
    2631        if len(sys.argv) < 2:
    2732            self.printUsage()
    2833            self.exitProgram("Wrong args")
    29            
     34
    3035        # some class constants
    31         self.PROGNAME = sys.argv[0]
    32         CONFIGNAME = sys.argv[1]
    3336        self.HOST = socket.gethostname()
    3437        self.PID = os.getpid()
     
    3841        self.SECONDS = None
    3942
    40         self.createNewConfig = False
    41         self.rotateConfigs = False
    42         # a new config?
    43         if CONFIGNAME == "edit": self.createNewConfig = True
    44         # should we rotate configs for this program?
    45         elif CONFIGNAME == "all": self.rotateConfigs = True
     43        self.logger = self.config.getLogger(self.HOST, self.PID, logToStdout, logToFile)
    4644
    47         # set up config object
    48         self.config = Config(self.PROGNAME, CONFIGNAME)
    49         self.logger = self.config.getLogger(self.HOST, self.PID, logToStdout, logToFile)
     45        # argv[1] -> self.skychunk.name
     46        self.skychunk = Skychunk(self.logger)
    5047
    5148        # create connection to databases database
    5249        try:
    53             self.ippToPspsDb = IppToPspsDb(self.logger, self.config)
     50            self.ippToPspsDb = IppToPspsDb(self.logger, self.config, self.skychunk)
    5451        except:
    5552            self.exitProgram("Could not connect to ipptopsps Db")
     
    6360        # title for log
    6461        self.logger.infoSeparator()
    65         self.logger.infoTitle("ippToPsps '" + self.PROGNAME + "' started")
     62        self.logger.infoTitle("ippToPsps '" + self.config.programName + "' started")
    6663        self.logger.infoPair("Host", self.HOST)
    6764        self.logger.infoPair("PID", "%d" % self.PID)
    68         self.logger.infoPair("Config", self.config.name)
     65        self.logger.infoPair("Skychunk", self.skychunk.name)
    6966
    7067    '''
     
    104101
    105102        # write message to log or stdout if no logger set up
    106         msg = sys.argv[0] + " <configName|all|edit> " + extra
     103        msg = sys.argv[0] + " <skychunkName|all|edit> " + extra
    107104        try:
    108105            self.logger.errorPair("Usage:", msg)
     
    111108
    112109    '''
    113     Refreshes the config then recreates objects with new settings
     110    Refreshes the skychunk then recreates objects with new settings
    114111    '''
    115     def refreshConfig(self):
     112    def refreshSkychunk(self):
    116113
    117         # new config?
    118         if self.createNewConfig:
    119             self.ippToPspsDb.editConfig()
    120             self.ippToPspsDb.setConfigForThisClient(self.config.name, self.HOST, self.PID)
    121             self.createNewConfig = False
     114        # new skychunk?
     115        if self.skychunk.createNewSkychunk:
     116            self.ippToPspsDb.editSkychunk()
     117            self.ippToPspsDb.setSkychunkForThisClient(self.skychunk.name, self.HOST, self.PID)
     118            self.skychunk.createNewSkychunk = False
    122119
    123         # if we are rotating configs, then look for next active one in list
    124         if self.rotateConfigs:
    125             self.ippToPspsDb.getConfigForThisClient(self.HOST, self.PID)
    126             configs = self.ippToPspsDb.getActiveConfigList()
     120        # if we are rotating skychunks, then look for next active one in list
     121        if self.skychunk.rotateSkychunks:
     122            self.ippToPspsDb.getSkychunkForThisClient(self.HOST, self.PID)
     123            skychunks = self.ippToPspsDb.getActiveSkychunkList()
    127124             
    128125            i = 1
    129             for config in configs:
    130                if config == self.config.name: break
     126            for skychunk in skychunks:
     127               if skychunk == self.skychunk.name: break
    131128               i += 1
    132129
    133             if i >= len(configs): newConfig = configs[0]
    134             else: newConfig = configs[i]
     130            if i >= len(skychunks): newSkychunk = skychunks[0]
     131            else: newSkychunk = skychunks[i]
    135132
    136             self.ippToPspsDb.setConfigForThisClient(newConfig, self.HOST, self.PID)
     133            self.ippToPspsDb.setSkychunkForThisClient(newSkychunk, self.HOST, self.PID)
    137134
    138         return self.ippToPspsDb.readConfig(self.HOST, self.PID)
     135        return self.ippToPspsDb.readSkychunk(self.HOST, self.PID)
    139136
    140137    '''
    141     All implementing subclasses (programs) should call this method once in a while to see if it should be paused or killed, otherwise this updates the clients table with current time and reloads the config data
     138    All implementing subclasses (programs) should call this method once in a while to see if it should be paused or killed, otherwise this updates the clients table with current time and reloads the skychunk data
    142139    '''
    143140    def checkClientStatus(self):
    144141
    145         self.ippToPspsDb.updateClient(self.PROGNAME, self.HOST, self.PID)
     142        self.ippToPspsDb.updateClient(self.config.programName, self.HOST, self.PID)
    146143
    147144        if self.ippToPspsDb.isKilled(self.HOST, self.PID):
    148145            self.exitProgram("killed via Db")
    149146       
    150         # this loop pauses the process if we have no config or we have set it to pause
     147        # this loop pauses the process if we have no skychunk or we have set it to pause
    151148        firstTimeIn = True
    152         while not self.refreshConfig() or self.ippToPspsDb.isPaused(self.HOST, self.PID):
     149        while not self.refreshSkychunk() or self.ippToPspsDb.isPaused(self.HOST, self.PID):
    153150
    154             self.ippToPspsDb.updateClient(self.PROGNAME, self.HOST, self.PID)
     151            self.ippToPspsDb.updateClient(self.config.programName, self.HOST, self.PID)
    155152            if self.ippToPspsDb.isKilled(self.HOST, self.PID):
    156153                self.exitProgram("killed while paused")
     
    175172        # write message to log or stdout if no logger set up
    176173        try:
    177             self.logger.infoPair(self.PROGNAME + " exited", exitReason)
     174            self.logger.infoPair(self.config.programName + " exited", exitReason)
    178175        except:
    179176            print "*** Program exited: " + exitReason
     
    186183
    187184        sys.exit(0)
    188    
    189 
Note: See TracChangeset for help on using the changeset viewer.