summaryrefslogtreecommitdiff
path: root/examples/introspection/python/all-async.py
diff options
context:
space:
mode:
authorIvan Frade <ivan.frade@nokia.com>2011-03-28 19:28:49 +0300
committerMartyn Russell <martyn@lanedo.com>2011-04-05 12:29:46 +0100
commitc5e62d1dedf1fab04087e6ed7efb96b998e9b54a (patch)
tree88d1e02436d664399c70098f414bb8c065802772 /examples/introspection/python/all-async.py
parent54d0a683acbfdc10589c6bb4b06573f32483667a (diff)
downloadtracker-c5e62d1dedf1fab04087e6ed7efb96b998e9b54a.tar.gz
libtracker-miner, libtracker-sparql: Added introspection examples
Miner and Async query are not working as expected yet, but the code should be correct.
Diffstat (limited to 'examples/introspection/python/all-async.py')
-rwxr-xr-xexamples/introspection/python/all-async.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/introspection/python/all-async.py b/examples/introspection/python/all-async.py
new file mode 100755
index 000000000..70a3b2b1f
--- /dev/null
+++ b/examples/introspection/python/all-async.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+import gi
+from gi.repository import Tracker, GObject
+
+
+def results_ready_cb (obj, result, user_data):
+ cursor = obj.query_finish (result)
+
+ # This can also be done asynchronously
+ while (cursor.next (None)):
+ print cursor.get_string (0)
+
+ user_data.quit ()
+
+def connection_ready_cb (object, result, user_data):
+ assert user_data
+ conn = Tracker.SparqlConnection.get_finish (result)
+
+ conn.query_async ("SELECT ?u WHERE { ?u a nie:InformationElement. }",
+ None,
+ results_ready_cb,
+ user_data)
+
+
+if __name__ == "__main__":
+ loop = GObject.MainLoop ()
+
+ Tracker.SparqlConnection.get_async (None, connection_ready_cb, loop)
+
+ loop.run ()