Alon Bar-Lev has uploaded a new change for review.

Change subject: packagers: yum: drop the local helper
......................................................................

packagers: yum: drop the local helper

Change-Id: I65e3340bc805811e5e2a41af23bd53386ba340ae
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M po/POTFILES.in
M src/plugins/otopi/packagers/Makefile.am
D src/plugins/otopi/packagers/miniyumlocal.py
M src/plugins/otopi/packagers/yumpackager.py
4 files changed, 65 insertions(+), 103 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/otopi refs/changes/78/15778/1

diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5aae2ba..774280b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -32,7 +32,6 @@
 ./src/plugins/otopi/network/iptables.py
 ./src/plugins/otopi/network/ssh.py
 ./src/plugins/otopi/packagers/__init__.py
-./src/plugins/otopi/packagers/miniyumlocal.py
 ./src/plugins/otopi/packagers/yumpackager.py
 ./src/plugins/otopi/services/__init__.py
 ./src/plugins/otopi/services/openrc.py
diff --git a/src/plugins/otopi/packagers/Makefile.am 
b/src/plugins/otopi/packagers/Makefile.am
index daf3f42..732c773 100644
--- a/src/plugins/otopi/packagers/Makefile.am
+++ b/src/plugins/otopi/packagers/Makefile.am
@@ -27,7 +27,6 @@
 dist_my_PYTHON = \
        __init__.py \
        yumpackager.py \
-       miniyumlocal.py \
        $(NULL)
 
 clean-local: \
diff --git a/src/plugins/otopi/packagers/miniyumlocal.py 
b/src/plugins/otopi/packagers/miniyumlocal.py
deleted file mode 100644
index 038d88e..0000000
--- a/src/plugins/otopi/packagers/miniyumlocal.py
+++ /dev/null
@@ -1,98 +0,0 @@
-#
-# otopi -- plugable installer
-# Copyright (C) 2012-2013 Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-
-
-"""miniyum interaction."""
-
-
-import time
-import gettext
-_ = lambda m: gettext.dgettext(message=m, domain='otopi')
-
-
-from otopi import constants
-from otopi import util
-from otopi import miniyum
-
-
-class _MyMiniYumSink(miniyum.MiniYumSinkBase):
-    """miniyum interaction."""
-
-    def _touch(self):
-        self._last = time.time()
-
-    def __init__(self, parent):
-        super(_MyMiniYumSink, self).__init__()
-        self._parent = parent
-        self._touch()
-
-    def verbose(self, msg):
-        super(_MyMiniYumSink, self).verbose(msg)
-        self._parent.logger.debug('Yum %s' % msg)
-
-    def info(self, msg):
-        super(_MyMiniYumSink, self).info(msg)
-        self._parent.logger.info('Yum %s' % msg)
-        self._touch()
-
-    def error(self, msg):
-        super(_MyMiniYumSink, self).error(msg)
-        self._parent.logger.error('Yum %s' % msg)
-        self._touch()
-
-    def keepAlive(self, msg):
-        super(_MyMiniYumSink, self).keepAlive(msg)
-        if time.time() - self._last >= self._parent.environment[
-            constants.PackEnv.KEEP_ALIVE_INTERVAL
-        ]:
-            self.info(msg)
-
-    def askForGPGKeyImport(self, userid, hexkeyid):
-        return self._parent.dialog.confirm(
-            constants.Confirms.GPG_KEY,
-            _(
-                'Confirm use of GPG Key '
-                'userid={userid} hexkeyid={hexkeyid}'
-            ).format(
-                userid=userid,
-                hexkeyid=hexkeyid,
-            )
-        )
-
-    def reexec(self):
-        super(_MyMiniYumSink, self).reexec()
-        self._parent.context.notify(self._parent.context.NOTIFY_REEXEC)
-
-
[email protected]
-def getMiniYum(
-    parent,
-    disabledPlugins=[],
-    enabledPlugins=[]
-):
-    """Get miniyum objects at separate source to ease making it optional."""
-    return miniyum.MiniYum(
-        sink=_MyMiniYumSink(parent=parent),
-        blockStdHandles=False,
-        disabledPlugins=disabledPlugins,
-        enabledPlugins=enabledPlugins,
-    )
-
-
-# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/plugins/otopi/packagers/yumpackager.py 
b/src/plugins/otopi/packagers/yumpackager.py
index 87c783a..a67fea2 100644
--- a/src/plugins/otopi/packagers/yumpackager.py
+++ b/src/plugins/otopi/packagers/yumpackager.py
@@ -22,6 +22,7 @@
 
 
 import os
