UnknownMethodException: connecting python client through dbus

Srinadh Penugonda srinadh0 at yahoo.com
Wed Oct 6 17:14:20 UTC 2021


My host service is as below:
root at sonic:/tmp# busctl introspect org.SONiC.HostService.keyhandler  /org/SONiC/HostService/keyhandlerNAME                                TYPE      SIGNATURE RESULT/VALUE FLAGSorg.SONiC.HostService.keyhandler    interface -         -            -.key_ctl                            method    as        is           -org.freedesktop.DBus.Introspectable interface -         -            -.Introspect                         method    -         s            -root at sonic:/tmp# 


When I try to connect and execute a method, I am getting UnknownMethodException
My client code is as below:=========================================================================import dbus
import sys
class HostQuery:    def __init__(self):        try:            self._bus = dbus.SystemBus()            self._proxy = self._bus.get_object('org.SONiC.HostService',"/org/SONiC/HostService")        except Exception as e:
            msg = "Failed to connect.\nException :'{}'".format(str(e))            print(msg, file=sys.stderr)            sys.exit(1)
    def action(self, path, values):        print("in hostquery action")        res = path.split('.')        print("res is {}".format(res))        intf = dbus.Interface(self._proxy, dbus_interface=('org.SONiC.HostService.'+res[0]))        print(intf.getProperties())        ret = intf.key_ctl(values)        print("ret is {}".format(ret))        return ret
ut = HostQuery()ut.action("keyhandler.key_ctl", ["pwEncrypt", "test"])==============================================================================================
Logs shows as below:
root at sonic:/tmp# python3 hostcomm.py in hostquery actionres is ['keyhandler', 'key_ctl']Traceback (most recent call last):  File "hostcomm.py", line 27, in <module>    ut.action("keyhandler.key_ctl", ["pwEncrypt", "test"])  File "hostcomm.py", line 22, in action    ret = intf.key_ctl(values)  File "/usr/local/lib/python3.7/dist-packages/dbus/proxies.py", line 72, in __call__    return self._proxy_method(*args, **keywords)  File "/usr/local/lib/python3.7/dist-packages/dbus/proxies.py", line 147, in __call__    **keywords)  File "/usr/local/lib/python3.7/dist-packages/dbus/connection.py", line 653, in call_blocking    message, timeout)dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Traceback (most recent call last):  File "/usr/local/lib/python3.7/dist-packages/dbus/service.py", line 658, in _message_cb    (candidate_method, parent_method) = _method_lookup(self, method_name, interface_name)  File "/usr/local/lib/python3.7/dist-packages/dbus/service.py", line 248, in _method_lookup    raise UnknownMethodException('%s is not a valid method of interface %s' % (method_name, dbus_interface))dbus.exceptions.UnknownMethodException: org.freedesktop.DBus.Error.UnknownMethod: Unknown method: key_ctl is not a valid method of interface org.SONiC.HostService.keyhandler

Even getProperties() fails.
Any idea what is wrong here?



~~  Thanks, Srinadh

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/dbus/attachments/20211006/db6be5f2/attachment.htm>


More information about the dbus mailing list