Re: Restarting connection with dbus



On Tue, 2006-10-24 at 16:01 +0200, Christian G�rote:
> Can you give me some advice on how to use the dbus-send command? I don't
> get howto pass the correct device to it...

The fourth parameter of the getProperties call on a device is the
"active" property.  Use that, the order of parameters in the reply will
never change for 0.6.x.

Have fun with shell!  Or, you could use Python and make this a _lot_
easier.

Dan


[dcbw localhost ~]$ dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.NetworkManager.getDevices
method return sender=:1.5 -> dest=:1.67
   array [
      object path "/org/freedesktop/NetworkManager/Devices/eth0"
      object path "/org/freedesktop/NetworkManager/Devices/eth1"
   ]

[dcbw localhost ~]$ dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager /org/freedesktop/NetworkManager/Devices/eth1 org.freedesktop.NetworkManager.getProperties
method return sender=:1.5 -> dest=:1.68
   object path "/org/freedesktop/NetworkManager/Devices/eth1"
   string "eth1"
   uint32 2
   string "/org/freedesktop/Hal/devices/net_00_xx_xx_xx_xx_xx"
   boolean true    <<<<<<< ----- 'active': true/false
   uint32 7
   string "xx.xx.xx.85"
   string "255.255.254.0"
   string "xx.xx.xx.255"
   string "00:xx:xx:xx:xx:xx"
   string "xx.xx.xx.1"
   string "xx.xx.x.138"
   string "xx.xx.x.171"
   int32 0
   int32 80
   boolean true
   int32 48
   uint32 5
   uint32 61647
   string "/org/freedesktop/NetworkManager/Devices/eth1/Networks/foobar"
   array [
      string "/org/freedesktop/NetworkManager/Devices/eth1/Networks/foobar"
      string "/org/freedesktop/NetworkManager/Devices/eth1/Networks/baz"
      string "/org/freedesktop/NetworkManager/Devices/eth1/Networks/blah"
      string "/org/freedesktop/NetworkManager/Devices/eth1/Networks/bork"
   ]

In python:


#!/usr/bin/python

import dbus
import sys, os
import time

NM_DBUS_SERVICE = "org.freedesktop.NetworkManager"
NM_DBUS_INTERFACE = "org.freedesktop.NetworkManager"
NM_DBUS_OPATH = "/org/freedesktop/NetworkManager"

def main():
	bus = dbus.SystemBus()
	nm_obj = bus.get_object(NM_DBUS_SERVICE, NM_DBUS_OPATH)
	nm = dbus.Interface(nm_obj, NM_DBUS_INTERFACE)

	# See if wpa_supplicant already knows about this interface
	devices = nm.getDevices()
	print devices
	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:
			print "Device %s is the active device" % op

if __name__ == "__main__":
	main()





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