def processRelease (self): """ Process one release. Returns a list of strings with a summary of what was done. It is for human consumption. """ notLocked= True if self.cleanLevel=='release': notLocked= False # try to lock self.lockfile= '%(repoDir)s/lock-%(distro)s-%(release)s' % self logger.debug ("lockfile is %s" % self.lockfile) if lockFile (self.lockfile): notLocked= True logger.debug ("keeping %s" % self.lockfile) self.keep[self.lockfile]= '%(repo)s/%(distro)s/%(release)s' % self if notLocked: # we gotta clean the lockfile later try: logger.info ('---- processing %(repo)s/%(distro)s/%(release)s' % self) self.releaseFailed= False self.releaseFailedFiles= [] if (not self.process_old and not self.wipe) or (self.wipe and self.download_db): self.getReleaseDatabases () if not self.wipe: archs= getattr (self, 'archs', [ None ]) for arch in archs: self.arch= arch self.archSize= 0 logger.info ('----- processing %(repo)s/%(distro)s/%(release)s/%(arch)s' % self) modules= getattr (self, 'modules', [ None ]) for module in modules: # won't log what module we are processing self.module= module self.moduleSize= 0 self.processModule () self.archSize+= self.moduleSize if self.showSize: # in MiB print u"%(moduleSize)10.2f %(repo)s/%(distro)s/%(release)s/%(arch)s/%(module)s" % self if self.showSize: # in MiB print u"%(archSize)10.2f %(repo)s/%(distro)s/%(release)s/%(arch)s" % self self.releaseSize+= self.archSize # reset count self.downloadedSize= 0 except TopmostException, e: # BUG: what happens when a database fails to load? self.releaseFailed= True if self.cleanLevel=='release': unlockFile (self.lockfile) logger.warn ('processing %(repo)s/%(distro)s/%(release)s failed due to' % self) logger.warn (e) print_exc () if ( (isinstance (e, IOError) and e.errno==errno.ENOSPC) or isinstance (e, KeyboardInterrupt) ): # out of disk space or keyb int raise finally:
def processRepo (self): """ Process the whole repo. Returns a list of strings with a summary of what was done. It is for human consumption. """ logger.info ("=== processing "+self.repo) self.totalSize= 0 notLocked= True logger.debug ("clean level: %s" % self.cleanLevel) if self.cleanLevel=='repo': # try to lock notLocked= False self.lockfile= '%s/lock' % self.repoDir logger.debug ("lockfile is %s" % self.lockfile) if lockFile (self.lockfile): notLocked= True logger.debug ("keeping %s" % self.lockfile) self.keep[self.lockfile]= '%(repo)s' % self if notLocked: # we gotta clean the lockfile later try: if not self.save_space and not self.process_old and not self.wipe: # create tmp dir self.tempDir= ".tmp" logger.debug ("not cont: working on %s" % self.tempDir) else: self.tempDir= '.' for i in xrange (int (getattr (self, 'retries', '1'))): distros= getattr (self, 'distros', [None]) for distro in distros: self.distroSize= 0 self.distro= distro if distro is not None: pass releases= getattr (self, 'releases', [None]) for release in releases: self.releaseSize= 0 self.release= release self.processRelease () if self.showSize: # in MiB print u"%(releaseSize)10.2f %(repo)s/%(distro)s/%(release)s" % self self.distroSize+= self.releaseSize if self.showSize: # in MiB print u"%(distroSize)10.2f %(repo)s/%(distro)s" % self self.repoSize+= self.distroSize if self.cleanLevel=='repo' and not self.showSize and not self.databasesFailed: self.cleanRepo (self.repoDir) except TopmostException, e: logger.debug ("repo except'ed! %s" % e) if self.cleanLevel=='repo': unlockFile (self.lockfile) # reraise raise else: if self.cleanLevel=='repo': unlockFile (self.lockfile)