RE: Confusing about DBus API specification
- From: Nguyen Canh Toan <Toannc5 viettel com vn>
- To: jklimes redhat com, networkmanager-list gnome org
- Subject: RE: Confusing about DBus API specification
- Date: Thu, 29 Apr 2010 06:08:59 -0700
Dear Jirka,
It's weird. After adjusting my script, it's still error:
[Here is new script:]
#!/usr/bin/env python
import dbus
bus = dbus.SystemBus()
proxy = bus.get_object("org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager")
proxy_prop = dbus.Interface(proxy, "org.freedesktop.DBus.Properties")
manager = dbus.Interface(proxy, "org.freedesktop.NetworkManager")
#proxy_user_setting =
bus.get_object("org.freedesktop.NetworkManagerUserSettings",
"/org/freedesktop/NetworkManagerUserSettings")
proxy_sys_setting =
bus.get_object("org.freedesktop.NetworkManagerSystemSettings",
"/org/freedesktop/NetworkManagerSystemSettings")
settings = dbus.Interface(proxy_sys_setting,
"org.freedesktop.NetworkManagerSettings")
print "========= 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 = settings.ListConnections()
for con in connections:
print "%s" % con
[Here is log:]
toannc vt_ttpm_rd_toannc5:~/Desktop$ ./python_dbus_client
========= active connection
1
1
3
========== list connection
Traceback (most recent call last):
File "./python_dbus_client", line 25, in <module>
connections = settings.ListConnections()
File "/var/lib/python-support/python2.6/dbus/proxies.py", line 68, in
__call__
return self._proxy_method(*args, **keywords)
File "/var/lib/python-support/python2.6/dbus/proxies.py", line 140, in
__call__
**keywords)
File "/var/lib/python-support/python2.6/dbus/connection.py", line 622, in
call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod:
Method "ListConnections" with signature "" on interface
"org.freedesktop.NetworkManagerSettings" doesn't exist
Please help.
-----Original Message-----
From: Jirka Klimes [mailto:jklimes redhat com]
Sent: Wednesday, April 28, 2010 1:18 AM
To: networkmanager-list gnome org
Cc: Nguyen Canh Toan; 'Pablo Martí Gamboa'
Subject: 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]