【问题标题】:DBus object errorDBus 对象错误
【发布时间】:2011-12-18 14:31:40
【问题描述】:

我正在尝试制作一个脚本,以便在我的 USB 记忆棒连接时启动我的自定义脚本。 我找到了不错的 python 脚本 here 但是当它调用 GetAllProperties() 方法时我得到一个异常:

错误:dbus.connection:D-Bus 信号处理程序中的异常:
Traceback (最近一次通话最后一次):
文件 “/usr/lib/python2.7/site-packages/dbus/connection.py”,第 214 行,在 也许_handle_message
self._handler(*args, **kwargs)
文件“./hal-automount”,第 31 行,在 device_added
属性 = self.udi_to_device(udi).GetAllProperties()
文件“/usr/lib/python2.7/site-packages/dbus/proxies.py”,第 68 行,在 __call__
return self._proxy_method(*args, **keywords)
文件“/usr/lib/python2.7/site-packages/dbus/proxies.py”,第 140 行,在 __call__
**关键字)
文件“/usr/lib/python2.7/site-packages/dbus/connection.py”,第 630 行,在 呼叫阻塞
消息,超时)
DBusException:org.freedesktop.DBus.Error.AccessDenied:拒绝发送消息,3 匹配规则; type="method_call", sender=":1.39539" (uid=0 pid=9527 comm="python) interface="(unset)" member="getAllProperties" 错误 name="(unset)" requested_reply=0 destination=":1.8" (uid=0 pid=3039 comm="/usr/sbin/hald))

操作系统:openSuSE 11.4

我以前没有使用过 DBus,你能告诉我有什么问题吗? 谢谢。

【问题讨论】:

    标签: python linux dbus opensuse


    【解决方案1】:

    由于访问策略,您的 DBus 方法调用失败。这可能是因为您调用了一个方法而没有指定任何接口。看起来您尝试使用的脚本中存在错误(应始终通过接口调用 DBus 方法)。

    尝试替换:

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

    与:

    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')
    

    顺便说一句:HAL 现已过时,您可能应该切换到 udisk。见http://www.freedesktop.org/wiki/Software/hal

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-28
    • 2013-02-21
    • 2019-10-14
    • 2015-11-14
    • 1970-01-01
    • 2014-02-07
    • 2011-09-23
    相关资源
    最近更新 更多