【问题标题】:Print D-Bus introspection tree打印 D-Bus 内省树
【发布时间】:2011-10-13 15:41:56
【问题描述】:

如何打印出 D-Bus 上所有可用信息的树?

*Bus Name
    * Interface
        *Method
            *Signature
    * Interface
        *Method
            *Signature
        *Method
            *Signature
*Bus Name
    * Interface
        *Method
            *Signature

【问题讨论】:

    标签: python dbus


    【解决方案1】:

    您可以使用诸如DFeet 之类的 dbus 调试工具,以良好的结构化方式查看通过 DBus 公开的所有内容。

    【讨论】:

    • D-feet 是一个非常宝贵的工具,我向任何想要全面了解 dbus 内部情况的人推荐它。
    【解决方案2】:

    除了D-Feet(在之前的回答中提到),gdbus command line tool 将允许在给定的唯一或众所周知的总线名称上内省特定的对象路径:

    $ 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:
      };
      …
    }
    

    【讨论】:

      【解决方案3】:

      我创建了一个 git 存储库来演示如何解决这个问题: https://github.com/smokedice/PyDBusTree

      代码相当慢,因为它不使用回调。如果有人想改进代码,请在此处发布,或推送到存储库。

      【讨论】:

      • 你这样做很酷,但如果我们推广一套通用的标准 D-Bus 工具可能会更好。
      • 我个人不同意。 D-Feet 之类的工具无法满足所有需求。我现在发现这个问题模棱两可,因为我认为 print 更多地与代码而不是工具相关联。这可能是由于语言或上下文。
      • Here 的另一种选择:使用asyncio-compatible Python D-Bus 包装器。
      猜你喜欢
      • 2019-10-05
      • 2013-07-03
      • 2011-10-29
      • 2013-04-11
      • 2015-08-17
      • 2010-12-01
      • 1970-01-01
      • 2011-12-08
      • 1970-01-01
      相关资源
      最近更新 更多