unicode and os.system
Dumbkiwi
dmbkiwi at yahoo.com
Fri Sep 2 19:04:34 EDT 2005
I've got a rather large python script that I write and maintain. It has
some interaction with other programmes on the linux/kde desktop through
the dcop interface. This script also uses the gettext module to enable
the output of the script to be translated into several languages,
including utf-8 encoded text.
However, when I issue a dcop call to an application (which is a docker
application that can display text above an icon), the operation fails with:
Traceback (most recent call last):
File "/home/matt/karamba/lwbkup/liquid_weather.py", line 2970, in widgetUpdated
os.system('dcop kxdocker docker changeTextByName Current "%s : %s"' %(_(situtext), weather.temperature()))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 2:
ordinal not in range(128)
_(situtext) is a variable containing a unicode string.
My python environment has ascii as its encoding for stdout
>>> import sys
>>> print sys.stdout.encoding
ANSI_X3.4-1968
the dcop call I'm using requires a QString variable where the _(situtext)
is.
Can anyone help me to work through this issue? I'm a bit lost as to where
to start.
Thanks
Matt
More information about the Python-list
mailing list