+import time
 import gettext
 _ = lambda m: gettext.dgettext(message=m, domain='otopi')
 
@@ -41,6 +42,7 @@
         Confirms.GPG_KEY -- confirm use of gpg key.
 
     """
+
     class YumTransaction(transaction.TransactionElement):
         """yum transaction element."""
 
@@ -58,6 +60,68 @@
 
         def commit(self):
             self._miniyum.endTransaction(rollback=False)
+
+    def _getMiniYum(
+        self,
+        disabledPlugins=[],
+        enabledPlugins=[]
+    ):
+        from otopi import miniyum
+
+        class _MyMiniYumSink(miniyum.MiniYumSinkBase):
+            """miniyum interaction."""
+
+            def _touch(self):
+                self._last = time.time()
+
+            def __init__(self, parent):
+                super(_MyMiniYumSink, self).__init__()
+                self._parent = parent
+                self._touch()
+
+            def verbose(self, msg):
+                super(_MyMiniYumSink, self).verbose(msg)
+                self._parent.logger.debug('Yum %s' % msg)
+
+            def info(self, msg):
+                super(_MyMiniYumSink, self).info(msg)
+                self._parent.logger.info('Yum %s' % msg)
+                self._touch()
+
+            def error(self, msg):
+                super(_MyMiniYumSink, self).error(msg)
+                self._parent.logger.error('Yum %s' % msg)
+                self._touch()
+
+            def keepAlive(self, msg):
+                super(_MyMiniYumSink, self).keepAlive(msg)
+                if time.time() - self._last >= self._parent.environment[
+                    constants.PackEnv.KEEP_ALIVE_INTERVAL
+                ]:
+                    self.info(msg)
+
+            def askForGPGKeyImport(self, userid, hexkeyid):
+                return self._parent.dialog.confirm(
+                    constants.Confirms.GPG_KEY,
+                    _(
+                        'Confirm use of GPG Key '
+                        'userid={userid} hexkeyid={hexkeyid}'
+                    ).format(
+                        userid=userid,
+                        hexkeyid=hexkeyid,
+                    )
+                )
+
+            def reexec(self):
+                super(_MyMiniYumSink, self).reexec()
+                self._parent.context.notify(self._parent.context.NOTIFY_REEXEC)
+
+        return miniyum.MiniYum(
+            sink=_MyMiniYumSink(parent=self),
+            blockStdHandles=False,
+            disabledPlugins=disabledPlugins,
+            enabledPlugins=enabledPlugins,
+        )
 
     def __init__(self, context):
         super(Plugin, self).__init__(context=context)
@@ -83,9 +147,7 @@
                 constants.Defaults.PACKAGER_KEEP_ALIVE_INTERVAL
             )
 
-            from . import miniyumlocal
-            self._miniyum = miniyumlocal.getMiniYum(
-                parent=self,
+            self._miniyum = self._getMiniYum(
                 disabledPlugins=self.environment[
                     constants.PackEnv.YUM_DISABLED_PLUGINS
                 ],


-- 
To view, visit http://gerrit.ovirt.org/15778
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I65e3340bc805811e5e2a41af23bd53386ba340ae
Gerrit-PatchSet: 1
Gerrit-Project: otopi
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to