How dynamically export methods to dbus using python, without static decorator?

孤街浪徒 提交于 2020-01-07 04:17:05

问题


I searched for an answer to this question in several places, but I could not find a consistent solution, and some are too old and unclear.

I have a classe where the interface path for dbus is generated in runtime, so I need to export methods with the properly interface, for example:

One instance of my service start dbus with interface br.example.MyInterface.Number1, and a second instance of service start dbus with br.example.MyInterface.Number2, so the decorator for each method will be:

br.example.MyInterface.Number1 ; and br.example.MyInterface.Number2

Cannot make this work with static decorator like @dbus.service.method('com.example.MyInterface.Number1'), because they are distincts.

How can I export methods to dbus in runtime using python?


回答1:


@dbus.service.method('com.example.MyInterface.Number%d' % (instancenum,))


来源:https://stackoverflow.com/questions/13810613/how-dynamically-export-methods-to-dbus-using-python-without-static-decorator

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!