Difference between revisions of "D-Bus examples"
Jump to navigation
Jump to search
Line 8: | Line 8: | ||
# -*- encoding: utf-8 -*- |
# -*- encoding: utf-8 -*- |
||
import dbus; |
import dbus, sys, codecs; |
||
sys.stdin = codecs.getwriter('utf-8')(sys.stdin); |
sys.stdin = codecs.getwriter('utf-8')(sys.stdin); |
Revision as of 17:58, 18 December 2007
The simplest
Python
#!/usr/bin/python # coding=utf-8 # -*- encoding: utf-8 -*- import dbus, sys, codecs; sys.stdin = codecs.getwriter('utf-8')(sys.stdin); sys.stdout = codecs.getwriter('utf-8')(sys.stdout); pair_name = 'en-af'; dbus_pair_name = "/" + "_".join(pair_name.split("-")); bus = dbus.SessionBus(); translator = dbus.Interface(bus.get_object("org.apertium.mode", dbus_pair_name), "org.apertium.Mode") input = sys.stdin.read(); print translator.translate({}, input)