Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python中通过DBus获取VPN连接状态_Python_Linux_Dbus - Fatal编程技术网

在python中通过DBus获取VPN连接状态

在python中通过DBus获取VPN连接状态,python,linux,dbus,Python,Linux,Dbus,我试图通过Python中的DBus获取VPN连接的状态。 这是我的密码: name="testVPN" proxy = dbus.SystemBus().get_object('org.freedesktop.NetworkManagerUserSettings', '/org/freedesktop/NetworkManagerSettings') iface = dbus.Interface(proxy, 'org.freedesktop.NetworkManagerSettings') c

我试图通过Python中的DBus获取VPN连接的状态。 这是我的密码:

name="testVPN"
proxy = dbus.SystemBus().get_object('org.freedesktop.NetworkManagerUserSettings', '/org/freedesktop/NetworkManagerSettings')
iface = dbus.Interface(proxy, 'org.freedesktop.NetworkManagerSettings')
connections = iface.ListConnections()
for connection in connections:
    proxy = dbus.SystemBus().get_object('org.freedesktop.NetworkManagerUserSettings', connection)
    iface = dbus.Interface(proxy, 'org.freedesktop.NetworkManagerSettings.Connection')
    con_settings = iface.GetSettings()['connection']
    if con_settings['type'] == 'vpn' and con_settings['id'] == name:
        state=dbus.Interface(proxy, 'org.freedesktop.DBus.Properties').Get('org.freedesktop.NetworkManager.VPN.Connection', 'VpnState')
这将正确查找VPN连接,但在最后一行中,当尝试获取VpnState属性时,会引发此异常:

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied: Rejected send message, 1 matched rules; type="method_call", sender=":1.169" (uid=0 pid=20580 comm="python) interface="org.freedesktop.DBus.Properties" member="Get" error name="(unset)" requested_reply=0 destination=":1.36" (uid=1000 pid=3457 comm="nm-applet))
有什么问题

谢谢