On 12/05/2013 06:57 AM, Vratislav Podzimek wrote:
On Wed, 2013-12-04 at 11:05 -0500, David Shea wrote:
> On 12/04/2013 07:19 AM, Vratislav Podzimek wrote:
>> Signed-off-by: Vratislav Podzimek <vpodzime(a)redhat.com>
>> ---
>> anaconda.spec.in | 5 +++--
>> pyanaconda/keyboard.py | 39 ++++++++++++---------------------------
>> 2 files changed, 15 insertions(+), 29 deletions(-)
>>
>> diff --git a/anaconda.spec.in b/anaconda.spec.in
>> index 4c68b31..9bd6c30 100644
>> --- a/anaconda.spec.in
>> +++ b/anaconda.spec.in
>> @@ -41,6 +41,7 @@ Source0: %{name}-%{version}.tar.bz2
>> %define rpmver 4.10.0
>> %define libarchivever 3.0.4
>> %define langtablever 0.0.18-1
>> +%define libxklavierver 5.4
>>
>> BuildRequires: audit-libs-devel
>> BuildRequires: gettext >= %{gettextver}
>> @@ -55,7 +56,7 @@ BuildRequires: libXt-devel
>> BuildRequires: libXxf86misc-devel
>> BuildRequires: libgnomekbd-devel
>> BuildRequires: libnl-devel >= %{libnlver}
>> -BuildRequires: libxklavier-devel
>> +BuildRequires: libxklavier-devel >= %{libxklavierver}
>> BuildRequires: pango-devel
>> BuildRequires: pykickstart >= %{pykickstartver}
>> %if ! 0%{?rhel}
>> @@ -105,7 +106,7 @@ Requires: python-IPy
>> Requires: python-nss
>> Requires: tigervnc-server-minimal
>> Requires: pytz
>> -Requires: libxklavier
>> +Requires: libxklavier >= %{libxklavierver}
>> Requires: libgnomekbd
>> Requires: realmd
>> Requires: teamd
>> diff --git a/pyanaconda/keyboard.py b/pyanaconda/keyboard.py
>> index 21505a2..0d607e6 100644
>> --- a/pyanaconda/keyboard.py
>> +++ b/pyanaconda/keyboard.py
>> @@ -351,21 +351,6 @@ def background_XklWrapper_initialize():
>>
>> threadMgr.add(AnacondaThread(name=THREAD_XKL_WRAPPER_INIT,
target=XklWrapper.get_instance))
>>
>> -def item_str(s):
>> - """Convert a zero-terminated byte array to a proper
str"""
>> -
>> - # depending of version of libxklavier and the tools generating
introspection
>> - # data the value of 's' can be either byte string or list of
integers
>> - if type(s) == types.StringType:
>> - i = s.find(b'\x00')
>> - s = s[:i]
>> - elif type(s) == types.ListType:
>> - # XXX: this is the wrong case that should be fixed (rhbz#920595)
>> - i = s.index(0)
>> - s = "".join(chr(ctypes.c_uint8(char).value) for char in
s[:i])
>> -
>> - return s.decode("utf-8") #there are some non-ascii layout
descriptions
>> -
>> class XklWrapperError(KeyboardConfigError):
>> """Exception class for reporting libxklavier-related
problems"""
>>
>> @@ -442,11 +427,11 @@ class XklWrapper(object):
>>
>> def _get_lang_variant(self, c_reg, item, subitem, lang):
>> if subitem:
>> - name = item_str(item.name) + " (" + item_str(subitem.name)
+ ")"
>> - description = item_str(subitem.description)
>> + name = item.get_name() + " (" + subitem.get_name() +
")"
>> + description = subitem.get_description()
>> else:
>> - name = item_str(item.name)
>> - description = item_str(item.description)
>> + name = item.get_name()
>> + description = item.get_description()
>>
>> #if this layout has already been added for some other language,
>> #do not add it again (would result in duplicates in our lists)
>> @@ -456,11 +441,11 @@ class XklWrapper(object):
>>
>> def _get_country_variant(self, c_reg, item, subitem, country):
>> if subitem:
>> - name = item_str(item.name) + " (" + item_str(subitem.name)
+ ")"
>> - description = item_str(subitem.description)
>> + name = item.get_name() + " (" + subitem.get_name() +
")"
>> + description = subitem.get_description()
>> else:
>> - name = item_str(item.name)
>> - description = item_str(item.description)
>> + name = item.get_name()
>> + description = item.get_description()
>>
>> # if the layout was not added with any language, add it with a
country
>> if name not in self._layout_infos:
>> @@ -468,20 +453,20 @@ class XklWrapper(object):
>>
description.encode("utf-8"))
>>
>> def _get_language_variants(self, c_reg, item, user_data=None):
>> - lang_name, lang_desc = item_str(item.name), item_str(item.description)
>> + lang_name, lang_desc = item.get_name(), item.get_description()
>>
>> c_reg.foreach_language_variant(lang_name, self._get_lang_variant,
lang_desc)
>>
>> def _get_country_variants(self, c_reg, item, user_data=None):
>> - country_name, country_desc = item_str(item.name),
item_str(item.description)
>> + country_name, country_desc = item.get_name(), item.get_description()
>>
>> c_reg.foreach_country_variant(country_name,
self._get_country_variant,
>> country_desc)
>>
>> def _get_switch_option(self, c_reg, item, user_data=None):
>> """Helper function storing layout switching options in
foreach cycle"""
>> - desc = item_str(item.description)
>> - name = item_str(item.name)
>> + desc = item.get_description()
>> + name = item.get_name()
>>
>> self._switch_opt_infos[name] = desc.encode("utf-8")
>>
> Oops, found a problem. The .encode("utf-8") parts in _get_lang_variant
> no longer works right: I get a UnicodeDecodeError on that one Latvian
> layout with a Ū in the name. I'm guessing the behavior of the other
> encodes and decodes throughout the file are different now, too.
Hmm, that's weird, I run maybe 5 installations in different languages
with this patch applied and didn't hit any issue. I'll have a look at it
once more. Good catch, anyway, thanks!
Huh. I was running the change with run-spoke, so maybe the problem is
just in how the script initializes the class. I just tried an install
with an updates.img and it worked fine. So maybe this isn't actually a
problem.