亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從 dbus 對象打印結果

從 dbus 對象打印結果

臨摹微笑 2022-01-05 19:36:33
我想從 dbus 打印結果。在命令行中我運行這個:busctl introspect org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.DBus.Properties我得到了一些結果。我嘗試使用 python 但沒有運氣打印結果。import dbusbus = dbus.SystemBus()eth0 = bus.get_object('org.freedesktop.NetworkManager',                      '/org/freedesktop/NetworkManager/Devices/eth0')eth0_dev_iface = dbus.Interface(eth0,    dbus_interface='org.freedesktop.NetworkManager.Devices')props = eth0_dev_iface.getProperties()但我收到此錯誤:dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: 沒有這樣的方法“getProperties”
查看完整描述

1 回答

?
翻閱古今

TA貢獻1780條經驗 獲得超5個贊

這非常令人惱火。界面有點瘋狂。


試試這個:


import dbus

bus = dbus.SystemBus()

eth0 = bus.get_object('org.freedesktop.NetworkManager',

                      '/org/freedesktop/NetworkManager/Devices/eth0')


# Here's where we change things

eth0_dev_iface = dbus.Interface(eth0,

    dbus_interface='org.freedesktop.DBus.Properties')

eth0_dev_iface.GetAll('org.freedesktop.NetworkManager.Devices')

現在為什么文檔示例代碼沒有按照文檔工作?這是一個很好的問題......但是上面的代碼工作正常。


查看完整回答
反對 回復 2022-01-05
  • 1 回答
  • 0 關注
  • 290 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號