RE: Confusing about DBus API specification



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")

proxy_prop = dbus.Interface(proxy, "org.freedesktop.DBus.Properties")

manager = dbus.Interface(proxy, "org.freedesktop.NetworkManager")

settings = dbus.Interface(proxy, "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.NetworkManagerSettings")

for con in connections:

            print "%s" % con

 

 

It till say:

toannc vt_ttpm_rd_toannc5:~/Desktop$ ./python_dbus_client

1

1

3

xxxx /org/freedesktop/NetworkManager/ActiveConnection/1

list connection

Traceback (most recent call last):

  File "./python_dbus_client", line 21, in <module>

    connections = manager.ListConnections(dbus_interface="org.freedesktop.NetworkManagerSettings")

  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.


From: Pablo Martí Gamboa [mailto:pmarti warp es]
Sent: Tuesday, April 27, 2010 11:41 PM
To: Nguyen Canh Toan
Cc: networkmanager-list gnome org
Subject: Re: Confusing about DBus API specification

 

 

2010/4/29 Nguyen Canh Toan <Toannc5 viettel com vn>

Hi all,

 

After reading DBus API http://projects.gnome.org/NetworkManager/developers/spec-07.html#org.freedesktop.NetworkManager

I try to list all connection setting by below interface specification

 

org.freedesktop.NetworkManagerSettings

The NetworkManagerSettings interface is provided by the service which provides connections to NetworkManager.

Methods:

ListConnections ( ) ao

List the connections stored by this Settings object.

Returns

 

connections - ao

    List of connections.

 

Signals:

NewConnection ( o: connection )

Emitted when a new connection has been configured.

Parameters

 

connection - o

    Object path of the new connection.

 

Interface has no properties.

 

 

Without success. DBus service say:

 

Traceback (most recent call last):

  File "./python_dbus_client", line 21, in <module>

    connections = manager.ListConnections()

  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.NetworkManager" doesn't exist


That's because ListConnections is a method of the "
org.freedesktop.NetworkManagerSettings" interface ;)

Try executing your method as:

connections = manager.ListConnections(dbus_interface="org.freedesktop.NetworkManagerSettings")


Best regards,

--
Pablo Martí // http://minimoesfuerzo.org
python -c "print '706d617267616d40676d61696c2e636f6d'.decode('hex')"



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