1 From 7243f1fcc395cdf87815ac5a33c0d2f8b61c0cdf Mon Sep 17 00:00:00 2001
2 From: Sebastian Pipping <sebastian@pipping.org>
3 Date: Sun, 20 Sep 2009 21:38:35 +0200
4 Subject: [PATCH 1/2] Client: Hopefully fix encoding trouble
6 More or less a squashed cherry-pick from these commits:
7 - 7592c44f6eef240aaae147ba11ffe85a4156068b
8 - 81bfa3f0f5172d853f95034e061c4e3a4bd55ebe
9 - b21ddc39c1e51329a957a463aff3b7db09f5a726
10 - fa41853f7fcbe5e465bbd25fbe94942a87a5d2bb
12 client/sendProfile.py | 9 +++++----
13 client/smolt.py | 11 +++++++++++
14 2 files changed, 16 insertions(+), 4 deletions(-)
16 diff --git a/client/sendProfile.py b/client/sendProfile.py
17 index 46b0f18..ff3a0a9 100644
18 --- a/client/sendProfile.py
19 +++ b/client/sendProfile.py
20 @@ -36,6 +36,7 @@ import smolt
21 from smolt import debug
22 from smolt import error
23 from smolt import get_config_attr
24 +from smolt import to_ascii
25 from scan import scan, rating
26 from gate import GateFromConfig
28 @@ -179,10 +180,10 @@ if not opts.autoSend:
29 'label_fs_related':_('File system-related'),
30 'label_distro_specific':_('Distribution-specific'),
32 - 'general':inner_indent(profile.get_general_info_excerpt()),
33 - 'devices':inner_indent(profile.get_devices_info_excerpt()),
34 - 'file_system':inner_indent(profile.get_file_system_info_excerpt()),
35 - 'distro':inner_indent(profile.get_distro_info_excerpt()),
36 + 'general':inner_indent(to_ascii(profile.get_general_info_excerpt())),
37 + 'devices':inner_indent(to_ascii(profile.get_devices_info_excerpt())),
38 + 'file_system':inner_indent(to_ascii(profile.get_file_system_info_excerpt())),
39 + 'distro':inner_indent(to_ascii(profile.get_distro_info_excerpt())),
43 diff --git a/client/smolt.py b/client/smolt.py
44 index dee142f..7016ab6 100644
47 @@ -51,6 +51,7 @@ from fs_util import get_fslist
50 from uuiddb import UuidDb
53 WITHHELD_MAGIC_STRING = 'WITHHELD'
55 @@ -140,6 +141,16 @@ PCI_CLASS_SERIAL_USB = 3
56 PCI_CLASS_SERIAL_FIBER = 4
57 PCI_CLASS_SERIAL_SMBUS = 5
59 +def to_ascii(o, current_encoding='utf-8'):
60 + if not isinstance(o, basestring):
63 + if isinstance(o, unicode):
66 + s = unicode(o, current_encoding)
67 + return codecs.encode(s, 'ascii', 'ignore')
70 def __init__(self, props, hardware):