我正在阅读 dbus-python 教程。
https://dbus.freedesktop.org/doc/dbus-python/tutorial.html#interfaces-and-methods
提供的示例对我不起作用。我用 1 替换了 eth0 ,但它仍然引发错误。
import dbus
bus = 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.AccessDenied: Rejected send
message, 2 matched rules; type="method_call", sender=":1.4371" (uid=78105 pid=8231
comm="python3 " label="unconfined") interface="org.freedesktop.NetworkManager.Devices"
member="getProperties" error name="(unset)" requested_reply="0" destination=":1.11"
(uid=0 pid=1122 comm="/usr/sbin/NetworkManager --no-daemon " label="unconfined")
还有下面这个声明
例如,表示网络接口的每个 NetworkManager 对象都实现了 interface org.freedesktop.NetworkManager.Devices
,该接口具有类似 getProperties
.
我用d-feet检查过,不知何故网络管理器的接口没有getProperties
方法