Пример #1
0
 def setUpClass(cls):
     super(TestMessageASimple, cls).setUpClass()
     handler = EchoHandlerInherit()
     conn = SimpleDBusConnection(DBUS_BUS_SESSION)
     conn.add_handler(handler)
     cls.server_name = conn.get_unique_name()
     cls.server = Thread(target=cls.dbus_server, args=(conn,))
     cls.server.start()
     cls.client = SimpleDBusConnection(DBUS_BUS_SESSION)
Пример #2
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()
Пример #3
0
                </method>
        </interface>
</node>"""

        self.set_response("s", [xml])

EXAMPLE_NAME = "com.example.Hello"

conn = SimpleDBusConnection(DBUS_BUS_SESSION)
conn.register_name(EXAMPLE_NAME)
handler = MethodHandler()
conn.add_handler(handler)

print('Exposing a hello world method on the bus.')
print('In another terminal, issue:')
print()
print('  $ dbus-send --session --print-reply --type=method_call --dest={} /com/example/TDBus com.example.Hello.Hello'.format(conn.get_unique_name()))
print()
print('or')
print()
print('  $ dbus-send --session --print-reply --type=method_call --dest={} /com/example/TDBus com.example.Hello.Hello'.format(EXAMPLE_NAME))
print()
print()
print('or')
print()
print('  $ dbus-send --session --print-reply --type=method_call --dest={} /com/example/TDBus com.example.Hello.HelloException'.format(EXAMPLE_NAME))
print('Press CTRL-c to exit.')
print()

conn.dispatch()
Пример #4
0
                        <arg type="s" name="hello_world" direction="out" />
                </method>
        </interface>
</node>"""

        self.set_response("s", [xml])

EXAMPLE_NAME = "com.example.Hello"

conn = SimpleDBusConnection(DBUS_BUS_SESSION)
conn.register_name(EXAMPLE_NAME)
handler = MethodHandler()
conn.add_handler(handler)

print 'Exposing a hello world method on the bus.'
print 'In another terminal, issue:'
print
print '  $ dbus-send --session --print-reply --type=method_call --dest={} /com/example/TDBus com.example.Hello.Hello'.format(conn.get_unique_name())
print
print 'or'
print
print '  $ dbus-send --session --print-reply --type=method_call --dest={} /com/example/TDBus com.example.Hello.Hello'.format(EXAMPLE_NAME)
print
print 'or'
print
print '  $ dbus-send --session --print-reply --type=method_call --dest={} /com/example/TDBus com.example.Hello.HelloException'.format(EXAMPLE_NAME)
print
print 'Press CTRL-c to exit.'
print
conn.dispatch()
Пример #5
0
 def test_get_unique_name(self):
     conn = SimpleDBusConnection(DBUS_BUS_SESSION)
     name = conn.get_unique_name()
     assert name.startswith(':')
     conn.close()
Пример #6
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()
Пример #7
0
        self.set_response("s", [xml])


EXAMPLE_NAME = "com.example.Hello"

conn = SimpleDBusConnection(DBUS_BUS_SESSION)
conn.register_name(EXAMPLE_NAME)
handler = MethodHandler()
conn.add_handler(handler)

print "Exposing a hello world method on the bus."
print "In another terminal, issue:"
print
print "  $ dbus-send --session --print-reply --type=method_call --dest={} /com/example/TDBus com.example.Hello.Hello".format(
    conn.get_unique_name()
)
print
print "or"
print
print "  $ dbus-send --session --print-reply --type=method_call --dest={} /com/example/TDBus com.example.Hello.Hello".format(
    EXAMPLE_NAME
)
print
print "or"
print
print "  $ dbus-send --session --print-reply --type=method_call --dest={} /com/example/TDBus com.example.Hello.HelloException".format(
    EXAMPLE_NAME
)
print
print "Press CTRL-c to exit."