[Pkg-libvirt-commits] [SCM] Virtinst Debian packaging branch, master, updated. debian/0.500.2-1-1-g004c933
Laurent Léonard
laurent at open-minds.org
Tue Mar 2 15:49:31 UTC 2010
The following commit has been merged in the master branch:
commit 004c933e1ba6b8f364128b7223d1e33a4e25c7f0
Author: Laurent Léonard <laurent at open-minds.org>
Date: Tue Mar 2 16:46:13 2010 +0100
Hopefully fix unicode locale use once and for all!
Closes: #565941
Thanks: Cole Robinson
diff --git a/debian/patches/0004-Hopefully-fix-unicode-locale-use-once-and-for-all.patch b/debian/patches/0004-Hopefully-fix-unicode-locale-use-once-and-for-all.patch
new file mode 100644
index 0000000..030dc0c
--- /dev/null
+++ b/debian/patches/0004-Hopefully-fix-unicode-locale-use-once-and-for-all.patch
@@ -0,0 +1,249 @@
+From: Cole Robinson <crobinso at redhat.com>
+Date: Mon, 1 Mar 2010 17:52:49 -0500
+Subject: [PATCH] Hopefully fix unicode locale use once and for all!
+
+Closes: #565941
+Origin: upstream, http://hg.fedoraproject.org/hg/python-virtinst/rev/3eae7ab7e457
+Origin: upstream, http://hg.fedoraproject.org/hg/python-virtinst/rev/4cc206766cce
+---
+ virt-clone | 9 +------
+ virt-convert | 10 +-------
+ virt-image | 10 +-------
+ virt-install | 11 +--------
+ virtinst/__init__.py | 2 +-
+ virtinst/cli.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++--
+ 6 files changed, 58 insertions(+), 36 deletions(-)
+
+diff --git a/virt-clone b/virt-clone
+index a1798f5..cbbdd04 100755
+--- a/virt-clone
++++ b/virt-clone
+@@ -22,20 +22,15 @@
+
+ import sys
+ import logging
+-import virtinst
+ import virtinst.CloneManager as clmgr
+ import urlgrabber.progress as progress
+
+ from optparse import OptionGroup
+-import gettext
+-import locale
+ import virtinst.cli as cli
+ from virtinst.cli import fail
+ from virtinst.User import User
+
+-locale.setlocale(locale.LC_ALL, '')
+-gettext.bindtextdomain(virtinst.gettext_app, virtinst.gettext_dir)
+-gettext.install(virtinst.gettext_app, virtinst.gettext_dir, unicode=1)
++cli.setupGettext()
+
+ ### General input gathering functions
+ def get_clone_name(new_name, auto_clone, design):
+@@ -127,7 +122,7 @@ def get_force_target(target, design):
+ design.set_force_target(i)
+
+ def parse_args():
+- parser = cli.VirtOptionParser(version=virtinst.__version__)
++ parser = cli.setupParser()
+
+ parser.add_option("", "--connect", type="string", dest="connect",
+ action="callback", callback=cli.check_before_store,
+diff --git a/virt-convert b/virt-convert
+index 3213613..8b9760c 100755
+--- a/virt-convert
++++ b/virt-convert
+@@ -25,27 +25,21 @@ import sys
+ import os
+ import logging
+ import errno
+-import gettext, locale
+ from optparse import OptionGroup
+
+-import virtinst
+ import virtinst.cli as cli
+ from virtinst.cli import fail
+ import virtinst.util as util
+-import virtconv
+ import virtconv.formats as formats
+ import virtconv.vmcfg as vmcfg
+ import virtconv.diskcfg as diskcfg
+
+-locale.setlocale(locale.LC_ALL, '')
+-gettext.bindtextdomain(virtconv.gettext_app, virtconv.gettext_dir)
+-gettext.install(virtconv.gettext_app, virtconv.gettext_dir, unicode=1)
++cli.setupGettext()
+
+ def parse_args():
+ """Parse and verify command line."""
+ usage = "%prog [options] inputdir|input.vmx [outputdir|output.xml]"
+- opts = cli.VirtOptionParser(usage=usage,
+- version=virtinst.__version__)
++ opts = cli.setupParser(usage)
+
+ cong = OptionGroup(opts, "Conversion Options")
+ cong.add_option("-i", "--input-format", action="store",
+diff --git a/virt-image b/virt-image
+index abd5854..5382615 100755
+--- a/virt-image
++++ b/virt-image
+@@ -32,12 +32,8 @@ from virtinst.cli import fail
+
+ import optparse
+ from optparse import OptionGroup
+-import gettext
+-import locale
+
+-locale.setlocale(locale.LC_ALL, '')
+-gettext.bindtextdomain(virtinst.gettext_app, virtinst.gettext_dir)
+-gettext.install(virtinst.gettext_app, virtinst.gettext_dir, unicode=1)
++cli.setupGettext()
+
+ ### General input gathering functions
+
+@@ -70,9 +66,7 @@ def get_graphics(domain, vnc, vncport, vnclisten, nographics, sdl, keymap,
+ ### Option parsing
+ def parse_args():
+ usage = "%prog [options] image.xml"
+- parser = cli.VirtOptionParser(usage=usage,
+- formatter=cli.VirtHelpFormatter(),
+- version=virtinst.__version__)
++ parser = cli.setupParser(usage)
+
+ parser.add_option("", "--connect", type="string", dest="connect",
+ action="callback", callback=cli.check_before_store,
+diff --git a/virt-install b/virt-install
+index 71e03f3..8b33b94 100755
+--- a/virt-install
++++ b/virt-install
+@@ -37,12 +37,7 @@ from virtinst.VirtualCharDevice import VirtualCharDevice
+ from virtinst.VirtualDevice import VirtualDevice
+ from virtinst.cli import fail
+
+-import gettext
+-import locale
+-
+-locale.setlocale(locale.LC_ALL, '')
+-gettext.bindtextdomain(virtinst.gettext_app, virtinst.gettext_dir)
+-gettext.install(virtinst.gettext_app, virtinst.gettext_dir, unicode=1)
++cli.setupGettext()
+
+ DEFAULT_POOL_PATH = "/var/lib/libvirt/images"
+ DEFAULT_POOL_NAME = "default"
+@@ -499,9 +494,7 @@ def validate_install_media(guest, location, cdpath, cdinstall=False):
+ ### Option parsing
+ def parse_args():
+ usage = "%prog --name NAME --ram RAM STORAGE INSTALL [options]"
+- parser = cli.VirtOptionParser(usage=usage,
+- formatter=cli.VirtHelpFormatter(),
+- version=virtinst.__version__)
++ parser = cli.setupParser(usage)
+
+ parser.add_option("", "--connect", type="string", dest="connect",
+ action="callback", callback=cli.check_before_store,
+diff --git a/virtinst/__init__.py b/virtinst/__init__.py
+index 07e60a1..1828acc 100644
+--- a/virtinst/__init__.py
++++ b/virtinst/__init__.py
+@@ -16,7 +16,7 @@
+
+ import gettext
+
+-gettext_dir = "::LOCALEDIR::"
++gettext_dir = "/usr/share/locale"
+ gettext_app = "virtinst"
+
+ gettext.bindtextdomain(gettext_app, gettext_dir)
+diff --git a/virtinst/cli.py b/virtinst/cli.py
+index 591f00b..5624a5d 100644
+--- a/virtinst/cli.py
++++ b/virtinst/cli.py
+@@ -22,7 +22,7 @@
+ import os, sys
+ import logging
+ import logging.handlers
+-import locale
++import gettext, locale
+ import optparse
+ from optparse import OptionValueError, OptionParser
+
+@@ -44,6 +44,29 @@ def check_if_test_uri_remote(uri):
+ _util.is_uri_remote = lambda uri_: True
+ return uri
+
++class VirtStreamHandler(logging.StreamHandler):
++
++ def emit(self, record):
++ """
++ Based on the StreamHandler code from python 2.6: ripping out all
++ the unicode handling and just uncoditionally logging seems to fix
++ logging backtraces with unicode locales (for me at least).
++
++ No doubt this is atrocious, but it WORKSFORME!
++ """
++ try:
++ msg = self.format(record)
++ stream = self.stream
++ fs = "%s\n"
++
++ stream.write(fs % msg)
++
++ self.flush()
++ except (KeyboardInterrupt, SystemExit):
++ raise
++ except:
++ self.handleError(record)
++
+ class VirtOptionParser(OptionParser):
+ '''Subclass to get print_help to work properly with non-ascii text'''
+
+@@ -56,8 +79,18 @@ class VirtOptionParser(OptionParser):
+ def print_help(self, file=None):
+ if file is None:
+ file = sys.stdout
++
+ encoding = self._get_encoding(file)
+- file.write(self.format_help().encode(encoding, "replace"))
++ helpstr = self.format_help()
++ try:
++ encodedhelp = helpstr.encode(encoding, "replace")
++ except UnicodeError:
++ # I don't know why the above fails hard, unicode makes my head
++ # spin. Just printing the format_help() output seems to work
++ # quite fine, with the occasional character ?.
++ encodedhelp = helpstr
++
++ file.write(encodedhelp)
+
+ class VirtHelpFormatter(optparse.IndentedHelpFormatter):
+ """
+@@ -87,6 +120,19 @@ class VirtHelpFormatter(optparse.IndentedHelpFormatter):
+ # Setup helpers
+ #
+
++def setupParser(usage=None):
++ parse_class = VirtOptionParser
++
++ parser = parse_class(usage=usage,
++ formatter=VirtHelpFormatter(),
++ version=virtinst.__version__)
++ return parser
++
++def setupGettext():
++ locale.setlocale(locale.LC_ALL, '')
++ gettext.bindtextdomain(virtinst.gettext_app, virtinst.gettext_dir)
++ gettext.install(virtinst.gettext_app, virtinst.gettext_dir)
++
+ def setupLogging(appname, debug=False):
+ # set up logging
+ vi_dir = os.path.expanduser("~/.virtinst")
+@@ -116,7 +162,7 @@ def setupLogging(appname, debug=False):
+ dateFormat))
+ rootLogger.addHandler(fileHandler)
+
+- streamHandler = logging.StreamHandler(sys.stderr)
++ streamHandler = VirtStreamHandler(sys.stderr)
+ if debug:
+ streamHandler.setLevel(logging.DEBUG)
+ streamHandler.setFormatter(logging.Formatter(streamDebugFormat,
+--
diff --git a/debian/patches/series b/debian/patches/series
index 3419750..bed58c4 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
0001-fix-path-to-hvmloader.patch
0002-Fix-path-to-pygrub.patch
0003-Fix-path-to-keyboard-configuration.patch
+0004-Hopefully-fix-unicode-locale-use-once-and-for-all.patch
--
Virtinst Debian packaging
More information about the Pkg-libvirt-commits
mailing list