IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 14, 2012, 12:02:48 PM (14 years ago)
Author:
rhenders
Message:

Big changes to support a new Config class that encapuslates the xml config file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/batch.py

    r33235 r33259  
    3030    def __init__(self,
    3131                 logger,
    32                  configPath,
    33                  doc,
     32                 config,
    3433                 gpc1Db,
    3534                 ippToPspsDb,
     
    4241        self.everythingOK = False
    4342        self.readHeader = False
    44         self.configPath = configPath
    45         self.doc = doc
     43        self.config = config
    4644        self.fits = fits
    4745        self.useFullTables = useFullTables
     
    7573               return
    7674
    77         # get info from config
    78         self.survey = self.doc.find("options/survey").text
    79         self.pspsSurvey = self.doc.find("options/pspsSurvey").text
    80         self.dvoGpc1Label = self.doc.find("dvo/gpc1Label").text
    81         self.dvoLocation = self.doc.find("dvo/location").text
    82         self.scratchDb = ScratchDb(logger, self.doc, self.useFullTables)
     75        self.scratchDb = ScratchDb(logger, self.config, self.useFullTables)
    8376
    8477        if not self.scratchDb.everythingOK: return
     
    8780        self.tablesToExport = []
    8881
    89         if self.survey != "":
    90             self.surveyID = self.scratchDb.getSurveyID(self.survey)
     82        if self.config.survey != "":
     83            self.surveyID = self.scratchDb.getSurveyID(self.config.survey)
    9184        else:
    9285            self.surveyID = -1;
    9386       
    94         # get some options from the config
    95         self.testMode = int(self.doc.find("options/testMode").text)
    96         self.dataRelease = int(self.doc.find("metadata/dataRelease").text)
    97 
    9887        # create datastore object
    99         self.datastore = Datastore(self.logger, self.doc, self.ippToPspsDb)
     88        self.datastore = Datastore(self.logger, self.config, self.ippToPspsDb)
    10089
    10190        # get local storage location from config
    10291        self.batchName = Batch.getNameFromID(self.batchID)
    103         self.basePath = self.doc.find("localOutPath").text
    10492        self.subDir = Batch.getSubDir(
    105                 self.basePath,
     93                self.config.basePath,
    10694                self.batchType,
    107                 self.dvoGpc1Label)
     95                self.config.dvoLabel)
    10896
    10997        self.localOutPath = Batch.getOutputPath(
    110                 self.basePath,
     98                self.config.basePath,
    11199                self.batchType,
    112                 self.dvoGpc1Label,
     100                self.config.dvoLabel,
    113101                self.batchID)
    114102
     
    125113        self.logger.infoTitle("New " + self.batchType + " batch")
    126114        self.logger.infoPair("Batch name", self.batchName)
    127         self.logger.infoPair("Survey", self.survey)
    128115        self.logger.infoPair("Survey ID", "%d" % self.surveyID)
    129         self.logger.infoPair("Publishing to PSPS as survey", self.pspsSurvey)
    130         self.logger.infoPair("DVO location", self.dvoLocation)
    131116        self.logger.infoBool("Use full DVO tables?", self.useFullTables)
    132117
     
    227212         if value != "NULL": return value
    228213         else:
    229              if not self.testMode: return "NULL"
     214             if not self.config.test: return "NULL"
    230215             header[key] = default
    231216             self.logger.infoPair("Hardcoding " + key + " to", header[key])
     
    256241        root.attrib['type'] = self.batchType
    257242        root.attrib['timestamp'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    258         if self.batchType != "IN": root.attrib['survey'] = self.pspsSurvey
     243        if self.batchType != "IN": root.attrib['survey'] = self.config.pspsSurvey
    259244        try: self.minObjID
    260245        except: pass
     
    287272        # set up filenams and paths
    288273        tarFile = Batch.getTarFile(self.batchID)
    289         tarPath = Batch.getTarPath(self.basePath, self.batchType, self.dvoGpc1Label, self.batchID)
     274        tarPath = Batch.getTarPath(self.config.basePath, self.batchType, self.config.dvoLabel, self.batchID)
    290275        tarballFile = Batch.getTarballFile(self.batchID)
    291         tarballPath = Batch.getTarballPath(self.basePath, self.batchType, self.dvoGpc1Label, self.batchID)
     276        tarballPath = Batch.getTarballPath(self.config.basePath, self.batchType, self.config.dvoLabel, self.batchID)
    292277
    293278        # tar directory
     
    498483
    499484        # TODO path to DVO prog hardcoded temporarily
    500         cmd = "../src/dvograbber " + self.configPath + " " + self.dvoLocation
     485        cmd = "../src/dvograbber " + self.config.path + " " + self.config.dvoLocation
    501486        self.logger.infoPair("Running DVO", cmd)
    502487        p = Popen(cmd, shell=True, stdout=PIPE)
     
    537522            else:
    538523                self.writeBatchManifest()
    539                 if int(self.doc.find("options/publishToDatastore").text):
     524                if self.config.datastorePublishing:
    540525                    # tar and zip ready for publication to datastore
    541526                    if self.tarAndZip():
     
    544529                        Batch.publishToDatastore(self.datastore, self.batchID, self.batchName, self.subDir, tarballFile)
    545530
    546                 if int(self.doc.find("options/reportNulls").text): self.reportNullsInAllPspsTables(False)
     531                if self.config.reportNulls: self.reportNullsInAllPspsTables(False)
    547532
    548533from datastore import Datastore
Note: See TracChangeset for help on using the changeset viewer.