IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33554 for trunk/ippToPsps


Ignore:
Timestamp:
Mar 16, 2012, 12:04:49 PM (14 years ago)
Author:
rhenders
Message:

changes to make sure loader notices a config change and resets processing accordingly

File:
1 edited

Legend:

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

    r33529 r33554  
    5050            self.logger.errorPair("Cannot connect to a", "scratch database")
    5151            exitProgram("no available scratch database")
    52         
    53         # now pass scratch Db to dvo object
    54         self.dvo = Dvo(self.logger, self.config)
    55         self.dvo.setScratchDb(self.scratchDb.dbName)
     52       
     53        # create Dvo and Datastore objects
     54        self.dvo = Dvo(self.logger, self.config, self.scratchDb.dbName)
     55        self.datastore = Datastore(self.logger, self.config, self.ippToPspsDb)
    5656
    5757        # if an IN batch is requested, create and quit
     
    7979
    8080    '''
    81     Overrides base-class version
     81    Overrides base-class version so we can ensure our scratch Db is using the right DVO Db
    8282    '''
    8383    def refreshConfig(self):
    8484
    8585        ret = super(Loader, self).refreshConfig()
    86        
    87         try: self.dvo.setScratchDb(self.scratchDb.dbName)
    88         except: pass
    89         self.datastore = Datastore(self.logger, self.config, self.ippToPspsDb)
     86        try: dvo
     87        except: return ret
     88
     89        dvo.checkDvoLocation()
    9090
    9191        return ret
     92
     93    '''
     94    Overrides base_class version so we can break out of processing loops if the config changes
     95    '''
     96    def checkClientStatus(self):
     97
     98        oldConfigName = self.config.name
     99        super(Loader, self).checkClientStatus()
     100        if oldConfigName != self.config.name:
     101            self.logger.infoPair("Config changed",  "from '" + oldConfigName + "' to '" + self.config.name + "'")
     102            self.config.printAll()
     103            return False
     104
     105        return True
    92106
    93107    '''
     
    99113        while True:
    100114
     115            abort = False
    101116            for batchType in self.config.batchTypes:
    102117
     
    112127                for boxId in boxIds:
    113128         
    114                     self.checkClientStatus()
     129                    if not self.checkClientStatus():
     130                        abort = True
     131                        break
    115132   
    116133                    # get box info. if boxes have changed, break and start again
     
    151168               
    152169                    self.logger.infoBool("Using pre-ingested DVO data?", useFullTables)
    153                     self.processTheseItems(batchType, ids, useFullTables)
    154 
    155             self.checkClientStatus()
    156             if numAttempts > 1 and not self.waitForPollTime(): break
     170                    if not self.processTheseItems(batchType, ids, useFullTables):
     171                        abort = True
     172                        break
     173
     174            if abort or not self.checkClientStatus(): abort = True
     175            elif numAttempts > 1 and not self.waitForPollTime():  break
    157176
    158177       
     
    200219            batch.run()
    201220   
    202             # check that we should continue
    203             self.checkClientStatus()
     221            if not self.checkClientStatus(): return False
    204222   
    205223            self.ippToPspsDb.lockBatchTable()
     
    212230        self.ippToPspsDb.unlockTables()
    213231        self.logger.infoPair("Unattempted batches", "%d" % unattemptedCount)
     232
     233        return True
    214234   
    215235    '''
Note: See TracChangeset for help on using the changeset viewer.