On 05/16/12 23:57, Danek Duvall wrote:
Sorry for the long delay.
Change looks good, though I'd add an assertion that unicode_list isn't
empty, with an explanation of the failure. Something like
self.assert_(unicode_list, "You must have one of the following locales "
"installed for this test to succeed: " + ", ".join(unicode_locales))
And on line 583, in the dictionary, don't put a space before the colon.
Thanks Danek for review. I have incorporated the above suggestion. The
updated webrev is :
https://cr.opensolaris.org/action/browse/pkg/ae112802/7140680-rev4/webrev/
I have also attached patch. Could you please integrate it.
Abhi.
--
Oracle
Abhinandan Ekande
Solaris Install,
Revenue Product Engineering (RPE), Systems
Phone: +91 8067283830 | Fax: +91 80 22231794 | Mobile: +91 9632144088
ORACLE India | Off Langford Road | Bangalore | 560025
Green Oracle <http://www.oracle.com/commitment> Oracle is committed to
developing practices and products that help protect the environment
# HG changeset patch
# User abhinandan.eka...@oracle.com
# Date 1337243642 -19800
# Node ID 3bdd03f9d72cf4f84a2a9d5c28724d1011bf78b5
# Parent 41a4fd204b0b2ec5ad9239802e6026d0d21e4e69
7140680 "pkg history" does not work in some localized locales
diff -r 41a4fd204b0b -r 3bdd03f9d72c src/client.py
--- a/src/client.py Mon May 14 09:13:08 2012 -0700
+++ b/src/client.py Thu May 17 14:04:02 2012 +0530
@@ -5652,9 +5652,17 @@
if not output["new_be_uuid"]:
output["new_be_uuid"] = _("(None)")
+ enc = locale.getlocale(locale.LC_CTYPE)[1]
+ if not enc:
+ enc = locale.getpreferredencoding()
+
if long_format:
data = __get_long_history_data(he, output)
for field, value in data:
+ if isinstance(field, unicode):
+ field = field.encode(enc)
+ if isinstance(value, unicode):
+ value = value.encode(enc)
msg("%18s: %s" % (field, value))
# Separate log entries with a blank line.
@@ -5662,7 +5670,10 @@
else:
items = []
for col in columns:
- items.append(output[col])
+ item = output[col]
+ if isinstance(item, unicode):
+ item = item.encode(enc)
+ items.append(item)
msg(history_fmt % tuple(items))
return EXIT_OK
diff -r 41a4fd204b0b -r 3bdd03f9d72c src/tests/cli/t_pkg_history.py
--- a/src/tests/cli/t_pkg_history.py Mon May 14 09:13:08 2012 -0700
+++ b/src/tests/cli/t_pkg_history.py Thu May 17 14:04:02 2012 +0530
@@ -34,6 +34,7 @@
import random
import re
import shutil
+import subprocess
import time
import unittest
import xml.etree.ElementTree
@@ -567,5 +568,22 @@
self.pkg("history -n 1 -o time")
self.assert_("369576:0:0" in self.output)
+ def test_14_history_unicode_locale(self):
+ """Verify we can get history when unicode locale is set"""
+
+ # If pkg history run when below locales set, it fails.
+ unicode_locales = ["fr_FR.UTF-8", "zh_TW.UTF-8", "zh_CN.UTF-8",
+ "ko_KR.UTF-8", "ja_JP.UTF-8"]
+ p = subprocess.Popen(["/usr/bin/locale", "-a"],
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ lines = p.stdout.readlines()
+ locale_list = [i.rstrip() for i in lines]
+ unicode_list = list(set(locale_list) & set(unicode_locales))
+ self.assert_(unicode_list, "You must have one of the "
+ " following locales installed for this test to succeed: "
+ + ", ".join(unicode_locales))
+ env = { "LC_ALL": unicode_list[0] }
+ self.pkg("history", env_arg=env)
+
if __name__ == "__main__":
unittest.main()
diff -r 41a4fd204b0b -r 3bdd03f9d72c src/tests/pkg5unittest.py
--- a/src/tests/pkg5unittest.py Mon May 14 09:13:08 2012 -0700
+++ b/src/tests/pkg5unittest.py Thu May 17 14:04:02 2012 +0530
@@ -2211,7 +2211,7 @@
def pkg(self, command, exit=0, comment="", prefix="", su_wrap=None,
out=False, stderr=False, cmd_path=None, use_img_root=True,
- debug_smf=True):
+ debug_smf=True, env_arg=None):
if debug_smf and "smf_cmds_dir" not in command:
command = "--debug smf_cmds_dir=%s %s" % \
(DebugValues["smf_cmds_dir"], command)
@@ -2222,7 +2222,8 @@
cmd_path = self.pkg_cmdpath
cmdline = "%s %s" % (cmd_path, command)
return self.cmdline_run(cmdline, exit=exit, comment=comment,
- prefix=prefix, su_wrap=su_wrap, out=out, stderr=stderr)
+ prefix=prefix, su_wrap=su_wrap, out=out, stderr=stderr,
+ env_arg=env_arg)
def pkgdepend_resolve(self, args, exit=0, comment="", su_wrap=False):
ops = ""
_______________________________________________
pkg-discuss mailing list
pkg-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss