Create a subclass of yum to work around logging fun

This commit is contained in:
Jesse Keating 2007-08-08 23:50:33 -04:00 committed by Jesse Keating
parent d98fe83e7a
commit 9cb130eb8d

View File

@ -17,6 +17,29 @@ import os
import shutil import shutil
import sys import sys
class PungiYum(yum.YumBase):
"""Subclass of Yum"""
def __init__(self, config):
self.pungiconfig = config
yum.YumBase.__init__(self)
def doLoggingSetup(self, debuglevel, errorlevel):
"""Setup the logging facility."""
logdir = os.path.join(self.pungiconfig.get('default', 'destdir'), 'logs')
if not os.path.exists(logdir):
os.makedirs(logdir)
if self.pungiconfig.get('default', 'flavor'):
logfile = os.path.join(logdir, '%s.%s.log' % (self.pungiconfig.get('default', 'flavor'),
self.pungiconfig.get('default', 'arch')))
else:
logfile = os.path.join(logdir, '%s.log' % (self.pungiconfig.get('default', 'arch')))
yum.logging.basicConfig(level=yum.logging.DEBUG, filename=logfile)
class Gather(): class Gather():
def __init__(self, config, pkglist): def __init__(self, config, pkglist):
self.workdir = os.path.join(config.get('default', 'destdir'), self.workdir = os.path.join(config.get('default', 'destdir'),
@ -36,7 +59,7 @@ class Gather():
self.compsobj.add(self.config.get('default', 'comps')) self.compsobj.add(self.config.get('default', 'comps'))
# Create a yum object to use # Create a yum object to use
self.ayum = yum.YumBase() self.ayum = PungiYum(config)
self.ayum.doConfigSetup(fn=config.get('default', 'yumconf'), debuglevel=6, errorlevel=6, root=os.path.join(self.workdir, 'yumroot')) self.ayum.doConfigSetup(fn=config.get('default', 'yumconf'), debuglevel=6, errorlevel=6, root=os.path.join(self.workdir, 'yumroot'))
self.ayum.cleanMetadata() # clean metadata that might be in the cache from previous runs self.ayum.cleanMetadata() # clean metadata that might be in the cache from previous runs
self.ayum.cleanSqlite() # clean metadata that might be in the cache from previous runs self.ayum.cleanSqlite() # clean metadata that might be in the cache from previous runs
@ -62,26 +85,6 @@ class Gather():
self.logger = yum.logging.getLogger("yum.verbose.pungi") self.logger = yum.logging.getLogger("yum.verbose.pungi")
self.ayum.logger = yum.logging.getLogger("yum.verbose.pungi") self.ayum.logger = yum.logging.getLogger("yum.verbose.pungi")
def doLoggingSetup(self, debuglevel, errorlevel):
"""Setup the logging facility."""
logdir = os.path.join(self.config.get('default', 'destdir'), 'logs')
if not os.path.exists(logdir):
os.makedirs(logdir)
if self.config.get('default', 'flavor'):
logfile = os.path.join(logdir, '%s.%s.log' % (self.config.get('default', 'flavor'),
self.config.get('default', 'arch')))
else:
logfile = os.path.join(logdir, '%s.log' % (self.config.get('default', 'arch')))
yum.logging.basicConfig(level=yum.logging.DEBUG, filename=logfile)
def doFileLogSetup(self, uid, logfile):
# This function overrides a yum function, allowing pungi to control
# the logging.
pass
def verifyCachePkg(self, po, path): # Stolen from yum def verifyCachePkg(self, po, path): # Stolen from yum
"""check the package checksum vs the cache """check the package checksum vs the cache
return True if pkg is good, False if not""" return True if pkg is good, False if not"""