[yum-commits] yum/Errors.py yum/yumRepo.py

zpavlas at osuosl.org zpavlas at osuosl.org
Wed Aug 22 15:16:01 UTC 2012


 yum/Errors.py  |   15 +++++++++++++--
 yum/yumRepo.py |   11 +++--------
 2 files changed, 16 insertions(+), 10 deletions(-)

New commits:
commit 08548580dcdaa4f4d600327b3b799b50554a0806
Author: Zdeněk Pavlas <zpavlas at redhat.com>
Date:   Tue Aug 21 16:45:42 2012 +0200

    Show full URLs and mirror errors when _getFile() fails.
    
    - add .errors attribute to NoMoreMirrorsRepoError.
    - include URLs and error messages in unicode(e).
    
    Also updated/fixed:
    
    - We may never get URLGrabError(256) without MirrorGroup.
    
    - When MG's failure_callback signals fail=1, the LAST error
      is re-raised.  We turn this into NoMoreMirrorsRepoError, too.
      (NoMoreMirrors should actually read AllMirrorsFailed, but..)

diff --git a/yum/Errors.py b/yum/Errors.py
index c1af4ad..e3e3956 100644
--- a/yum/Errors.py
+++ b/yum/Errors.py
@@ -79,9 +79,20 @@ class RepoError(YumBaseError):
 class DuplicateRepoError(RepoError):
     pass
 
+# Have our own custom .value with all the mirror errors.
 class NoMoreMirrorsRepoError(RepoError):
-    pass
-    
+    def __init__(self, value=None, errors=None):
+        Exception.__init__(self)
+        self._value = value
+        self.errors = errors
+
+    @property
+    def value(self):
+        ret = self._value
+        for url, msg in self.errors or []:
+            ret += '\n%s: %s' % (url, msg)
+        return ret
+
 class ConfigError(YumBaseError):
     pass
     
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index b7b4357..e60fc20 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -891,10 +891,7 @@ Insufficient space in download directory %s
                 if self.mirrorurls:
                     errstr +="\n  You could try running: yum clean expire-cache"
                     errstr +="\n  To get a new set of mirrors."
-                if e.errno == 256:
-                    raise Errors.NoMoreMirrorsRepoError, errstr
-                else:
-                    raise Errors.RepoError, errstr
+                raise Errors.RepoError, errstr
 
 
         else:
@@ -912,10 +909,8 @@ Insufficient space in download directory %s
                                            )
             except URLGrabError, e:
                 errstr = "failure: %s from %s: %s" % (relative, self.id, e)
-                if e.errno == 256:
-                    raise Errors.NoMoreMirrorsRepoError, errstr
-                else:
-                    raise Errors.RepoError, errstr
+                errors = getattr(e, 'errors', None)
+                raise Errors.NoMoreMirrorsRepoError(errstr, errors)
 
         return result
     __get = _getFile


More information about the Yum-commits mailing list