私は既存の C プロジェクトの Python クローンに取り組んでいます。C プロジェクトはカスタム DBus に接続し、そこでコールバックを取得するためのオブジェクトを提供します。
基本的には次のコードで Python を使用してこれを複製しようとしました。
def vtable_method_call_cb(connection, sender, object_path, interface_name, method_name, parameters, invocation, user_data):
print('vtable_method_call_cb: %s' % method_name)
connection = Gio.DBusConnection.new_for_address_sync(
"unix:abstract=gstswitch",
Gio.DBusConnectionFlags.AUTHENTICATION_CLIENT,
None,
None)
node_info = Gio.DBusNodeInfo.new_for_xml(introspection_xml)
vtable = Gio.DBusInterfaceVTable()
vtable.method_call(vtable_method_call_cb)
vtable.get_property(None)
vtable.set_property(None)
connection.register_object(
"/info/duzy/gst/switch/SwitchUI",
node_info.interfaces[0],
vtable,
None,
None)
呼び出しで vtable を作成するときにコードが失敗しvtable.method_callます (ただしget_property、1 つの呼び出しをコメントアウトすると失敗します)、次のログ/トレースバック:
** (process:18062): WARNING **: Field method_call: Interface type 2 should have is_pointer set
Traceback (most recent call last):
File "moo.py", line 69, in <module>
vtable.method_call(vtable_method_call_cb)
RuntimeError: unable to get the value
Python で使用しているコードを見つけることができなかったregister_object()ので、Gio のこの部分を使用できるかどうか、または完全ではないかどうかはわかりません。