4 python example-service.py &
5 python example-client.py
6 python example-client.py --exit-service
10 from traceback
import print_exc
15 bus
= dbus
.SessionBus()
18 remote_object
= bus
.get_object("com.example.SampleService",
21 # you can either specify the dbus_interface in each call...
22 hello_reply_list
= remote_object
.HelloWorld("Hello from example-client.py!",
23 dbus_interface
= "com.example.SampleInterface")
24 except dbus
.DBusException
:
29 print (hello_reply_list
)
31 # ... or create an Interface wrapper for the remote object
32 iface
= dbus
.Interface(remote_object
, "com.example.SampleInterface")
34 hello_reply_tuple
= iface
.GetTuple()
36 print hello_reply_tuple
38 hello_reply_dict
= iface
.GetDict()
40 print hello_reply_dict
42 # D-Bus exceptions are mapped to Python exceptions
44 iface
.RaiseException()
45 except dbus
.DBusException
, e
:
48 # introspection is automatically supported
49 print remote_object
.Introspect(dbus_interface
="org.freedesktop.DBus.Introspectable")
51 if sys
.argv
[1:] == ['--exit-service']:
54 if __name__
== '__main__':