Hi,

I have created a patch to add a '--disableplugin' option,

ex.
yum --disableplugin=installonlyn list yum


Just want to make a sanity check, before commiting :-)

Tim
### Eclipse Workspace Patch 1.0
#P yum
Index: yum/plugins.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/plugins.py,v
retrieving revision 1.39
diff -u -r1.39 plugins.py
--- yum/plugins.py      26 Apr 2007 04:00:24 -0000      1.39
+++ yum/plugins.py      3 Jun 2007 17:25:14 -0000
@@ -106,7 +106,7 @@
     '''
 
     def __init__(self, base, searchpath, optparser=None, types=None, 
-            pluginconfpath=None):
+            pluginconfpath=None,disabled=None):
         '''Initialise the instance.
 
         @param base: The
@@ -128,6 +128,7 @@
         self.optparser = optparser
         self.cmdline = (None, None)
         self.verbose_logger = logging.getLogger("yum.verbose.YumPlugins")
+        self.disabledPlugins = disabled
         if not types:
             types = ALL_TYPES
 
@@ -227,6 +228,10 @@
 
             if plugintype not in types:
                 return
+        # Check if this plugin has been temporary disabled
+        if self.disabledPlugins:
+            if modname in self.disabledPlugins:
+                return
 
         self.verbose_logger.log(logginglevels.INFO_2, 'Loading "%s" plugin', 
modname)
 
Index: yum/__init__.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/__init__.py,v
retrieving revision 1.328
diff -u -r1.328 __init__.py
--- yum/__init__.py     29 May 2007 15:52:33 -0000      1.328
+++ yum/__init__.py     3 Jun 2007 17:25:14 -0000
@@ -110,7 +110,7 @@
         
     def _getConfig(self, fn='/etc/yum/yum.conf', root='/', init_plugins=True,
             plugin_types=(plugins.TYPE_CORE,), optparser=None, debuglevel=None,
-            errorlevel=None):
+            errorlevel=None,plugin_disabled=None):
         '''
         Parse and load Yum's configuration files and call hooks initialise
         plugins and logging.
@@ -126,6 +126,7 @@
             level will be read from the configuration file.
         @param errorlevel: Error level to use for logging. If None, the debug
             level will be read from the configuration file.
+        @param plugin_disabled: Plugins to be disabled    
         '''
 
         if self._conf:
@@ -148,7 +149,7 @@
 
         if init_plugins and startupconf.plugins:
             self.doPluginSetup(optparser, plugin_types, startupconf.pluginpath,
-                    startupconf.pluginconfpath)
+                    startupconf.pluginconfpath,plugin_disabled)
 
         self._conf = config.readMainConfig(startupconf)
         # run the postconfig plugin hook
@@ -258,7 +259,7 @@
         self.plugins = plugins.DummyYumPlugins()
     
     def doPluginSetup(self, optparser=None, plugin_types=None, searchpath=None,
-            confpath=None):
+            confpath=None,plugin_disabled=None):
         '''Initialise and enable yum plugins. 
 
         Note: _getConfig() will initialise plugins if instructed to. Only
@@ -275,12 +276,13 @@
         @param confpath: A list of directories to look in for plugin
             configuration files. A default will be used if no value is
             specified.
+        @param plugin_disabled: Plugins to be disabled    
         '''
         if isinstance(plugins, plugins.YumPlugins):
             raise RuntimeError("plugins already initialised")
 
         self.plugins = plugins.YumPlugins(self, searchpath, optparser,
-                plugin_types, confpath)
+                plugin_types, confpath, plugin_disabled)
 
     
     def doRpmDBSetup(self):
Index: cli.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/cli.py,v
retrieving revision 1.269
diff -u -r1.269 cli.py
--- cli.py      24 May 2007 00:48:35 -0000      1.269
+++ cli.py      3 Jun 2007 17:25:13 -0000
@@ -127,7 +127,7 @@
         
         # Parse only command line options that affect basic yum setup
         opts = self.optparser.firstParse(args)
-
+        
         # Just print out the version if that's what the user wanted
         if opts.version:
             print yum.__version__
@@ -143,7 +143,9 @@
                     plugin_types=(yum.plugins.TYPE_CORE, 
yum.plugins.TYPE_INTERACTIVE),
                     optparser=self.optparser,
                     debuglevel=opts.debuglevel,
-                    errorlevel=opts.errorlevel)
+                    errorlevel=opts.errorlevel,
+                    plugin_disabled=opts.disableplugins)
+                    
         except yum.Errors.ConfigError, e:
             self.logger.critical(_('Config Error: %s'), e)
             sys.exit(1)
@@ -1086,7 +1088,7 @@
         try:
             args = _filtercmdline(
                         ('--noplugins','--version'), 
-                        ('-c', '-d', '-e', '--installroot'), 
+                        ('-c', '-d', '-e', '--installroot','--disableplugin'), 
                         args)
         except ValueError:
             self.base.usage()
@@ -1120,7 +1122,7 @@
 
             if opts.installroot:
                 self.base.conf.installroot = opts.installroot
- 
+            
             for exclude in opts.exclude:
                 try:
                     excludelist = self.base.conf.exclude
@@ -1225,7 +1227,9 @@
                 help="disable Yum plugins")
         self.add_option("--nogpgcheck", action="store_true",
                 help="disable gpg signature checking")
-
+        self.add_option("", "--disableplugin", dest="disableplugins", 
default=[], 
+                action="append", help="disable plugins by name",
+                metavar='[plugin]')
         
 def _filtercmdline(novalopts, valopts, args):
     '''Keep only specific options from the command line argument list
_______________________________________________
Yum-devel mailing list
Yum-devel@linux.duke.edu
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to