from tdbus import SimpleDBusConnection, DBUS_BUS_SYSTEM, DBusHandler, signal_handler, DBusError import logging logging.basicConfig(level=logging.DEBUG) # = 'org.freedesktop.Avahi' #PATH_SERVER = '/' #IFACE_SERVER = 'org.freedesktop.Avahi.Server' conn = SimpleDBusConnection(DBUS_BUS_SYSTEM) try: bluez = conn.call_method('/', 'GetManagedObjects', interface='org.freedesktop.DBus.ObjectManager', destination='org.bluez') except DBusError: print "Bluez not available" raise var = bluez.get_args()[0] for p, dev in var.iteritems(): if 'org.bluez.Adapter1' in dev: print "Found adapter {}".format(p) adapter = p # # Get device name #
from __future__ import division, absolute_import from tdbus import SimpleDBusConnection, DBUS_BUS_SYSTEM, DBusHandler, signal_handler, DBusError import logging logging.basicConfig(level=logging.DEBUG) CONN_AVAHI = 'org.freedesktop.Avahi' PATH_SERVER = '/' IFACE_SERVER = 'org.freedesktop.Avahi.Server' conn = SimpleDBusConnection(DBUS_BUS_SYSTEM) try: result = conn.call_method(PATH_SERVER, 'GetVersionString', interface=IFACE_SERVER, destination=CONN_AVAHI) except DBusError: print('Avahi NOT available.') raise print('Avahi is available at %s' % CONN_AVAHI) print('Avahi version: %s' % result.get_args()[0]) print() print('Browsing service types on domain: local') print('Press CTRL-c to exit') print() result = conn.call_method('/', 'ServiceTypeBrowserNew', interface=IFACE_SERVER, destination=CONN_AVAHI, format='iisu', args=(-1, 0, 'local', 0)) browser = result.get_args()[0] print(browser)
#!/usr/bin/env python # # This file is part of python-tdbus. Python-tdbus is free software # available under the terms of the MIT license. See the file "LICENSE" that # was provided together with this source file for the licensing terms. # # Copyright (c) 2012 the python-tdbus authors. See the file "AUTHORS" for a # complete list. # This example shows how to do a blocking method call. We call the bus function # ListNames to list all bus names. from tdbus import SimpleDBusConnection import tdbus conn = SimpleDBusConnection(tdbus.DBUS_BUS_SESSION) print 'Listing all well-known services on the system bus:' print result = conn.call_method(tdbus.DBUS_PATH_DBUS, 'ListNames', tdbus.DBUS_INTERFACE_DBUS, destination=tdbus.DBUS_SERVICE_DBUS) for name in result.get_args()[0]: if not name.startswith(':'): print ' %s' % name print
#!/usr/bin/env python # # This file is part of python-tdbus. Python-tdbus is free software # available under the terms of the MIT license. See the file "LICENSE" that # was provided together with this source file for the licensing terms. # # Copyright (c) 2012 the python-tdbus authors. See the file "AUTHORS" for a # complete list. # This example shows how to do a blocking method call. We call the bus function # ListNames to list all bus names. from tdbus import SimpleDBusConnection import tdbus conn = SimpleDBusConnection(tdbus.DBUS_BUS_SESSION) print 'Listing all well-known services on the system bus:' print result = conn.call_method(tdbus.DBUS_PATH_DBUS, 'ListNames', tdbus.DBUS_INTERFACE_DBUS, destination=tdbus.DBUS_SERVICE_DBUS) for name in result.get_args()[0]: if not name.startswith(':'): print ' %s' % name print
from tdbus import SimpleDBusConnection, DBUS_BUS_SYSTEM, DBusHandler, signal_handler, DBusError import logging logging.basicConfig(level=logging.DEBUG) # = 'org.freedesktop.Avahi' #PATH_SERVER = '/' #IFACE_SERVER = 'org.freedesktop.Avahi.Server' conn = SimpleDBusConnection(DBUS_BUS_SYSTEM) try: bluez = conn.call_method('/', 'GetManagedObjects', interface='org.freedesktop.DBus.ObjectManager', destination='org.bluez') except DBusError: print "Bluez not available" raise var = bluez.get_args()[0] for p, dev in var.iteritems(): if 'org.bluez.Adapter1' in dev: print "Found adapter {}".format(p) adapter = p # # Get device name # bluez = conn.call_method(adapter,