Hi,

happy new year.

I have attached two small patches to imporove the SUSE client support.

The first one is a general workaround for a not installed yum.
Currently the classes are only defined if platform is "deb", but also on SUSE 
with zypp plugin, yum is not installed.
Additionally it fixes some python errors in the original code. You cannot 
assign a class which is defined later.

The second one is a small patch to check for the zypp plugin and hide the 
warning about the not installed yum plugin. 

-- 
Regards

        Michael Calmer

--------------------------------------------------------------------------
Michael Calmer
SUSE LINUX Products GmbH, Maxfeldstr. 5, D-90409 Nuernberg
T: +49 (0) 911 74053 0
F: +49 (0) 911 74053575  - e-mail: michael.cal...@suse.com
--------------------------------------------------------------------------
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer
HRB 16746 (AG Nürnberg)
From 57c05d29e7d0845358390a07ff760e6f097a3298 Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Thu, 1 Dec 2011 16:58:02 +0100
Subject: [PATCH 1/2] implement YumBaseError and RepoError on ImportError if yum cannot be loaded

---
 .../src/up2date_client/up2dateErrors.py            |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

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 c88169b..3945901 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/up2dateErrors.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/up2dateErrors.py
@@ -13,19 +13,17 @@ t = gettext.translation('rhn-client-tools', fallback=True)
 _ = t.ugettext
 import OpenSSL
 import config
-from platform import getPlatform
 
-if getPlatform() == 'deb':
-    RepoError = Error
+try:
+    from yum.Errors import YumBaseError
+except ImportError:
     class YumBaseError(Exception):
         def __init__(self, errmsg):
             self.value = errmsg
-        def __getattribute__(self, name):
+        def __getattr__(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
 
 class Error(YumBaseError):
     """base class for errors"""
@@ -65,7 +63,12 @@ class Error(YumBaseError):
                 YumBaseError.__setattr__(self, name, value)
             else:
                 self.__dict__[name] = value
-    
+
+try:
+    from yum.Errors import RepoError
+except ImportError:
+    RepoError = Error
+
 class RpmError(Error):
     """rpm itself raised an error condition"""
     premsg = _("RPM error.  The message was:\n")
-- 
1.7.3.4

From c2e234b3d1c055a6ada59ad2ba92d4f7bc291581 Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Thu, 1 Dec 2011 17:22:08 +0100
Subject: [PATCH 2/2] do not print yum-rhn-plugin warning if zypp-plugin is used

---
 .../src/up2date_client/yumPlugin.py                |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/client/rhel/rhn-client-tools/src/up2date_client/yumPlugin.py b/client/rhel/rhn-client-tools/src/up2date_client/yumPlugin.py
index 5116533..ed7e910 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/yumPlugin.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/yumPlugin.py
@@ -21,6 +21,9 @@ def pluginEnable():
         else:
             createDefaultYumRHNPluginConf()
             conf_changed = 1
+    elif os.path.exists("/usr/lib/zypp/plugins/services/spacewalk"):
+        """SUSE zypp plugin is installed"""
+        plugin_present = 1
     return plugin_present, conf_changed
 
 def YumRHNPluginPackagePresent():
-- 
1.7.3.4

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to