[yum-git] 3 commits - cli.py yum/config.py yum/__init__.py yum/logginglevels.py yum/plugins.py yum/yumRepo.py

James Antill james at linux.duke.edu
Fri Feb 1 17:40:15 UTC 2008


 cli.py               |    5 +----
 yum/__init__.py      |    8 ++++++++
 yum/config.py        |    1 -
 yum/logginglevels.py |    5 +++++
 yum/plugins.py       |   14 +++++++++++++-
 yum/yumRepo.py       |    4 ++++
 6 files changed, 31 insertions(+), 6 deletions(-)

New commits:
commit fa6cef13e561c51330f30fd805bbee56bf4467c2
Author: James Antill <james at and.org>
Date:   Fri Feb 1 12:38:44 2008 -0500

    Make the dirs. we need for the log file

diff --git a/yum/logginglevels.py b/yum/logginglevels.py
index 8b1b61b..5ba3a70 100644
--- a/yum/logginglevels.py
+++ b/yum/logginglevels.py
@@ -149,6 +149,11 @@ def setFileLog(uid, logfile):
     # syslog-style log
     if uid == 0:
         try:
+            # For installroot etc.
+            logdir = os.path.dirname(filename)
+            if not os.path.exists(logdir):
+                os.makedirs(logdir, mode=0755)
+
             filelogger = logging.getLogger("yum.filelogging")
             filehandler = logging.FileHandler(logfile)
             formatter = logging.Formatter("%(asctime)s %(message)s",
commit b2f38c3df4c07f46fb1751281a15f6861eaa751f
Author: James Antill <james at and.org>
Date:   Fri Feb 1 12:36:17 2008 -0500

     Remove the undocumented config. var yumversion.
     Add the yum name/version into the default_grabber user_agent, and use that
    in all our URLGrabber() instances.

diff --git a/cli.py b/cli.py
index e4e813e..0a61f74 100644
--- a/cli.py
+++ b/cli.py
@@ -216,7 +216,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         """reads self.cmds and parses them out to make sure that the requested 
         base command + argument makes any sense at all""" 
 
-        self.verbose_logger.debug('Yum Version: %s', self.conf.yumversion)
+        self.verbose_logger.debug('Yum Version: %s', yum.__version__)
         self.verbose_logger.debug('COMMAND: %s', self.cmdstring)
         self.verbose_logger.debug('Installroot: %s', self.conf.installroot)
         if len(self.conf.commands) == 0 and len(self.cmds) < 1:
@@ -976,9 +976,6 @@ class YumOptionParser(OptionParser):
             # config file is parsed and moving us forward
             # set some things in it.
                 
-            # version of yum
-            self.base.conf.yumversion = yum.__version__
-            
             # Handle remaining options
             if opts.assumeyes:
                 self.base.conf.assumeyes =1
diff --git a/yum/__init__.py b/yum/__init__.py
index fd96d75..c9d3594 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -65,6 +65,8 @@ from yum.i18n import _
 
 import string
 
+from urlgrabber.grabber import default_grabber as urlgrab
+
 __version__ = '3.2.10'
 
 class YumBase(depsolve.Depsolve):
@@ -165,6 +167,12 @@ class YumBase(depsolve.Depsolve):
                     startupconf.pluginconfpath,disabled_plugins)
 
         self._conf = config.readMainConfig(startupconf)
+
+        #  Setup a default_grabber UA here that says we are yum, done this way
+        # so that other API users can add to it if they want.
+        add_ua = " yum/" + __version__
+        urlgrab.opts.user_agent += add_ua
+
         # run the postconfig plugin hook
         self.plugins.run('postconfig')
         self.yumvar = self.conf.yumvar
diff --git a/yum/config.py b/yum/config.py
index 416187a..59fe059 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -583,7 +583,6 @@ class YumConf(StartupConf):
     commands = ListOption()
     exclude = ListOption()
     failovermethod = Option('roundrobin')
-    yumversion = Option('unversioned')
     proxy = UrlOption(schemes=('http', 'ftp', 'https'), allow_none=True)
     proxy_username = Option()
     proxy_password = Option()
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 1a7d918..23db351 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -22,6 +22,7 @@ urlparse.uses_fragment.append("media")
 
 import Errors
 from urlgrabber.grabber import URLGrabber
+from urlgrabber.grabber import default_grabber
 import urlgrabber.mirror
 from urlgrabber.grabber import URLGrabError
 import repoMDObject
@@ -427,6 +428,7 @@ class YumRepository(Repository, config.RepoConf):
                                     http_headers=headers,
                                     reget='simple')
 
+        self._grabfunc.opts.user_agent = default_grabber.opts.user_agent
 
         self._grab = mgclass(self._grabfunc, self.urls,
                              failure_callback=self.mirror_failure_obj)
@@ -599,6 +601,8 @@ class YumRepository(Repository, config.RepoConf):
                             http_headers=headers,
                             )
 
+            ug.opts.user_agent = default_grabber.opts.user_agent
+
             remote = url + '/' + relative
 
             try:
commit 8527b2d9238d16f7a16810d71cc4749c81324cfc
Author: James Antill <james at and.org>
Date:   Fri Feb 1 11:34:37 2008 -0500

    Have a single loaded plugins line

diff --git a/yum/plugins.py b/yum/plugins.py
index 2e674e6..21f7128 100644
--- a/yum/plugins.py
+++ b/yum/plugins.py
@@ -30,6 +30,8 @@ import config
 import Errors
 from parser import ConfigPreProcessor
 
+from textwrap import fill
+
 
 # TODO: expose rpm package sack objects to plugins (once finished)
 # TODO: allow plugins to use the existing config stuff to define options for
@@ -184,6 +186,15 @@ class YumPlugins:
                 continue
             for modulefile in glob.glob('%s/*.py' % dir):
                 self._loadplugin(modulefile, types)
+            plugins = sorted(self._plugins)
+
+            # Mostly copied from YumOutput._outKeyValFill()
+            key = "Loaded plugins: "
+            val = ", ".join(plugins)
+            nxt = ' ' * (len(key) - 2) + ': '
+            self.verbose_logger.log(logginglevels.INFO_2,
+                                    fill(val, width=80, initial_indent=key,
+                                         subsequent_indent=nxt))
 
     def _loadplugin(self, modulefile, types):
         '''Attempt to import a plugin module and register the hook methods it
@@ -238,7 +249,8 @@ class YumPlugins:
             if modname in self.disabledPlugins:
                 return
 
-        self.verbose_logger.log(logginglevels.INFO_2, 'Loading "%s" plugin', modname)
+        self.verbose_logger.log(logginglevels.DEBUG_3, 'Loading "%s" plugin',
+                                modname)
 
         # Store the plugin module and its configuration file
         if not self._plugins.has_key(modname):



More information about the Yum-cvs-commits mailing list