Re: problems with accessing nm properties through dbus



On Wed, Jan 21, 2009 at 04:29:19AM -0800, I M wrote:
> So i did something like:
> Service:       org.freedesktop.NetworkManager
> object path:/org/freedesktop/NetworkManager
> Interface:     org.freedesktop.DBus.Properties
> Method:      Get,GetAll,Set
> 
> and they all fail with dbus error messages like:
> org.freedesktop.DBus.Error.UnknownMethod: Method "Get" with signature "" on interface "org.freedesktop.DBus.Properties" doesn't exist
> 
> So how come DBus spits UnknownMethod?
> Maybe i am doing it wrong :)) and i am not using the right way to expose nm's properties through dbus and help from you guys might be really appreciated.

The DBus error messages could be certainly improved, I think.

Here is code that works for me (extracted from
http://repo.or.cz/w/cnetworkmanager.git ).

-- 
Martin Vidner, YaST developer
http://en.opensuse.org/User:Mvidner

Kuracke oddeleni v restauraci je jako fekalni oddeleni v bazenu
#! /usr/bin/python
# sample code to get NM properties
try:
    import dbus
except:
    print "Install dbus-1-python.rpm or or python-dbus.rpm or python-dbus.deb"

bus = dbus.SystemBus()
nmp = '/org/freedesktop/NetworkManager'
NMC = 'org.freedesktop.NetworkManager'
NMI = NMC
PI = 'org.freedesktop.DBus.Properties'

nmo = bus.get_object(NMC, nmp)
nmi = dbus.Interface(nmo, NMI)
nmpi = dbus.Interface(nmo, PI)
try:
    print "Wifi enabled:", nmpi.Get(NMI, "WirelessEnabled")
    print "Wifi HW enabled:", nmpi.Get(NMI, "WirelessHardwareEnabled")
except dbus.exceptions.DBusException, e:
    print e
    print "NetworkManager is not running"


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