1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#!/usr/bin/env python
from twisted.internet import reactor, defer
from txdbus import client, error
@defer.inlineCallbacks
def main():
try:
cli = yield client.connect(reactor)
robj = yield cli.getRemoteObject( 'org.example', '/MyObjPath' )
# Use the standard org.freedesktop.DBus.Properties.Get function to
# obtain the value of 'foo'. Only one interface on the remote object
# declares 'foo' so the interface name (the second function argument)
# may be omitted.
foo = yield robj.callRemote('Get', '', 'foo')
# prints "bar"
print foo
yield robj.callRemote('Set', '', 'foo', 'baz')
foo = yield robj.callRemote('Get', '', 'foo')
# prints "baz"
print foo
except error.DBusException, e:
print 'DBus Error:', e
reactor.stop()
reactor.callWhenRunning(main)
reactor.run()
|