[yum-commits] Branch 'yum-3_2_X' - 2 commits - cli.py utils.py yum/i18n.py yum/__init__.py yummain.py
James Antill
james at osuosl.org
Wed Aug 10 13:50:46 UTC 2011
cli.py | 4 ++--
utils.py | 30 +-----------------------------
yum/__init__.py | 4 ++--
yum/i18n.py | 28 ++++++++++++++++++++++++++++
yummain.py | 4 ++--
5 files changed, 35 insertions(+), 35 deletions(-)
New commits:
commit 8e16be3c248ec485ef2926c5d39759d22e22e51f
Author: ZdenÄk Pavlas <zpavlas at redhat.com>
Date: Wed Aug 10 10:41:23 2011 +0200
Some more str(e) => exception2msg(e) fixes.
diff --git a/cli.py b/cli.py
index 43c0e1d..00374d8 100755
--- a/cli.py
+++ b/cli.py
@@ -43,7 +43,7 @@ from yum.rpmtrans import RPMTransaction
import signal
import yumcommands
-from yum.i18n import to_unicode, to_utf8
+from yum.i18n import to_unicode, to_utf8, exception2msg
# This is for yum-utils/yumdownloader in RHEL-5, where it isn't importing this
# directly but did do "from cli import *", and we did have this in 3.2.22. I
@@ -457,7 +457,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
try:
self._getTs(needTsRemove)
except yum.Errors.YumBaseError, e:
- return 1, [str(e)]
+ return 1, [exception2msg(e)]
return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd, self.extcmds)
diff --git a/yum/__init__.py b/yum/__init__.py
index b7808bd..2a8e278 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -82,7 +82,7 @@ from packages import YumAvailablePackage, YumLocalPackage, YumInstalledPackage
from packages import YumUrlPackage, YumNotFoundPackage
from constants import *
from yum.rpmtrans import RPMTransaction,SimpleCliCallBack
-from yum.i18n import to_unicode, to_str
+from yum.i18n import to_unicode, to_str, exception2msg
import string
import StringIO
@@ -2027,7 +2027,7 @@ class YumBase(depsolve.Depsolve):
done_repos.add(po.repoid)
except Errors.RepoError, e:
- adderror(po, str(e))
+ adderror(po, exception2msg(e))
else:
po.localpath = mylocal
if po in errors:
commit 900b9f17b81c54b9246a6677324f04c9d6320dca
Author: ZdenÄk Pavlas <zpavlas at redhat.com>
Date: Wed Aug 10 09:59:03 2011 +0200
Move exception2msg() from utils.py to i18n.py
diff --git a/utils.py b/utils.py
index 90b6fd4..99533a6 100755
--- a/utils.py
+++ b/utils.py
@@ -23,7 +23,7 @@ import yum
from cli import *
from yum import Errors
from yum import _
-from yum.i18n import utf8_width
+from yum.i18n import utf8_width, exception2msg
from yum import logginglevels
from optparse import OptionGroup
@@ -163,34 +163,6 @@ def show_lock_owner(pid, logger):
return ps
-def exception2msg(e):
- """Convert an exception to a message. This function will convert
- the exception using to_unicode, unicode, or str, whichever works correctly.
-
- :param e: an exception
- :return: a string representation of the exception
- """
-
- # DIE python DIE! Which one works:
- # to_unicode(e.value); unicode(e); str(e);
- # Call this so you don't have to care.
- try:
- return to_unicode(e.value)
- except:
- pass
-
- try:
- return unicode(e)
- except:
- pass
-
- try:
- return str(e)
- except:
- pass
- return "<exception failed to convert to text>"
-
-
class YumUtilBase(YumBaseCli):
"""A class to extend the yum cli for utilities."""
diff --git a/yum/i18n.py b/yum/i18n.py
index 9889bf6..85ad15e 100755
--- a/yum/i18n.py
+++ b/yum/i18n.py
@@ -462,6 +462,34 @@ def str_eq(a, b):
return False
+def exception2msg(e):
+ """Convert an exception to a message. This function will convert
+ the exception using to_unicode, unicode, or str, whichever works correctly.
+
+ :param e: an exception
+ :return: a string representation of the exception
+ """
+
+ # DIE python DIE! Which one works:
+ # to_unicode(e.value); unicode(e); str(e);
+ # Call this so you don't have to care.
+ try:
+ return to_unicode(e.value)
+ except:
+ pass
+
+ try:
+ return unicode(e)
+ except:
+ pass
+
+ try:
+ return str(e)
+ except:
+ pass
+ return "<exception failed to convert to text>"
+
+
try:
'''
Setup the yum translation domain and make _() and P_() translation wrappers
diff --git a/yummain.py b/yummain.py
index d7ba288..4b1112a 100755
--- a/yummain.py
+++ b/yummain.py
@@ -29,10 +29,10 @@ from yum import Errors
from yum import plugins
from yum import logginglevels
from yum import _
-from yum.i18n import to_unicode, utf8_width
+from yum.i18n import to_unicode, utf8_width, exception2msg
import yum.misc
import cli
-from utils import suppress_keyboard_interrupt_message, show_lock_owner, exception2msg
+from utils import suppress_keyboard_interrupt_message, show_lock_owner
def main(args):
"""Run the yum program from a command line interface."""
More information about the Yum-commits
mailing list