mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-12-05 01:54:22 +08:00
ee56337e41
This patch makes the python tests source-compatible with python 3, while leaving the interpreter at python 2 for now. The tradeoff is that this source is no longer compatible with python versions < 2.6, and requires gobject-introspection for the glib-based tests.
41 lines
913 B
Python
Executable File
41 lines
913 B
Python
Executable File
#!/usr/bin/python
|
|
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
|
|
|
from gi.repository import GObject
|
|
|
|
import dbus
|
|
import dbus.mainloop.glib
|
|
|
|
def adapter_added(path):
|
|
print("Adapter with path %s added" % (path))
|
|
|
|
def adapter_removed(path):
|
|
print("Adapter with path %s removed" % (path))
|
|
|
|
def default_changed(path):
|
|
print("Default adapter is now at path %s" % (path))
|
|
|
|
if __name__ == "__main__":
|
|
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
|
|
|
bus = dbus.SystemBus()
|
|
|
|
manager = dbus.Interface(bus.get_object('org.bluez', '/'),
|
|
'org.bluez.Manager')
|
|
|
|
manager.connect_to_signal("AdapterAdded", adapter_added)
|
|
|
|
manager.connect_to_signal("AdapterRemoved", adapter_removed)
|
|
|
|
manager.connect_to_signal("DefaultAdapterChanged", default_changed)
|
|
|
|
try:
|
|
path = manager.DefaultAdapter()
|
|
default_changed(path)
|
|
except:
|
|
pass
|
|
|
|
mainloop = GObject.MainLoop()
|
|
mainloop.run()
|