def execute(self): source_db = PHINMS_DB() feeder = Batchfile_Feeder(verbosity=self.verbosity, source_db=source_db) feeder.copy_tempdir = self.copy_tempdir while True: try: # long running process, capture interrupt if systemUnderLoad(): logging.info("system under load - continue anyhow") if self.files: # Look up the given files for their filedates self.files = source_db.name_dates(self.files) else: self.files = source_db.filelist(self.progression) # If we didn't get any back, we've caught up, take # this opportunity to sleep for a while if self.daemon_mode and not self.files: logging.debug("no files found, sleeping") sleep(5 * 60) for batch_file, filedate in self.files: feeder.upload(batch_file, filedate) self.files = None # done with that batch if not self.daemon_mode: raise (SystemExit('non daemon-mode exit')) except: logging.info("Shutting down") raise # now exit finally: source_db.close()
def setUp(self): super(TestPhinmsDB, self).setUp() self.phinms = PHINMS_DB()