[Yum-devel] condensing error callbacks

Chris Lumens clumens at redhat.com
Tue May 23 18:38:00 UTC 2006


Paul and I have been working on making the package error handling in
anaconda suck less.  In the middle of all this, we discovered that yum
does not support passing a failure callback to a mirror object.  The
result of this is that an error grabbing a file with mgclass as set up
by setupGrab causes a RepoError to be raised, instead of the registered
urlgrabber error callback getting used.

The solution is to just pass a failure_callback keyword argument to
mgclass, as it is already setup to deal with this argument.  We also
added methods to set the callback that should be used in the mirror case
on Repository and YumRepo.

Oh also, I removed some extraneous apostrophes as reading that causes me
to stop, re-read it, and wonder exactly what the sentence is supposed to
mean.

- Chris
-------------- next part --------------
Index: yum/repos.py
===================================================================
RCS file: /cvsroot/yum/cvs/yum/yum/repos.py,v
retrieving revision 1.91
diff -u -r1.91 repos.py
--- yum/repos.py	11 Apr 2006 21:34:10 -0000	1.91
+++ yum/repos.py	23 May 2006 17:32:35 -0000
@@ -154,17 +154,23 @@
             repo.basecachedir = cachedir
 
     def setProgressBar(self, obj):
-        """set's the progress bar for downloading files from repos"""
+        """sets the progress bar for downloading files from repos"""
         
         for repo in self.repos.values():
             repo.setCallback(obj)
 
     def setFailureCallback(self, obj):
-        """set's the failure callback for all repos"""
+        """sets the failure callback for all repos"""
         
         for repo in self.repos.values():
             repo.setFailureObj(obj)
 
+    def setMirrorFailureCallback(self, obj):
+        """sets the failure callback for all mirrors"""
+        
+        for repo in self.repos.values():
+            repo.setMirrorFailureObj(obj)
+
     def getPackageSack(self):
         return self.pkgSack
 
@@ -279,6 +285,9 @@
     def setFailureObj(self, obj):
         raise NotImplementedError()
 
+    def setMirrorFailureObj(self, obj):
+        raise NotImplementedError()
+
     def getPackage(self, package, checkfunc = None, text = None, cache = True):
         raise NotImplementedError()
 
Index: yum/yumRepo.py
===================================================================
RCS file: /cvsroot/yum/cvs/yum/yum/yumRepo.py,v
retrieving revision 1.4
diff -u -r1.4 yumRepo.py
--- yum/yumRepo.py	19 Apr 2006 22:10:37 -0000	1.4
+++ yum/yumRepo.py	23 May 2006 17:32:35 -0000
@@ -140,8 +140,6 @@
         self.repoMDFile = 'repodata/repomd.xml'
         self.repoXML = None
         self.cache = 0
-        self.callback = None # callback for the grabber
-        self.failure_obj = None
         self.mirrorlist = None # filename/url of mirrorlist file
         self.mirrorlistparsed = 0
         self.baseurl = [] # baseurls from the config file 
@@ -165,6 +163,7 @@
         # callbacks
         self.callback = None  # for the grabber
         self.failure_obj = None
+        self.mirror_failure_obj = None
 
         # Check to see if we can import sqlite stuff
         try:
@@ -334,7 +333,8 @@
                                    timeout=self.timeout,
                                    reget='simple')
 
-        self.grab = mgclass(self.grabfunc, self.urls)
+        self.grab = mgclass(self.grabfunc, self.urls,
+                            failure_callback=self.mirror_failure_obj)
 
     def dirSetup(self):
         """make the necessary dirs, if possible, raise on failure"""
@@ -694,6 +694,9 @@
     def setFailureObj(self, failure_obj):
         self.failure_obj = failure_obj
 
+    def setMirrorFailureObj(self, failure_obj):
+        self.mirror_failure_obj = failure_obj
+
 
 
 def getMirrorList(mirrorlist, pdict = None):


More information about the Yum-devel mailing list