[Telepathy] Accessing Folks from python, part 2
Philip Withnall
philip at tecnocode.co.uk
Mon Jan 23 06:40:07 PST 2012
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)
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?
> 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.
Philip
> So if anybody has any idea or advice, I’d be thankful.
>
> 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/92c89ae1/attachment.pgp>
More information about the telepathy
mailing list