python dbus如何获取对象值

python dbus how to get object value

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

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

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