python dbus如何获取对象值

时间:2017-09-27 11:56:41

标签: python dbus

import dbus

session_bus = dbus.SessionBus()
print(session_bus)

serviceName = "com.qcom.QCAT"
service = session_bus.get_object(
    serviceName, # Bus name
    "/Applications/QCAT/QCAT/bin/QCAT", # Object path
)

print(service)
appVersion = service.get_dbus_method('AppVersion')
print(appVersion)

我想在这段代码中打印appVersion,但它实际上是打印对象_DeferreMethod对象 我怎样才能获得AppVersion的价值。(arguemnts) pic

1 个答案:

答案 0 :(得分:0)

您正在appVersion中获取有关该方法的信息,而不是调用它并获取其返回值。尝试添加以下内容:

service_application = dbus.Interface(service, 'com.qcom.Application')
appVersion = service_application.AppVersion()
print(appVersion)