打印 D-Bus 反射树
我该怎么做才能打印出D-Bus上所有可用信息的树状结构呢?
*Bus Name
* Interface
*Method
*Signature
* Interface
*Method
*Signature
*Method
*Signature
*Bus Name
* Interface
*Method
*Signature
3 个回答
1
除了之前提到的D-Feet,还有一个叫gdbus
命令行工具,它可以让你查看特定对象路径的信息,这个对象路径是在一个独特或众所周知的总线名称下的:
$ gdbus introspect --session --dest org.gnome.Contacts --object-path /org/gnome/Contacts
node /org/gnome/Contacts {
interface org.freedesktop.DBus.Properties {
methods:
Get(in s interface_name,
in s property_name,
out v value);
…
signals:
PropertiesChanged(s interface_name,
a{sv} changed_properties,
as invalidated_properties);
properties:
};
…
}
2
你可以使用一些调试工具,比如DFeet,来很清晰地查看通过DBus暴露的所有内容。这些工具会把信息整理得很好,让你一目了然。
0
我创建了一个git仓库,用来演示如何解决这个问题:https://github.com/smokedice/PyDBusTree
这个代码运行得比较慢,因为它没有使用回调函数。如果有人想要改进这个代码,请在这里分享,或者直接提交到这个仓库里。