-
Notifications
You must be signed in to change notification settings - Fork 0
/
pretty_dbus.py
60 lines (52 loc) · 1.19 KB
/
pretty_dbus.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from twisted.internet import reactor, defer
from txdbus import error, client
@defer.inlineCallbacks
def call_method(
bus,
iface,
path,
method,
cb,
*args):
try:
cli = yield client.connect(reactor, bus)
robj = yield cli.getRemoteObject(
iface.name,
path,
iface)
r = yield robj.callRemote(method, *args)
cb(r)
except error.DBusException, e:
print 'DBus Error:', e
@defer.inlineCallbacks
def activate_notification(
bus,
iface,
path,
signal,
cb):
try:
cli = yield client.connect(reactor, bus)
robj = yield cli.getRemoteObject(
iface.name,
path,
iface)
robj.notifyOnSignal(signal, cb)
except error.DBusException, e:
print 'DBus Error:', e
@defer.inlineCallbacks
def update_state(
bus,
iface,
path,
property,
cb):
try:
cli = yield client.connect(reactor, bus)
robj = yield cli.getRemoteObject(
iface,
path)
r = yield robj.callRemote('Get', '', property)
cb(r)
except error.DBusException, e:
print 'DBus Error:', e