[Yum-devel] [PATCH] Show full URLs and mirror errors when _getFile() fails.
James Antill
james at fedoraproject.org
Wed Aug 22 13:45:34 UTC 2012
On Wed, 2012-08-22 at 11:50 +0200, Zdeněk Pavlas wrote:
> - add .errors attribute to NoMoreMirrorsRepoError.
> - include URLs and error messages in unicode(e).
> - exception2msg: prefer unicode(e) to e.value.
> diff --git a/yum/Errors.py b/yum/Errors.py
> index c1af4ad..ca23c24 100644
> --- a/yum/Errors.py
> +++ b/yum/Errors.py
> @@ -80,7 +80,14 @@ class DuplicateRepoError(RepoError):
> pass
>
> class NoMoreMirrorsRepoError(RepoError):
> - pass
> + def __init__(self, value=None, errors=None):
> + RepoError.__init__(self, value)
> + self.errors = errors
> + def __unicode__(self):
> + ret = self.value
> + for url, msg in self.errors or []:
> + ret += '\n%s: %s' % (url, msg)
> + return ret
Can this return non-unicode strings? Is that legal?
One fix, which I think is compatible, would be:
# Have our own custom .value with all the mirror errors.
class NoMoreMirrorsRepoError(RepoError):
def __init__(self, value=None, errors=None):
Exception.__init__(self)
self._value = value
self.errors = errors
def _getValue(self):
ret = self._value
for url, msg in self.errors or []:
ret += '\n%s: %s' % (url, msg)
return ret
value = property(fget=lambda self: self._getValue())
def __unicode__(self):
return unicode(self.value)
...pretty sure nothing tries to set .value (although that's not too hard
to add a property for, if something does). Also still not sure about the
"ret +=" bit and unicide ... but, meh.
More information about the Yum-devel
mailing list