Remove some debug spew
[beagle.git] / wrappers / python / beaglesearch.py
blob699e9d580eea8ed19b5c64a04697ac6db19ebff3
1 #!/usr/bin/env python
3 import beagle
4 import gobject
5 import sys
7 total_hits = 0
9 def hits_added_cb (query, response):
10 global total_hits
11 hits = response.get_hits()
13 total_hits = total_hits + len(hits)
14 print "Found hits (%d):" % len(hits)
15 print "-------------------------------------------"
17 for hit in hits:
18 if hit.get_type() == "FeedItem":
19 text = hit ['dc:title']
20 print "Blog: %s" % text
21 elif hit.get_type() == "File":
22 print "File: %s" % hit.get_uri()
23 elif hit.get_type() == "MailMessage":
24 print "Email: %s" % hit ['dc:title']
25 for sender in hit.get_properties ('fixme:from'):
26 print "\tSent by: %s" % sender
27 else:
28 print "%s (%s)" % (hit.get_uri(), hit.get_source())
30 print "-------------------------------------------"
32 def finished_cb (query, response, loop):
33 main_loop.quit()
35 client = beagle.Client()
36 main_loop = gobject.MainLoop()
37 query = beagle.Query()
39 for i in sys.argv[1:]:
40 query.add_text(i)
42 query.connect("hits-added", hits_added_cb)
43 query.connect("finished", finished_cb, main_loop)
44 client.send_request_async(query)
46 main_loop.run()
48 print "Found a total of %d hits" % total_hits