File: signal_client2

package info (click to toggle)
txdbus 1.1.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 996 kB
  • sloc: python: 6,658; makefile: 7
file content (37 lines) | stat: -rwxr-xr-x 1,123 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env python

# Manually defining the interface and passing it to getRemoteObject()
# prevents the need for DBus object introspection. The primary
# advantage of this is that the proxy object can be successfully
# created even if the remote object does not actually exist. As signal
# registration is a function of the bus itself and not of the actual
# object, this script may be run prior launching signal_server.
#

from twisted.internet import reactor

from txdbus import client

from txdbus.interface import DBusInterface, Signal

iface = DBusInterface( 'org.example.SignalSender',
                       Signal('tick', 'u')
                       )
            
def onSignal( tickCount ):
    print 'Got tick signal: ', tickCount

def onErr(err):
    print 'Error: ', err.getErrorMessage()



d = client.connect(reactor)

d.addCallback( lambda cli: cli.getRemoteObject( 'org.example',
                                                '/Signaller',
                                                iface) )
d.addCallback( lambda ro: ro.notifyOnSignal( 'tick', onSignal ) ) 
d.addErrback( onErr )

reactor.run()