HELP! Does anyone know how to export properties with python-dbus??

268/365 - Default State (C) Helga Weber 2009

I need help! I need to know if it’s possible to export properties over dbus with python-dbus, and how to do so! I’ve been Googling for hours, emailed dbus-list (which by the way admins LET MY EMAIL THROUGH THE QUEUE!), read the python-dbus tutorial, tried to find applications that do this, asked on irc and have found nothing. There has to be someone out there who knows a) whether or not this is possible and if a: then how to do it! So please, if you’re a python-dbus guru, a neophyte who just happens to know this, or some sort of crystal eating psychic who can tap into a collective consciousness and find this information out, PLEASE leave a comment, email me, find me on irc (lamalex on gimpnet and freenode), come to my house (in south philly- i’ll feed you), call my cellphone, or transmit the information to me telepathically.

Thank you to the prophet who can uncover this age old mystery.

About Alex Launi

I live in Philly \ I go to shows, I ride bikes \ Ugh, can't think of more.
This entry was posted in Uncategorized. Bookmark the permalink.

5 Responses to HELP! Does anyone know how to export properties with python-dbus??

  1. Evan says:

    @dbus.service.method(dbus.PROPERTIES_IFACE, in_signature=’s', out_signature=’v')
    def Get(self, prop):
    return self.props[prop]

    @dbus.service.method(dbus.PROPERTIES_IFACE, in_signature=’sv’, out_signature=”)
    def Set(self, prop, val):
    self.props[prop] = val

  2. D-Bus properties are just another interface that your object implements. you need to implement three methods on the org.freedesktop.DBus.Properties interface:

    @method(dbus_interface=’org.freedesktop.DBus.Properties’, in_signature=’s', out_signature=’a{sv}’)
    def GetAll(self, interface):
    if interface == ‘com.example.Foo’:
    return {‘Bar’: 3, ‘Baz’: ‘cake’}
    else:
    # throw an error if the object doesn’t actually implement that interface

    @method(dbus_interface=’org.freedesktop.DBus.Properties’, in_signature=’ss’, out_signature=’v')
    def GetAll(self, interface, property):
    if interface == ‘com.example.Foo’:
    if property == ‘Bar’:
    return 3
    # &c &c

    @method(dbus_interface=’org.freedesktop.DBus.Properties’, in_signature=’ssv’, out_signature=”)
    def Set(self, interface, property, value):
    left as an exercise to the reader

    In an ideal world dbus-python would help you out here. I’m sure a patch to add helpers for exporting properties would be appreciated. I’ve seen a few people throwing ideas around in the past; check on bugs.freedesktop.org, product=DBus, component=python for any discussion?

  3. glatzor says:

    AFAIK introspection isn’t supported you would have to add the properites to the xml manually.

  4. Bruce says:

    @dbus.service.method(dbus.PROPERTIES_IFACE, in_signature=’s', out_signature=’v')
    def Get(self, prop):
    return self.props[prop]

    @dbus.service.method(dbus.PROPERTIES_IFACE, in_signature=’sv’, out_signature=”)
    def Set(self, prop, val):
    self.props[prop] = val

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>