[Telepathy] Accessing Folks from python, part 2

Philip Withnall philip at tecnocode.co.uk
Mon Jan 23 08:45:59 PST 2012


On Mon, 2012-01-23 at 16:21 +0100, Frederik Elwert wrote:
> Am Montag, den 23.01.2012, 14:40 +0000 schrieb Philip Withnall:
> > On Mon, 2012-01-23 at 10:22 +0100, Frederik Elwert wrote:
> > > Hello,
> > > 
> > > I am still trying to write a Folks client in Python. Thanks again for
> > > the fast fix for my last issue.
> > > 
> > > Since I had some trouble getting folks 0.6.6 running on Ubuntu 11.10, I
> > > just upgraded to 12.04, which has folks 0.6.6. Now I am trying again to
> > > digg into the python/Folks combo.
> > > 
> > > I tried with this simple test script:
> > > 
> > > ----8<----
> > > from gi.repository import GObject
> > > from gi.repository import Folks
> > > 
> > > 
> > > def list_individuals():
> > >     for key in aggregator.props.individuals.props.keys:
> > >         print aggregator.props.individuals.get(key)
> > > 
> > > aggregator = Folks.IndividualAggregator.new()
> > > aggregator.prepare(None, None)
> > > 
> > > GObject.timeout_add(2000, list_individuals)
> > > 
> > > main_loop = GObject.MainLoop()
> > > main_loop.run()
> > > ---->8----
> > > 
> > > Now I get this traceback:
> > > 
> > > Traceback (most recent call last):
> > >   File "folkstest.py", line 6, in list_individuals
> > >     for key in aggregator.props.individuals.props.keys:
> > > TypeError: '__main__.GeeHashMapKeySet' object is not iterable
> > > 
> > > So the gee bindings seem not to work the python way. I read the gee API
> > > doc, and then came up with something I had hoped would work:
> > > 
> > > ----8<----
> > > def list_individuals():
> > >     iterator = aggregator.props.individuals.props.keys.iterator()
> > >     while iterator.has_next():
> > >         iterator.next()
> > >         key = iterator.get()
> > >         print aggregator.props.individuals.get(key)
> > > ---->8----
> > > 
> > > This, however, segfaults. The issue seems to be the iterator.get()
> > > method call. I tried to get a backtrace using gdb, but since my
> > > debugging skills are very limited, I am not sure how useful it is. I
> > > attached it anyways, if you need more information, please just let me
> > > know.
> > 
> > You should be able to trim the code down to:
> > 
> > while iterator.next():
> >     key = iterator.get()
> >     print aggregator.props.individuals.get(key)
> 
> Okay, I changed my sample script accordingly. Thanks for the hint.
> However, still segfaulting.
> 
> > To my untrained eye, it looks like Python doesn't like the code, though,
> > since the stack trace contains a call to "PyErr_Print". If you inspected
> > this frame more closely (e.g. "frame 48; info locals" in gdb) that might
> > give a hint.
> > 
> > In any case, could you use the "backtrace full" command in gdb to get a
> > more detailed stack trace please?
> 
> I did this, please see the attached backtrace.

Looks like you're missing debug information for Python. Could you make
sure you've got the Python runtime debug symbols installed and get a
better stack trace please?

Hopefully then someone who knows about PyGObject can take a look at it.

Philip

> > > Now I don’t know if I just used the API incorrectly, or if gee just does
> > > not work from Python. But I still hope to use Folks from python, and I
> > > wanted to investigate a bit further, before I ditch everything and start
> > > all over with vala.
> > 
> > Don't give up! Every problem which gets fixed as a result of using folks
> > from Python will help everyone.
> 
> You’re right. I just can be frustrating at times to spend all the time
> getting the prerequisites up and running, instead of actually writing
> code for the project.
> 
> Anyway, thank you for your help!
> 
> Regards
> Frederik
> _______________________________________________
> telepathy mailing list
> telepathy at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/telepathy

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 230 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/telepathy/attachments/20120123/0ef92a5b/attachment-0001.pgp>


More information about the telepathy mailing list