Search code examples
pythondbus

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)

I want to print appVersion at this code, but it actually print object _DeferreMethod object How can I get the value of AppVersion.(arguemnts) pic


Solution

  • You are getting information about the method in appVersion, rather than calling it and getting its return value. Try adding something like:

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