[Yum-devel] [PATCH] yum/yumRepo does not uses URLGrabber provided by yum extension

Romain Pelisse belaran at gmail.com
Wed Sep 7 16:41:52 UTC 2011


Hi,

A little bit of context first : I encounter this "bug" (if it is really one)
when I start using the yum-s3 [1] plugin to set up a yum repository on
Amazon S3 services. In order to make the repository private (and therefore
uses Amazon credential), we had to use this plugin. The plugin provided it
own URLGrabber - one able to authenticate properly against S3.

However, inside Yum's code (cf patch below or my fork on github [2]) I had
to modify the yumRepo class to ensure it actually uses the URLGrabber
provided by yum-s3 plugin.

Disclaimer: I am a very poor python programmer and I basically "hack" the
yum's code to get it working as I expect. This might be not a real bug, or
you might completely disagree with the all approach. I'm just reporting the
issue and offering my solution. If you have suggestions or if you want me to
rework this, I'm also willing to do so...
[1] https://github.com/NumberFour/yum-s3-plugin
[2] https://github.com/rpelisse/yum/tree/yum-3_2_X (branch 3.2.X)

Patch:
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index f7257d1..49a1067 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -637,6 +637,12 @@ class YumRepository(Repository, config.RepoConf):
                     fset=lambda self, value: setattr(self, "_urls", value),
                     fdel=lambda self: setattr(self, "_urls", None))

+    def _createDefaultGrabber(**kwargs):
+        ug = self._getgrab()
+        if ug == nil:
+            return URLGrabber(kwargs)
+        return ug
+
     def _getMetalink(self):
         if not self._metalink:
             self.metalink_filename = self.cachedir + '/' + 'metalink.xml'
@@ -644,7 +650,7 @@ class YumRepository(Repository, config.RepoConf):
             if not self._metalinkCurrent():
                 url = misc.to_utf8(self.metalink)
                 try:
-                    ug = URLGrabber(bandwidth = self.bandwidth,
+                    ug = _createDefaultGrabber(bandwidth = self.bandwidth,
                                     retry = self.retries,
                                     throttle = self.throttle,
                                     progress_obj = self.callback,
@@ -738,7 +744,7 @@ class YumRepository(Repository, config.RepoConf):
                 verbose_logger.log(logginglevels.DEBUG_2, "Error getting
package from media; falling back to url %s" %(e,))

         if url and scheme != "media":
-            ug = URLGrabber(keepalive = self.keepalive,
+            ug = _createDefaultGrabber(keepalive = self.keepalive,
                             bandwidth = self.bandwidth,
                             retry = self.retries,
                             throttle = self.throttle,

-- 
Romain PELISSE,
*"The trouble with having an open mind, of course, is that people will
insist on coming along and trying to put things in it" -- Terry Pratchett*
http://belaran.eu/wordpress/belaran
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.baseurl.org/pipermail/yum-devel/attachments/20110907/e0ade8fe/attachment.html>


More information about the Yum-devel mailing list