summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-01-10 16:47:22 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-01-10 16:47:22 +0100
commit5a721a992e6aea9df92e8bd2b02ab147c92e8f0b (patch)
tree2d65b338d67c4c33b4a925cbfecbace895d391c8 /pykolab
parent165602c5f24ee847c213e579f5690c4cd11e1e3f (diff)
downloadpykolab-5a721a992e6aea9df92e8bd2b02ab147c92e8f0b.tar.gz
Add debug statements for transliteration using pykolab.utils.translate(), so we can work out bugs such as #1508 and #1536
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/utils.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/pykolab/utils.py b/pykolab/utils.py
index dc2b088..7f56c29 100644
--- a/pykolab/utils.py
+++ b/pykolab/utils.py
@@ -23,9 +23,12 @@ import os
import pwd
import sys
+import pykolab
from pykolab import constants
from pykolab.translate import _
+log = pykolab.getLogger('pykolab.utils')
+
def ask_question(question, default="", password=False, confirm=False):
"""
Ask a question on stderr.
@@ -389,14 +392,19 @@ def translate(mystring, locale_name='en_US'):
import locale
import subprocess
+ log.debug(_("Transliterating string %r with locale %r") % (mystring, locale_name), level=8)
+
if len(locale.normalize(locale_name).split('.')) > 1:
(locale_name,locale_charset) = locale.normalize(locale_name).split('.')
else:
locale_charset = 'utf-8'
try:
+ log.debug(_("Attempting to set locale"), level=8)
locale.setlocale(locale.LC_ALL, (locale_name,locale_charset))
+ log.debug(_("Success setting locale"), level=8)
except:
+ log.debug(_("Failure to set locale"), level=8)
pass
command = [ '/usr/bin/iconv',
@@ -404,9 +412,10 @@ def translate(mystring, locale_name='en_US'):
'-t', 'ASCII//TRANSLIT',
'-s' ]
+ log.debug(_("Executing '%s | %s'") % (r"%s" % (mystring), ' '.join(command)), level=8)
process = subprocess.Popen(command, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE, env={'LANG': locale.normalize(locale_name)})
- print >> process.stdin, mystring
+ print >> process.stdin, r"%s" % mystring
result = process.communicate()[0].strip()