1

私はpythonとdbusを初めて使用しますが、dbus-pythonを介してPythonクラスをデータバインディング(=送受信する方法)はありますか?

私のクラスは次のようになります。

class Item:

    def __init__(self, one, two, three, four, five, *more):
        self.one= one
        self.two= two
        self.three= three
        self.four= four
        self.five= five
        self.more= more

moreはリストで、1〜5は文字列です。私はこれらのアイテムのリストを持っています:

list_items = []
list_items.append(Item('Test','Test','Test','Test',more))

dbusの部分は次のようになります。

@dbus.service.method('com.me.test', in_signature='', out_signature='a(sssssav)')
def get_all_items():
    return list_items

署名にエラーがありますか、それともマーシャリングできる別のデータ構造(タプル?)を使用する必要がありますか?

4

1 に答える 1

0

いつでもデータを使用しpickleたりmarshal、バイト文字列などとして送信したりできます。または、 からサブクラス化して独自の DBus-Object を作成することもできますdbus.service.Object。私は前者で行きます...

于 2012-11-07T13:32:59.943 に答える