Signed-off-by: Lucas Meneghel Rodrigues <[email protected]>
---
 client/shared/software_manager.py | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/client/shared/software_manager.py 
b/client/shared/software_manager.py
index d54f587..4459dfb 100755
--- a/client/shared/software_manager.py
+++ b/client/shared/software_manager.py
@@ -83,7 +83,6 @@ class SystemInspector(object):
             else:
                 pm_supported = list_supported[0]
 
-        logging.debug('Package Manager backend: %s' % pm_supported)
         return pm_supported
 
 
@@ -95,8 +94,6 @@ class SoftwareManager(object):
     uses the concept of a backend, a helper class that implements the set of
     operations of a given package management tool.
     """
-    initialized = False
-
     def __init__(self):
         """
         Lazily instantiate the object
@@ -107,6 +104,7 @@ class SoftwareManager(object):
         self.base_command = None
         self.pm_version = None
 
+
     def _init_on_demand(self):
         """
         Determines the best supported package management system for the given
@@ -115,17 +113,19 @@ class SoftwareManager(object):
         if not self.initialized:
             inspector = SystemInspector()
             backend_type = inspector.get_package_management()
-            if backend_type == 'yum':
-                self.backend = YumBackend()
-            elif backend_type == 'zypper':
-                self.backend = ZypperBackend()
-            elif backend_type == 'apt-get':
-                self.backend = AptBackend()
-            else:
+            backend_mapping = {'apt-get': AptBackend,
+                               'yum': YumBackend,
+                               'zypper': ZypperBackend}
+
+            if backend_type not in backend_mapping.keys():
                 raise NotImplementedError('Unimplemented package management '
                                           'system: %s.' % backend_type)
+
+            backend = backend_mapping[backend_type]
+            self.backend = backend()
             self.initialized = True
 
+
     def __getattr__(self, name):
         self._init_on_demand()
         return self.backend.__getattribute__(name)
-- 
1.8.1.2

_______________________________________________
Autotest-kernel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/autotest-kernel

Reply via email to