IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33262


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

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

File:
1 edited

Legend:

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

    r32543 r33262  
    99import logging.config
    1010
     11from config import Config
    1112from pslogger import PSLogger
    1213from ipptopspsdb import IppToPspsDb
     
    2829    logger.infoTitle("Cleaning up batch type %s" % batchType)
    2930
    30     localIDs = ippToPspsDb.getMergedButNotDeletedFromLocalDisk(batchType, EPOCH, DVOLABEL)
    31     datastoreIDs = ippToPspsDb.getLoadedToODMButNotDeletedFromDatastore(batchType, EPOCH, DVOLABEL)
    32     dxlayerIDs = ippToPspsDb.getLoadedToODMButNotDeletedFromDXLayer(batchType, EPOCH, DVOLABEL)
     31    localIDs = ippToPspsDb.getMergedButNotDeletedFromLocalDisk(batchType, config.epoch, config.dvoLabel)
     32    datastoreIDs = ippToPspsDb.getLoadedToODMButNotDeletedFromDatastore(batchType, config.epoch, config.dvoLabel)
     33    dxlayerIDs = ippToPspsDb.getLoadedToODMButNotDeletedFromDXLayer(batchType, config.epoch, config.dvoLabel)
    3334    logger.infoPair("Merged but still on local disk", "%d" % len(localIDs))
    3435    logger.infoPair("Loaded to ODM but still on datastore", "%d" % len(datastoreIDs))
    3536    logger.infoPair("Loaded to ODM but still in DXLayer", "%d" % len(dxlayerIDs))
    3637
    37     if DELETELOCAL:
     38    if config.deleteLocal:
    3839        count = 0
    3940        for id in localIDs:
    4041   
    41             if Batch.deleteFromDisk(logger, BASEPATH, batchType, DVOLABEL, id):
     42            if Batch.deleteFromDisk(logger, config.basePath, batchType, config.dvoLabel, id):
    4243                ippToPspsDb.updateDeletedLocal(id, 1)
    4344                count = count + 1
     
    4748   
    4849
    49     if DELETEDATASTORE:
     50    if config.deleteDatastore:
    5051        count = 0
    5152        for id in datastoreIDs:
     
    5960        logger.infoPair("Remaining on datastore", "%d" % (len(datastoreIDs) - count))
    6061   
    61     if DELETEDXLAYER:
     62    if config.deleteDxLayer:
    6263        count = 0
    6364        for id in dxlayerIDs:
     
    7576'''
    7677
    77 if len(sys.argv) > 1: CONFIG  = sys.argv[1]
     78if len(sys.argv) > 1: CONFIGPATH  = sys.argv[1]
    7879else:
    7980    print "\n** Usage: " + sys.argv[0] + " <configPath> [hours]\n"
     
    8687    SECONDS = None
    8788
    88 # open config file
    89 configDoc = ElementTree(file=CONFIG)
    9089
    91 # set up logging
    92 logging.setLoggerClass(PSLogger)
    93 logger = logging.getLogger(sys.argv[0])
    94 logger.setup(configDoc, sys.argv[0])
    95 
    96 ippToPspsDb = IppToPspsDb(logger, configDoc)
    97 datastore = Datastore(logger, configDoc, ippToPspsDb)
     90# create objects
     91config = Config(CONFIGPATH)
     92logger = config.getLogger(sys.argv[0])
     93ippToPspsDb = IppToPspsDb(logger, config)
     94datastore = Datastore(logger, config, ippToPspsDb)
    9895dxlayer = DXLayer(logger)
    9996
    100 DVOLABEL = configDoc.find("dvo/gpc1Label").text
    101 EPOCH = configDoc.find("options/epoch").text
    102 BASEPATH = configDoc.find("localOutPath").text
    103 DELETELOCAL = int(configDoc.find("deletion/local").text)
    104 DELETEDATASTORE = int(configDoc.find("deletion/datastore").text)
    105 DELETEDXLAYER = int(configDoc.find("deletion/dxlayer").text)
    10697
    10798logger.infoTitle("ippToPsps clean-up")
    10899if SECONDS: logger.infoPair("Performing clean-up every", "%f hours" % (SECONDS/60.0/60.0))
    109 logger.infoBool("Deleting from local disk?", DELETELOCAL)
    110 logger.infoBool("Deleting from datastore?", DELETEDATASTORE)
    111 logger.infoBool("Deleting from DXLayer?", DELETEDXLAYER)
    112 
     100config.printDeletionPolicy()
    113101while True:
    114102
Note: See TracChangeset for help on using the changeset viewer.