Exemplo n.º 1
0
from tdbus import DBusHandler, signal_handler, SimpleDBusConnection, DBUS_BUS_SESSION

class SignalHandler(DBusHandler):

    @signal_handler()
    def Signal(self, message):
         print 'signal received: %s, args = %s' % (message.get_member(), repr(message.get_args()))


conn = SimpleDBusConnection(DBUS_BUS_SESSION)
handler = SignalHandler()

conn.add_handler(handler)

# the next method needs to be called explicitly after all add_handler calls
conn.subscribe_to_signals()


print 'Listening for signals. Press CTRL-c to quit.'
print 'In another terminal, issue:'
print
print '  $ dbus-send --session --type=signal --dest={} /com/example/TDBus com.example.Hello.Signal'.format(conn.get_unique_name())
print
print 'or (only when subscribe_to_signals() is used)'
print '  $ dbus-send --session --type=signal /com/example/TDBus com.example.Hello.Signal'
print
print 'Press CTRL-c to exit.'
print

conn.dispatch()
Exemplo n.º 2
0

class SignalHandler(DBusHandler):
    @signal_handler()
    def Signal(self, message):
        print 'signal received: %s, args = %s' % (message.get_member(),
                                                  repr(message.get_args()))


conn = SimpleDBusConnection(DBUS_BUS_SESSION)
handler = SignalHandler()

conn.add_handler(handler)

# the next method needs to be called explicitly after all add_handler calls
conn.subscribe_to_signals()

print 'Listening for signals. Press CTRL-c to quit.'
print 'In another terminal, issue:'
print
print '  $ dbus-send --session --type=signal --dest={} /com/example/TDBus com.example.Hello.Signal'.format(
    conn.get_unique_name())
print
print 'or (only when subscribe_to_signals() is used)'
print '  $ dbus-send --session --type=signal /com/example/TDBus com.example.Hello.Signal'
print
print 'Press CTRL-c to exit.'
print

conn.dispatch()