def cleanupCacheDir(self): cleanupCacheMonitor = JobMonitorer() cleanupCacheMonitor.job_starts() logging.info('Start cache cleanup ...') cleanupDir = self.configService.getRepoCacheDir() try: for reponame in os.listdir(cleanupDir): if reponame.startswith('.'): continue # check for cache dirs of already deleted repos absoluteDir = os.path.join(cleanupDir, reponame) if os.path.isdir(absoluteDir): if not os.path.exists(self.configService.getStaticRepoDir(reponame)): shutil.rmtree(absoluteDir) continue lockfile = self.configService.getRepoLockFile(reponame) if not os.path.exists(lockfile): shutil.rmtree(absoluteDir) except Exception as ex: logging.error("Exception in CleanupCacheDir : "+str(ex)) finally: cleanupCacheMonitor.job_finishes() logging.info(cleanupCacheMonitor.get_pretty_job_summary("CleanupCacheDir"))
def createrepo_with_optional_cleanup_job(self, *argList): monitor = JobMonitorer() monitor.job_starts() repoDir = argList[0] reponame = argList[1] rpm_max_keep = argList[2] didCleanUp=False try: if rpm_max_keep != None: didCleanUp=True self.configService.doCleanup(repoDir, rpm_max_keep) logging.info("job RpmCleanup on "+reponame+" took "+str(monitor.get_execution_time_until_now_seconds())+" seconds") self.configService.doCreateRepo(repoDir, reponame) monitor.job_finishes() logging.info(monitor.get_pretty_job_summary("createrepo on "+reponame+" (cleanup included : "+str(didCleanUp)+")")) except Exception, ex: logging.error(traceback.format_exc())
def cleanupCacheDir(self): cleanupCacheMonitor = JobMonitorer() cleanupCacheMonitor.job_starts() logging.info('Start cache cleanup ...') cleanupDir = self.configService.getRepoCacheDir() try: for reponame in os.listdir(cleanupDir): if reponame.startswith('.'): continue # check for cache dirs of already deleted repos absoluteDir = os.path.join(cleanupDir, reponame) if os.path.isdir(absoluteDir): if not os.path.exists(self.configService.getStaticRepoDir(reponame)): shutil.rmtree(absoluteDir) continue lockfile = self.configService.getRepoLockFile(reponame) if not os.path.exists(lockfile): shutil.rmtree(absoluteDir) except Exception, ex: logging.error("Exception in CleanupCacheDir : "+str(ex))
def createrepo_with_optional_cleanup_job(self, *argList): monitor = JobMonitorer() monitor.job_starts() repoDir = argList[0] reponame = argList[1] rpm_max_keep = argList[2] didCleanUp=False try: if rpm_max_keep != None: didCleanUp=True self.configService.doCleanup(repoDir, rpm_max_keep) logging.info("job RpmCleanup on "+reponame+" took "+str(monitor.get_execution_time_until_now_seconds())+" seconds") self.configService.doCreateRepo(repoDir, reponame) monitor.job_finishes() logging.info(monitor.get_pretty_job_summary("createrepo on "+reponame+" (cleanup included : "+str(didCleanUp)+")")) except Exception as ex: logging.error(traceback.format_exc())