I believe we should fix this in software-properties. The most flexible way to do this is to use something like
if sys.getfilesystemencoding() == "ascii" and not "LANG" in os.environ:
os.putenv("LANG", "C.UTF-8")
with open("/etc/default/locale") as fobj:
for line in fobj:
line = line.split("#")[0].strip()
if line: key, value = line.split("=", 1) os.putenv(key, value)
os.execv(sys.argv[0], sys.argv)
before running other code in the dbus service. This will take care to setup the system's default locale settings and then re-exec() itself so that Python picks this up (it will not change filesystem encoding otherwise). In case no locale is set in /etc/default/locale, it falls back to LANG=C.UTF-8.
This can be changed to use systemd's localed later on (I do not know if it is currently installed), using:
bus = dbus.SystemBus()
localed = bus.get_object("org.freedesktop.locale1", "/org/freedesktop/locale1")
loc = dbus.Interface(localed, 'org.freedesktop.locale1')
props = dbus.Interface(localed, 'org.freedesktop.DBus.Properties')
for locale in props.Get('org.freedesktop.locale1', 'Locale'):
name, val = locale.split("=", 1)
os.putenv(name, val)
to get the values instead of reading /etc/default/locale.
I believe we should fix this in software- properties. The most flexible way to do this is to use something like
if sys.getfilesyst emencoding( ) == "ascii" and not "LANG" in os.environ: putenv( "LANG", "C.UTF-8") etc/default/ locale" ) as fobj: "#")[0] .strip( )
key, value = line.split("=", 1)
os.putenv( key, value)
os.
with open("/
for line in fobj:
line = line.split(
if line:
before running other code in the dbus service. This will take care to setup the system's default locale settings and then re-exec() itself so that Python picks this up (it will not change filesystem encoding otherwise). In case no locale is set in /etc/default/ locale, it falls back to LANG=C.UTF-8.
This can be changed to use systemd's localed later on (I do not know if it is currently installed), using:
bus = dbus.SystemBus() object( "org.freedeskto p.locale1" , "/org/freedeskt op/locale1" ) localed, 'org.freedeskto p.locale1' ) localed, 'org.freedeskto p.DBus. Properties' )
localed = bus.get_
loc = dbus.Interface(
props = dbus.Interface(
for locale in props.Get( 'org.freedeskto p.locale1' , 'Locale'):
name, val = locale.split("=", 1)
os.putenv(name, val)
to get the values instead of reading /etc/default/ locale.