[PATCH] Fix Python example in documentation

Thomas Petazzoni thomas.petazzoni at enix.org
Sun Dec 17 03:51:40 PST 2006


The Python example provided in the documentation no longer works with recent
version of DBus. The get_service() method of the bus object no longer exists,
and has been replaced by get_object(). Moreover, the prototype of the callback
also changed.

This updated version works on my Debian Unstable, with HAL 0.5.1, DBus 0.94 and
Python-DBus 0.71.
---
 doc/spec/example-manager.py |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/doc/spec/example-manager.py b/doc/spec/example-manager.py
index 753bf8a..861dc1b 100755
--- a/doc/spec/example-manager.py
+++ b/doc/spec/example-manager.py
@@ -2,20 +2,18 @@
  
 import gtk
 import dbus
+import dbus.glib
 
-def device_added(interface, signal_name, service, path, message):
-    [udi] = message.get_args_list ()
+def device_added(udi):
     print 'Device %s was added'%udi
 
-def device_removed(interface, signal_name, service, path, message):
-    [udi] = message.get_args_list ()
+def device_removed(udi):
     print 'Device %s was removed'%udi
 
  
 bus = dbus.Bus (dbus.Bus.TYPE_SYSTEM)
-hal_service = bus.get_service ('org.freedesktop.Hal')
-hal_manager = hal_service.get_object ('/org/freedesktop/Hal/Manager',
-				      'org.freedesktop.Hal.Manager')
+hal_manager = bus.get_object ('org.freedesktop.Hal',
+                              '/org/freedesktop/Hal/Manager')
 
 devices = hal_manager.GetAllDevices ()
 for d in devices:
-- 
Thomas Petazzoni



More information about the hal mailing list