client/rhel/rhn-client-tools/src/up2date_client/up2dateErrors.py | 24 ++++++++--
1 file changed, 20 insertions(+), 4 deletions(-)
New commits:
commit 33666946cb441e646bdca76ab18b05e8b4ab73f3
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Nov 29 11:40:06 2011 +0100
define __init__, __getattribute__, __setattr__ on Debian and workaround those mising
methods on RHEL5
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/up2dateErrors.py
b/client/rhel/rhn-client-tools/src/up2date_client/up2dateErrors.py
index 97d9ac3..989e876 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/up2dateErrors.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/up2dateErrors.py
@@ -17,8 +17,13 @@ from platform import getPlatform
if getPlatform() == 'deb':
RepoError = Error
- class YumBaseError:
- pass
+ class YumBaseError(Exception):
+ def __init__(self, errmsg):
+ self.value = errmsg
+ def __getattribute__(self, name):
+ raise AttributeError(_("class %s has no attribute '%s'") %
(self.__class__.__name__, name))
+ def __setattr__(self, name, value):
+ raise AttributeError(_("class %s has no attribute '%s'") %
(self.__class__.__name__, name))
else:
from yum.Errors import RepoError, YumBaseError
@@ -41,14 +46,25 @@ class Error(YumBaseError):
if name == 'errmsg':
return self.value
else:
- return YumBaseError.__getattribute__(self, name)
+ if hasattr(YumBaseError, '__getattribute__'):
+ # rhel5 has no __getattribute__()
+ return YumBaseError.__getattribute__(self, name)
+ else:
+ if name in self.__dict__:
+ return self.__dict__[name]
+ else:
+ raise AttributeError(_("class %s has no attribute
'%s'") % (self.__class__.__name__, name))
def __setattr__(self, name, value):
""" Spacewalk backend still use errmsg, let have errmsg as alias
to value """
if name == 'errmsg':
self.__dict__['value'] = value
else:
- YumBaseError.__setattr__(self, name, value)
+ if hasattr(YumBaseError, '__setattr__'):
+ # rhel5 has no __setattr__()
+ YumBaseError.__setattr__(self, name, value)
+ else:
+ self.__dict__[name] = value
class RpmError(Error):
"""rpm itself raised an error condition"""