【问题标题】:How to display the interfaces of a particular dbus bus name (/org/bluez) in python?如何在python中显示特定dbus总线名称(/org/bluez)的接口?
【发布时间】:2015-07-26 06:01:39
【问题描述】:

我想知道 bluez dbus 总线中有哪些可用的对象和接口。我编写了一个简单的 python 脚本来列出 dbus 会话中的所有总线名称。

import dbus
for service in dbus.SystemBus().list_names():
    print(service)

但是,我只对 bluez /org/bluez 内部的接口感兴趣。如何编写 python 脚本来列出 /org/bluez 中的接口?

我使用的是 Ubuntu 14.04 和 python 2.7

【问题讨论】:

    标签: python ubuntu ubuntu-14.04 dbus bluez


    【解决方案1】:

    你可以试试这个:

    system_bus = dbus.SystemBus()
    objectManager = system_bus.get_object('org.bluez', '/')
    om_iface = dbus.Interface(objectManager, 'org.freedesktop.DBus.ObjectManager')
    
    ifacelist = om_iface.GetManagedObjects()
    

    其中ifacelist 是 {ObjectPath, Dictof{String, Variant}}} 的字典

    【讨论】:

    猜你喜欢
    • 2012-09-02
    • 1970-01-01
    • 1970-01-01
    • 2012-04-05
    • 2023-03-22
    • 2011-03-22
    • 2017-09-12
    • 2020-11-07
    • 1970-01-01
    相关资源
    最近更新 更多