[Telepathy] Status of Telepathy Python

Mystilleef mystilleef at gmail.com
Mon Jun 6 21:15:43 PDT 2011


Danielle thanks for the response.

On Mon, Jun 6, 2011 at 10:14 PM, Danielle Madeley
<danielle.madeley at collabora.co.uk> wrote:
> On Mon, 2011-06-06 at 21:26 -0400, Mystilleef wrote:
>
>> I don't understand why though. I thought Telepathy was just
>> a DBus API. So maintaining the Python bindings against the
>> the DBus API doesn't sound too complicated. Afterall, all
>> we're doing is just calling DBus APIs in Python. I'm I
>> missing something?
>
> We actually want to move people away from direct use of the D-Bus API
> and towards using high-level, easier, useful API that calls the D-Bus
> API for you.
>

I see. I don't mind using the DBus APIs as long as I know what I'm doing.

>> > The future of writing Telepathy in Python is likely tp-glib via
>> > gobject-introspection/PyGI. This is how gnome-shell does it's Telepathy
>> > integration in Javascript. I don't know that anyone has tried writing a
>> > Python client in it today, but someone has to go first.
>>
>> I don't mind going first if I'm nudged in the right
>> direction. Are there any example code? Can I write a full
>> blown SIP client using tp-glib via PYGI today? Are there
>> any limitations?
>
> There isn't example code doing this in Python yet. You'd need to use a
> combination of the javascript code in gnome-shell, the telepathy-glib
> examples + any notes that exist on how PyGI generates API. People on
> #telepathy (irc.freenode.net) would gladly give you assistance here;
> it's our goal that this works, but no one has any time to work on it at
> the moment.
>
> There may be limitations, bugs that need fixing. Again, we haven't ever
> actually tested this, besides some very initial work I did a long time
> ago.
>
> You may end up having to make fixes to the introspection annotation in
> tp-glib, and find that pieces of high-level API you need are missing.
> OTOH, you _should_ be able to write a client at least as complete as
> gnome-shell.
>

I'll look into this. However, I'm nervous about writing an application using
Gobject Introspection. I've written a small app using it, but I'm not sure,
I'd use it for a big application, yet.

<snip>

>> I don't want to be completely negative. So I'll add I was
>> able to figure out some stuff using the DBus Spec and the
>> developer's handbook which does a fantastic job explaining
>> the architecture of Telepathy and would be even better
>> if the current examples (the Python ones in particular) are
>> updated and perhaps even more added.
>
> I happily welcome contributed/updated examples. Unfortunately I don't
> have any time to really invest in the docs at the moment.
>

I'd be more qualified to contribute when I _know_ what I'm doing. Newbies like
myself shouldn't be anywhere near the docs or examples. :-)

>> >> https://bugs.freedesktop.org/show_bug.cgi?id=35314
>> >
>> > This bug is a mistake in how someone is using the API, not a mistake in
>> > tp-python.
>>
>> What is the right way to use that API?
>
> Telepathy is meant to be used entirely asynchronously. You need to ready
> the object.

What object do I need to ready? Dbus Proxy objects, AccountManager, Account,
Connection objects? Or all of the above?

> Pass the keyword-arg ready_handler with the name of a
> callback for when the object is ready. [Notice also here the
> asynchronous method call.]
>
> For instance:
>
>        def main():
>            account = telepathy.client.Account(
>                '/org/freedesktop/Telepathy/Account/' + sys.argv[1],
>                ready_handler=_account_ready,
>                error_handler=_error)
>
>            loop = gobject.MainLoop()
>            loop.run()
>
>        def _account_ready(account):
>            # get the connection
>            account[dbus.PROPERTIES_IFACE].Get(ACCOUNT, 'Connection',
>                reply_handler=lambda x: _got_connection_path(account,
>        x),
>                error_handler=_error)
>
> In the tp-glib API this is called "preparing" an object. It does things
> like requesting the core properties, such as what interfaces are
> available on the object.
>

Thanks for the example, I'll look more into it.

>> After establishing a connection I can't use the
>> CONNECTION_INTERFACE_REQUESTS DBus interface at all.
>>
>> connection[CONNECTION_INTERFACE_REQUESTS] always raises an
>> error. I'm I not supposed to call that interface?
>
> Well, ideally you should make your requests to the ChannelDispatcher,
> which will forward them to the appropriate Connection for you. However
> your problem is not having prepared the object, so it doesn't know what
> interfaces are available.
>

Yeah, I read that in the documentation (developer's manual). If I remember
correctly I need to use the AccountManager/Accounts and the ChannelDispatcher
to initialize connections. I couldn't find any example code in Python
though. I'll
try to see if I can find examples for tp-glib.

>> >> QT does a fantastic job with their documentation it can be a
>> >> source of inspiration for the Telepathy framework.
>> >
>> > Have you considered Telepathy-Qt4?
>>
>> 5 years ago, I would have jumped at Telepathy-glib or
>> Telepathy-QT4. However, my days of writing desktop clients
>> in such languages (C/C++) is over. This is why I'm surprised
>> the Python bindings for Telepathy gets the least love. GIT
>> tells me the Python telepathy module has not seen any
>> commits in 5 months. I'm finding it hard to believe
>> developers today would choose Glib and Qt4 bindings over
>> Python. I'm I missing something? The situation seems to be
>> the reverse in most frameworks I've used.
>
> The interest in Telepathy on embedded devices means that languages like
> Python are not getting a lot of focus
>

Makes sense.

>[additionally I have opinions on  the appropriateness of languages like Python for big apps].
>

I had the same concerns years ago. However, many big apps are written in
Python today. I've written Python apps that are well into 100KSLOC.
Today, I even
found a full featured SIP library written entirely in Python. The idea that
you can't or shouldn't use Python to write large apps is mostly a myth.

http://www.b2bua.org/ [Full feature SIP library written entirely in Python]

I took for granted that there would be dozens of telepathy Python apps already
written that I could study because, at least of Linux, there's a Python app
for almost anything. I came away startled when I couldn't find much
for Telepathy.

> Furthermore
> we realised that maintaining n bindings for n languages was not a
> scalable use of our time, especially if we had to write a high-level
> binding in each language separately. Hence we began work on
> gobject-introspection for telepathy-glib and eventual deprecation of the
> low-level bindings.
>

Makes sense

> The future now is to support Python and Javascript via tp-glib +
> gobject-introspection (almost all CMs require tp-glib anyway).
> telepathy-python will probably continue to exist to provide service-side
> bindings for tp-butterfly and tp-sunshine [it would be neat to provide
> g-i bindings for tp-glib's service-side, and completely remove
> tp-python, but that's a long way off].
>

We'll see how it goes. Thanks for your response.


More information about the telepathy mailing list