Re: Confusing about DBus API specification



ListConnections() method is not provided by /org/freedesktop/NetworkManager 
service, rather /org/freedesktop/NetworkManagerSystemSettings and 
org.freedesktop.NetworkManagerUserSettings.
See inline comments to adapt your script.

On Thursday 29 of April 2010 11:05:13 Nguyen Canh Toan wrote:
> Thank Pablo for quickly reply,
> 
> 
> 
> I think I am misunderstanding something. I have rewritten my script as your
> advice but I still error. Here is my short script:
> 
> 
> 
> 
> 
> #!/usr/bin/env python
> 
> 
> 
> import dbus
> 
> bus = dbus.SystemBus()
> 
> 
> 
> proxy = bus.get_object("org.freedesktop.NetworkManager",
> "/org/freedesktop/NetworkManager")
> 
add here
proxy1 = bus.get_object("org.freedesktop.NetworkManagerUserSettings", 
"/org/freedesktop/NetworkManagerSettings")
for listing user connections or
proxy1 = bus.get_object("org.freedesktop.NetworkManagerSystemSettings", 
"/org/freedesktop/NetworkManagerSettings")
for listing system-wide connections.

> proxy_prop = dbus.Interface(proxy, "org.freedesktop.DBus.Properties")
> 
> manager = dbus.Interface(proxy, "org.freedesktop.NetworkManager")
> 
> settings = dbus.Interface(proxy, "org.freedesktop.NetworkManagerSettings")
You need to use proxy1 here instead of proxy.
settings = dbus.Interface(proxy1, "org.freedesktop.NetworkManagerSettings")

> 
> 
> 
> #active connection
> 
> connections = proxy_prop.Get("org.freedesktop.NetworkManager",
> "ActiveConnections")
> 
> print "%d" % proxy_prop.Get("org.freedesktop.NetworkManager",
> "WirelessHardwareEnabled")
> 
> print "%d" % proxy_prop.Get("org.freedesktop.NetworkManager",
> "WirelessEnabled")
> 
> print "%d" % proxy_prop.Get("org.freedesktop.NetworkManager", "State")
> 
> for con in connections:
> 
>             print "xxxx %s" % con
> 
>             con_obj = bus.get_object("org.freedesktop.NetworkManager", con)
> 
> 
> 
> print "list connection "
> 
> connections =
> manager.ListConnections(dbus_interface="org.freedesktop.NetworkManagerSetti
> n gs")
this line should look like this:
connections = settings.ListConnections()

i.e. using settings interface and no arguments to ListConnections()

> 
> for con in connections:
> 
>             print "%s" % con
> 
> 

Jirka


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]