Exemple #1
0
 def setUpClass(cls):
     super(TestMessageDecorated, cls).setUpClass()
     handler = EchoHandlerDecorator()
     conn = GEventDBusConnection(DBUS_BUS_SESSION)
     conn.add_handler(handler)
     cls.server_name = conn.get_unique_name()
     cls.client = GEventDBusConnection(DBUS_BUS_SESSION)
Exemple #2
0
 def setUpClass(cls):
     super(TestMessageName, cls).setUpClass()
     cls.server_name = "org.tdbus.Test"
     handler = EchoHandlerInherit()
     conn = GEventDBusConnection(DBUS_BUS_SESSION)
     conn.register_name(cls.server_name)
     conn.add_handler(handler)
     cls.client = GEventDBusConnection(DBUS_BUS_SESSION)
Exemple #3
0
    def setUpClass(cls):
        super(TestMessageSignalMatched, cls).setUpClass()
        cls.server_name = "org.tdbus.Test"

        def signal_handler_f(message):
            logging.getLogger('tdbus').info(message)
            cls.last_message = message

        handler = EchoHandlerInherit(signal_handler_f)
        conn = GEventDBusConnection(DBUS_BUS_SESSION)
        conn.add_handler(handler)
        conn.subscribe_to_signals()
        cls.client = GEventDBusConnection(DBUS_BUS_SESSION)
Exemple #4
0
 def __init__(self):
     """Constructor."""
     super(AvahiLocationSource, self).__init__()
     self.connection = GEventDBusConnection(DBUS_BUS_SYSTEM)
     handler = AvahiHandler(self._avahi_event)
     self.connection.add_handler(handler)
     self.logger = logging.getLogger(__name__)
     self.callbacks = []
     self.neighbors = {}
     self.addresses = {}
     self._browser = None
     self._entry_groups = {}
Exemple #5
0
            xml = """<?xml version="1.0" encoding="UTF-8"?>
    <node name="com/example/TDBus">
            <interface name="com.example.Hello">
                    <method name="HelloMethod">
                            <arg type="s" name="somestring" direction="in" />
                            <arg type="i" name="someint" direction="in" />
                            <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
                    </method>
                    <!-- Add more methods/signals if you want -->
            </interface>
    </node>"""

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


conn = GEventDBusConnection(DBUS_BUS_SESSION)
handler = GEventHandler()
conn.add_handler(handler)

print('Listening for signals, with gevent dispatcher.')
print('In another terminal, issue:')
print()
print(
    '  $ dbus-send --session --type=signal --dest={} /com/example/TDBus com.example.Hello.Hello'
    .format(conn.get_unique_name()))
print(
    '  $ dbus-send --session --print-reply --type=method_call --dest={} /com/example/TDBus com.example.Hello.HelloMethod'
    .format(conn.get_unique_name()))
print()
print('Press CTRL-c to exit.')
print()
Exemple #6
0
 def test_get_unique_name(self):
     conn = GEventDBusConnection(DBUS_BUS_SESSION)
     name = conn.get_unique_name()
     assert name.startswith(':')
     conn.close()
Exemple #7
0
 def test_connection_multiple_open(self):
     conn = GEventDBusConnection(DBUS_BUS_SESSION)
     conn.close()
     conn.open(DBUS_BUS_SESSION)
     conn.close()
Exemple #8
0
 def test_connection_init(self):
     conn = GEventDBusConnection(DBUS_BUS_SESSION)
     conn.close()