On Wed, 2005-03-23 at 18:32 +0100, Nils Philippsen wrote:
On Wed, 2005-03-23 at 11:37 -0500, Ray Strode wrote:
> Hi Nils,
> > import dbus
> >
> > service = 'org.freedesktop.NetworkManager'
> > object_path = "/org/freedesktop/NetworkManager/DhcpOptions"
> > interface = "org.freedesktop.NetworkManager.DhcpOptions"
> >
> > bus = dbus.Bus (dbus.Bus.TYPE_SYSTEM)
> > NWM_service = bus.get_service (service)
> > dhcpOptions = NWM_service.get_object (object_path, interface)
> > --- >8 ---
> >
> > but the resulting dhcpOptions options doesn't have many methods to begin
> > with:
> >
> > dhcpOptions: ['__doc__', '__getattr__', '__init__',
'__module__',
> > '_interface', '_object_path', '_service',
'connect_to_signal']
> The python bindings to dbus don't know about methods ahead of time. You
> just have to call them and see what happens.
> e.g.,
> type = dhcpOptions.getType("NTP Servers")
Hmm, how can I find out what methods a remote object implements -- dir()
obviously doesn't tell me there is getType(), but it worked kind of:
Traceback (most recent call last):
File "./NetworkManagerTinkerer.py", line 18, in ?
print dhcpOptions.getType ('NTP Servers')
File "/usr/lib/python2.3/site-packages/dbus.py", line 208, in __call__
reply_message = self._connection.send_with_reply_and_block(message,
5000)
File "dbus_bindings.pyx", line 557, in
dbus_bindings.Connection.send_with_reply_and_block
dbus_bindings.DBusException: The requested DHCP option does not exist.
You can't unless NetworkManager exports introspection. I want to
implement it in the python bindings when I have time (in which case I
might be able to get dir() to work) but the service must also export the
introspection data. The best way to find out about interfaces is to
read the NetworkManager spec or troll through the code.
--
John (J5) Palmieri
Associate Software Engineer
Desktop Group
Red Hat, Inc.
Blog:
http://martianrock.com