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/config.py

    r33728 r35097  
    11#!/usr/bin/env jython
    22
     3import sys
     4import os
    35import logging
    46from xml.etree.ElementTree import ElementTree, Element, tostring
     
    68from pslogger import PSLogger
    79
    8 
    910'''
    10 A class encapsulating a ippToPsps configuration. This information is stored in the 'config' table
    11 of the ipptopsps database, but there are some higher level config details in the 'settings.xml' file
     11A class encapsulating the globald ippToPsps configuration information.
     12This is stored in the 'settings.xml' file in the config directory
    1213'''
    1314class Config(object):
    14 
    1515
    1616    '''
     
    1919    Basically reads the entire config and stores values to class variables
    2020    '''
    21     def __init__(self, programName, name):
     21    def __init__(self):
    2222
    23         self.programName = programName
    24         self.name = name
    25         self.settingsPath = "../config/settings.xml" # TODO
     23        self.test = False
     24        for arg in sys.argv:
     25            if arg == "-test":
     26                self.test = True
     27                sys.argv.remove(arg)
     28            if arg == "-t":
     29                self.test = True
     30                sys.argv.remove(arg)
     31
     32        ## name of the top-level jython script
     33        self.programName = os.path.basename(sys.argv[0])
     34
     35        ## this is somewhat crude: ipptopsps programs are called like this:
     36        ## ippjython foo.py [chunk] [other options]
     37        ## the logging code (called below by getLogger) wants to include 'name' in the
     38        ## output file.  we blindly set name == argv[1]
     39        ## programs which are called without argv[1] will use 'none' in the log file
     40        if len(sys.argv) >= 2:
     41            self.name = sys.argv[1]
     42
     43        # XXX this probably goes in 'config.py'
     44        self.configDir = os.getenv("IPPTOPSPS_DATA")
     45        if self.configDir is None:
     46            self.configDir = "../config/"
     47        else:
     48            self.configDir = self.configDir + "/"
     49
     50        # self.configdir is set in ipptopsps.jy on init based on env(IPPTOPSPS_DATA)
     51        # for test purposes, an uninstalled system may use the config information from
     52        # a relative path
     53        self.settingsPath = self.configDir + "settings.xml"
     54
    2655        self.logger = None
    2756
    2857        self.settingsDoc = ElementTree(file=self.settingsPath)
    2958        self.logPath = self.settingsDoc.find("logPath").text
    30         self.czarPlotsPath = self.settingsDoc.find("czarPlotsPath").text
    3159
    32         # this is the border (in degrees) that we place around any loading box of
    33         # PS1 pointings to ensure we pull a large enough area out of DVO
    34         self.BORDER = 1.65
    35         self.isLoaded = False
    36 
    37     '''
    38     Prints everything for this config
    39     '''
    40     def printAll(self):
    41 
    42         self.logger.infoTitle("Config")
    43 
    44         try:
    45             self.logger.infoSeparator()
    46             self.logger.infoPair("Config name", self.name)
    47             self.logger.infoPair("Survey", self.survey)
    48             self.logger.infoPair("Publishing to PSPS as survey", self.pspsSurvey)
    49             self.logger.infoPair("Loading epoch", self.epoch)
    50             self.logger.infoPair("Data release", "%d" % self.dataRelease)
    51             for batchType in self.batchTypes: self.logger.infoPair("Queuing batch type", batchType)
    52         except:
    53             pass
    54 
    55         self.printDvoInfo()
    56         self.printDatastoreInfo()
    57         self.printBoxCoords()
    58         self.printDeletionPolicy()
    59         try: self.logger.infoSeparator()
    60         except: pass
    61 
    62     '''
    63     Queuing this batch type?
    64     '''
    65     def queuingThisBatchType(self, batchType):
    66        if batchType in self.batchTypes: return 1
    67        return 0
     60        print "config.programName: ", self.programName
     61        print "config.configDir: ", self.configDir
     62        print "config.settingsPath: ", self.settingsPath
     63        print "config.logPath: ", self.logPath
     64        print "config.test: ", self.test
    6865
    6966    '''
     
    7269    def getLogger(self, host, pid, stdout=1, sendToFile=0):
    7370       
     71        print "get Logger: ", host, pid
    7472        logging.setLoggerClass(PSLogger)
     73        print "done Logger 1"
    7574        self.logger = logging.getLogger(self.programName)
    76         self.logger.setup(self.programName, self.logPath, self.name, host, pid, stdout, sendToFile)
     75        print "done Logger 2"
     76        if (self.name is None):
     77            self.logger.setup(self.programName, self.logPath, "none", host, pid, stdout, sendToFile)
     78        else:
     79            self.logger.setup(self.programName, self.logPath, self.name, host, pid, stdout, sendToFile)
     80        print "done Logger 3"
    7781
    7882        return self.logger
    79 
    80     '''
    81     Prints the currently set DVO info
    82     '''
    83     def printDvoInfo(self):
    84 
    85         try:
    86             self.logger.infoPair("DVO label", self.dvoLabel)
    87             self.logger.infoPair("DVO location", self.dvoLocation)
    88         except:
    89             pass
    90    
    91     '''
    92     Prints datastore info
    93     '''
    94     def printDatastoreInfo(self):
    95 
    96         try:
    97             self.logger.infoBool("Datastore publishing?", self.datastorePublishing)
    98             if self.datastorePublishing:
    99                 self.logger.infoPair("Datastore type", self.datastoreProduct)
    100                 self.logger.infoPair("Datastore product", self.datastoreType)
    101         except:
    102             pass
    103    
    104     '''
    105     Prints the current deletion policy
    106     '''
    107     def printDeletionPolicy(self):
    108 
    109         try:
    110             self.logger.infoBool("Deleting local?", self.deleteLocal)
    111             self.logger.infoBool("Deleting datastore?", self.deleteDatastore)
    112             self.logger.infoBool("Deleting DXLayer?", self.deleteDxLayer)
    113         except:
    114             pass
    115    
    116     '''
    117     Prints the currently set RA/Dec bounding box
    118     '''
    119     def printBoxCoords(self):
    120 
    121         try:
    122             self.logger.infoPair("RA limits", "%.1f -> %.1f" % (self.minRa, self.maxRa))
    123             self.logger.infoPair("Dec limits", "%.1f -> %.1f" % (self.minDec, self.maxDec))
    124             self.logger.infoPair("Loading box size", "%.1f degrees" % self.boxSize)
    125         except:
    126             pass
    127    
    12883
    12984    '''
     
    13489    def getDbUser(self, dbType): return self.settingsDoc.find(dbType +"/user").text
    13590    def getDbPassword(self, dbType): return self.settingsDoc.find(dbType +"/password").text
    136 
Note: See TracChangeset for help on using the changeset viewer.