2011-10-13 52 views
0

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

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

回答

0

我已經創建了一個Git倉庫來演示如何來解決這個問題: https://github.com/smokedice/PyDBusTree

的代碼是相當慢的,因爲它不使用回調。如果有人想改進代碼,請將其發佈到此處,或者推送到存儲庫。

+0

這很酷,你做了,但是如果我們推廣一套通用的標準D-Bus工具,可能會更好。 –

+0

我個人不同意。像D-Feet這樣的工具不會涵蓋所有需求。我現在發現這個問題不明確,因爲我認爲'print'更多地與代碼而不是工具相關聯。這可能是由於語言或上下文。 – smokedice

+0

[這裏](https://github.com/ldo/dbussy_examples/blob/master/introspect_all)的另一個選項:使用['asyncio'-compatible](https://github.com/ldo/dbussy) Python的D-Bus包裝。 –

2

您可以使用dbus調試工具(如DFeet)以良好的結構化方式查看DBus上暴露的所有內容。

+0

D尺是一個非常寶貴的工具,我推薦給任何人試圖獲得dbus內部發生的事情的整體畫面。 – Zimano

0

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