Re: Restarting connection with dbus



On Wed, 2006-10-25 at 08:34 +0200, Christian G�rote:
> On Wed, 2006-10-25 at 01:08 -0400, Dan Williams wrote:
> > Once you've found it, use the setActiveDevice method call.  Its
> > arguments are:
> > 
> > If wired:
> > 1) DBUS_TYPE_OBJECT_PATH: path of device to activate
> 
> I'm using wired here, it works but I get an exception. This is a bit
> strange. I'm getting the following exception:
> 
> Traceback (most recent call last):
>   File "test.py", line 20, in ?
>     nm.setActiveDevice(op)
>   File "/var/lib/python-support/python2.4/dbus/proxies.py", line 102, in
> __call__
>     reply_message = self._connection.send_with_reply_and_block(message,
> timeout)
>   File "dbus_bindings.pyx", line 455, in
> dbus_bindings.Connection.send_with_reply_and_block
> dbus_bindings.DBusException: NetworkManager::setActiveDevice called with
> invalid arguments.

There are 3 cases where this may happen:

1) first argument is not a DBUS_TYPE_OBJECT_PATH.  Try:

    if props[4] == True:
        nm.setActiveDevice(dbus.ObjectPath(op))

2) You set a wireless network with invalid security information or
essid.  I don't think you do this.

3) An internal error.  What does NM print out to syslog when you execute
your python program?

But this does show a real bug in the NM code, where NM returns an error
reply on success, which is wrong.  I guess the key here, for the moment,
is to try #1, then find out what NM prints out to syslog when you
execute that call.

Dan

> My script looks like this:
> 
> #!/usr/bin/python
> import dbus
> 
> NM_DBUS_SERVICE = "org.freedesktop.NetworkManager"
> NM_DBUS_INTERFACE = "org.freedesktop.NetworkManager"
> NM_DBUS_OPATH = "/org/freedesktop/NetworkManager"
> 
> bus = dbus.SystemBus()
> nm_obj = bus.get_object(NM_DBUS_SERVICE, NM_DBUS_OPATH)
> nm = dbus.Interface(nm_obj, NM_DBUS_INTERFACE)
> 
> devices = nm.getDevices()
> 
> for op in devices:
>     dev_obj = bus.get_object(NM_DBUS_SERVICE, op)
>     dev = dbus.Interface(dev_obj, NM_DBUS_INTERFACE)
>     props = dev.getProperties()
>     
>     if props[4] == True:
>         nm.setActiveDevice(op)
> 




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