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

Change subject: packaging: setup: yum: do not use yum state strings
......................................................................

packaging: setup: yum: do not use yum state strings

the yum.i18n produces non standard string encoding, encoded using ansi
codec but has unicode string, while the locale environment is set to
unicode, and python does enforce proper unicode in string.format().

the solution is to provide our own translation table for transaction
status, as no [simple] way was found to convert the non standard format
into unicode.

Change-Id: If230a17799263e705f194f180af04bf2904a5d90
Reported-By: Jakub Bittner <j.bitt...@nbu.cz>
Signed-off-by: Alon Bar-Lev <alo...@redhat.com>
---
M packaging/fedora/setup/miniyum.py
1 file changed, 26 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/93/17393/1

diff --git a/packaging/fedora/setup/miniyum.py 
b/packaging/fedora/setup/miniyum.py
index 86555c2..a7a5497 100755
--- a/packaging/fedora/setup/miniyum.py
+++ b/packaging/fedora/setup/miniyum.py
@@ -105,6 +105,18 @@
 class MiniYum(object):
     """Minimalist yum API interaction."""
 
+    TRANSACTION_STATE = {
+        yum.constants.TS_UPDATE: _('update'),
+        yum.constants.TS_INSTALL: _('install'),
+        yum.constants.TS_TRUEINSTALL: _('trueinstall'),
+        yum.constants.TS_ERASE: _('erase'),
+        yum.constants.TS_OBSOLETED: _('obsoleted'),
+        yum.constants.TS_OBSOLETING: _('obsoleting'),
+        yum.constants.TS_AVAILABLE: _('available'),
+        yum.constants.TS_UPDATED: _('updated'),
+        'repackaging': _('repackaging'),
+    }
+
     class _LogHandler(logging.Handler):
         """Required for extracting yum log output."""
 
@@ -176,12 +188,20 @@
             if self._lastaction != action or package != self._lastpackage:
                 self._lastaction = action
                 self._lastpackage = package
+
+                #
+                # NOTE:
+                # do not use self.action as it is encoded
+                # using invalid encoding, some unicode proprietary
+                # for yum.
+                # test using LC_ALL=cs_CZ.utf8, LANG=cs_CZ
+                #
                 self._sink.info(
                     _('{action}: {count}/{total}: {package}').format(
-                        action=self.action[action],
+                        action=MiniYum.TRANSACTION_STATE.get(action, action),
                         count=ts_current,
                         total=ts_total,
-                        package=package
+                        package=package.name,
                     )
                 )
 
@@ -811,19 +831,12 @@
         try:
             with self._disableOutput:
                 ret = []
-                state = {
-                    yum.constants.TS_UPDATE: "update",
-                    yum.constants.TS_INSTALL: "install",
-                    yum.constants.TS_TRUEINSTALL: "trueinstall",
-                    yum.constants.TS_ERASE: "erase",
-                    yum.constants.TS_OBSOLETED: "obsoleted",
-                    yum.constants.TS_OBSOLETING: "obsoleting",
-                    yum.constants.TS_AVAILABLE: "available",
-                    yum.constants.TS_UPDATED: "updated",
-                }
                 for txmbr in sorted(self._yb.tsInfo):
                     info = self._get_package_info(txmbr)
-                    info['operation'] = state[txmbr.output_state]
+                    info['operation'] = self.TRANSACTION_STATE.get(
+                        txmbr.output_state,
+                        txmbr.output_state
+                    )
                     ret.append(info)
                 return ret
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If230a17799263e705f194f180af04bf2904a5d90
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to