DBUS/HAL Manager Interface Help

Jens Jorgensen jorgensen at lowtechsolutions.net
Tue Nov 4 20:03:40 PST 2008


> Can someone explain to me why this sample code does not work? I am trying
> to test if a device exists.
>
> ---------------- dbus_test.py --------------------------
> import dbus
>
> bus = dbus.SystemBus()
> proxy = bus.get_object( 'org.freedesktop.Hal',
> '/org/freedesktop/Hal/Manager' )
> manager =  dbus.Interface( proxy, 'org.freedesktop.Hal.Manager' )
>
> some_dev = manager.GetAllDevices()[0]
> print "Calling DeviceExists on '%s'" % some_dev
> print manager.DeviceExists( some_dev )
>
> ------------------- output ------------------------------
> $ python dbus_test.py
> Calling DeviceExists on '/org/freedesktop/Hal/devices/platform_bluetooth'
> Traceback (most recent call last):
>   File "dbus_test.py", line 9, in <module>
>     print manager.DeviceExists( some_dev )
>   File "/var/lib/python-support/python2.5/dbus/proxies.py", line 140, in
> __call__
>     **keywords)
>   File "/var/lib/python-support/python2.5/dbus/connection.py", line 607, in
> call_blocking
>     message, timeout)
> dbus.exceptions.DBusException: org.freedesktop.Hal.SyntaxError: There is a
> syntax error in the invocation of the method Manager.DeviceExists

Well, I don't know if anyone ever replied to you on the list, I for one wish 
they had! Would've saved me some time. In any case it turns out that this was 
because the Hal.Manager introspection was reporting that the signature for 
DeviceExists's argument was "o" but the actual code expected the parameter to 
instead be "s". The fix for this (making the signature match what the code 
expects) was committed to hal's git 2008-08-25. Of course that means it'll be 
a while before this shows up in your distro I'm guessing. In the mean time 
the following code works:

import dbus

sb = dbus.SystemBus()
o = 
dbus.Interface(sb.get_object('org.freedesktop.Hal', '/org/freedesktop/Hal/Manager', 
introspect=False), 'org.freedesktop.Hal.Manager')
print 
o.DeviceExists('/org/freedesktop/Hal/devices/usb_device_6e6_f210_noserial_if3_hiddev')

-- 
Jens Jorgensen


This e-mail and its attachments are intended only for the individual or entity to whom it is addressed and may contain information that is confidential, privileged, inside information, or subject to other restrictions on use or disclosure. Any unauthorized use, dissemination or copying of this transmission or the information in it is prohibited and may be unlawful. If you have received this transmission in error, please notify the sender immediately by return e-mail, and permanently delete or destroy this e-mail, any attachments, and all copies (digital or paper). Unless expressly stated in this e-mail, nothing in this message should be construed as a digital or electronic signature.


More information about the hal mailing list