altdesktop / python-dbus-next

🚌 The next great DBus library for Python with asyncio support
https://python-dbus-next.readthedocs.io/en/latest/
MIT License
197 stars 59 forks source link

call_get_managed_object doesn't work #56

Open danaronson opened 4 years ago

danaronson commented 4 years ago

running the following code:

from dbus_next.aio import MessageBus
from dbus_next import BusType, Message
import asyncio

loop = asyncio.get_event_loop()

async def main():
    bus = await MessageBus(bus_type=BusType.SYSTEM).connect()

    introspection = await bus.introspect('org.bluez', '/org/bluez')
    db =  bus.get_proxy_object('org.bluez', '/org/freedesktop/DBus', introspection.default())
    object_manager = db.get_interface('org.freedesktop.DBus.ObjectManager')

    objects = await object_manager.call_get_managed_objects()
    await loop.create_future()

loop.run_until_complete(main())

generates a signature error: dbus_next.errors.DBusError: Method "GetManagedObjects" with signature "" on interface "org.freedesktop.DBus.ObjectManager" doesn't exist

Am I calling this incorrectly?

rafalgajda-silvair commented 4 years ago

Hi,

BlueZ Object Manager is on the root node only. You need to introspect and get proxy object of "/". Try this:

introspection = await bus.introspect('org.bluez', '/') db = bus.get_proxy_object('org.bluez', '/', introspection) object_manager = db.get_interface('org.freedesktop.DBus.ObjectManager')

acrisci commented 4 years ago

Does it advertise the interface and method on the path /org/bluez and say there's no method? That seems like a mistake on the server.