1
votes

I'm trying to make a script to launch my custom script when my usb stick connected. I found nice python script here but when it calls GetAllProperties() method I get an exception:

ERROR:dbus.connection:Exception in handler for D-Bus signal:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/dbus/connection.py", line 214, in maybe_handle_message
self._handler(*args, **kwargs)
File "./hal-automount", line 31, in device_added
properties = self.udi_to_device(udi).GetAllProperties()
File "/usr/lib/python2.7/site-packages/dbus/proxies.py", line 68, in __call__
return self._proxy_method(*args, **keywords)
File "/usr/lib/python2.7/site-packages/dbus/proxies.py", line 140, in __call__
**keywords)
File "/usr/lib/python2.7/site-packages/dbus/connection.py", line 630, in call_blocking
message, timeout)
DBusException: org.freedesktop.DBus.Error.AccessDenied: Rejected send message, 3 matched rules; type="method_call", sender=":1.39539" (uid=0 pid=9527 comm="python) interface="(unset)" member="getAllProperties" error name="(unset)" requested_reply=0 destination=":1.8" (uid=0 pid=3039 comm="/usr/sbin/hald))

OS: openSuSE 11.4

I didn't work with DBus before, can you give me a hint what's wrong? Thanks.

1

1 Answers

2
votes

Your DBus method call failed due to access policy. It is probably because you called a method without specifying any interface. Looks like a bug in the script you tried to use (DBus methods should always be called via an interface).

Try replacing:

def udi_to_device(self, udi):
    return self.bus.get_object("org.freedesktop.Hal", udi)

With:

def udi_to_device(self, udi):
    obj = self.bus.get_object("org.freedesktop.Hal", udi)
    return dbus.Interface(obj, dbus_interface='org.freedesktop.Hal.Device')

BTW: HAL is now obsolete, you should probably switch to udisks. See http://www.freedesktop.org/wiki/Software/hal