diff options
author | Benjamin Saller <bcsaller@objectrealms.net> | 2007-07-09 05:13:47 (GMT) |
---|---|---|
committer | Benjamin Saller <bcsaller@objectrealms.net> | 2007-07-09 05:13:47 (GMT) |
commit | dba66e2ae0f2e85a7e024229c026c477ac786719 (patch) | |
tree | dc92813452072eebd389195ff04ad3abe3abf938 /bin | |
parent | cb8a3f7e34b07a4d3fb3ebb3cb7eddceaec0e73d (diff) |
indexing changes
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/datastore | 4 | ||||
-rwxr-xr-x | bin/datastore-service | 8 | ||||
-rwxr-xr-x | bin/index-service | 17 | ||||
-rwxr-xr-x | bin/test-indexprop.py | 27 |
4 files changed, 38 insertions, 18 deletions
diff --git a/bin/datastore b/bin/datastore index 77aca84..dad3df9 100755 --- a/bin/datastore +++ b/bin/datastore @@ -41,7 +41,7 @@ class DataStoreApplication(Application): action="store_true", default=False, help="""Dump database work""") - self.parser.add_option("--olpc.fulltext.sync", dest="sync_index", + self.parser.add_option("--olpc.fulltext.sync", dest="querymanager_sync_index", action="store_true", default=False, help="""Force the indexer in-process in synchronous mode.""") @@ -60,7 +60,7 @@ class DataStoreApplication(Application): self.ds = DataStore(self.options.repo_dir, self.options.md_db, - querymanager_sync_index=self.options.sync_index) + querymanager_sync_index=self.options.querymanager_sync_index) if self.options.sync_index is False and self.options.start_indexer: # trigger the index service diff --git a/bin/datastore-service b/bin/datastore-service index d43fd6d..4300619 100755 --- a/bin/datastore-service +++ b/bin/datastore-service @@ -7,6 +7,8 @@ from olpc.datastore import DataStore, DS_LOG_CHANNEL, backingstore from olpc.datastore.indexer import INDEX_SERVICE, INDEX_OBJECT_PATH import logging +SYNC_INDEX = True + # Path handling profile = os.environ.get('SUGAR_PROFILE', 'default') base_dir = os.path.join(os.path.expanduser('~'), '.sugar', profile) @@ -51,7 +53,7 @@ bus = dbus.SessionBus() ds = DataStore() ds.registerBackend(backingstore.FileBackingStore) ds.registerBackend(backingstore.InplaceFileBackingStore) -ds.mount(repo_dir, {'querymanager_sync_index': False}) +ds.mount(repo_dir, {'querymanager_sync_index': SYNC_INDEX}) # and run it logger.info("Starting Datastore %s" % (repo_dir)) @@ -66,7 +68,9 @@ signal.signal(signal.SIGHUP, handle_shutdown) signal.signal(signal.SIGTERM, handle_shutdown) def main(): - indexer = bus.get_object(INDEX_SERVICE, INDEX_OBJECT_PATH) + if SYNC_INDEX is False: + indexer = bus.get_object(INDEX_SERVICE, INDEX_OBJECT_PATH) + try: mainloop.run() except KeyboardInterrupt: ds.stop() diff --git a/bin/index-service b/bin/index-service index 4529913..a2ff83c 100755 --- a/bin/index-service +++ b/bin/index-service @@ -58,7 +58,8 @@ class IndexService(Application): self.fulltext = Indexer(self.options.fulltext_dir) self.fulltext.use_fulltext = True - self.ds = bus.get_object(DS_SERVICE, DS_OBJECT_PATH) + ds = bus.get_object(DS_SERVICE, DS_OBJECT_PATH) + self.ds = dbus.Interface(ds, dbus_interface=DS_DBUS_INTERFACE) self.ds.connect_to_signal("Created", self.created, dbus_interface=DS_DBUS_INTERFACE) @@ -80,8 +81,8 @@ class IndexService(Application): # currently this is still searched with the 'fulltext' # parameter of find() textprops = {} - for p in self.ds.get_properties(uid, type='text'): - textprops[p.key] = p.value and p.value or '' + for k,v in self.ds.get_properties(uid, dict(type='text')).items(): + textprops[str(k)] = v and str(v) or '' return textprops def created(self, uid): @@ -92,9 +93,9 @@ class IndexService(Application): filename = self.ds.get_filename(uid) r = None if filename: - mime_type = self.ds.get_properties(uid).get('mime_type', None) + mime_type = self.ds.get_properties(uid, {}).get('mime_type', None) r = self.fulltext.fulltext_index(uid, filename, mime_type, - **self.get_textprops(uid)) + self.get_textprops(uid)) if r is True: logger.debug("index creation of %s" % uid) elif r is False: @@ -110,10 +111,10 @@ class IndexService(Application): filename = self.ds.get_filename(uid) r = None if filename: - mime_type = self.ds.get_properties(uid).get('mime_type', None) - print uid, filename, mime_type + mime_type = self.ds.get_properties(uid, {}).get('mime_type', + None) r = self.fulltext.fulltext_index(uid, filename, mime_type, - **self.get_textprops(uid)) + self.get_textprops(uid)) if r is True: logger.debug("index update of %s" % uid) elif r is False: diff --git a/bin/test-indexprop.py b/bin/test-indexprop.py index fa0a5c3..e94a8aa 100755 --- a/bin/test-indexprop.py +++ b/bin/test-indexprop.py @@ -4,10 +4,22 @@ import os def main(): bus = dbus.SessionBus() - datastore = bus.get_object("org.laptop.sugar.DataStore", - "/org/laptop/sugar/DataStore") + ds = bus.get_object("org.laptop.sugar.DataStore", + "/org/laptop/sugar/DataStore") + datastore = dbus.Interface(ds, dbus_interface='org.laptop.sugar.DataStore') + + props = {'title:text': 'test activity', + 'title_set_by_user': '0', + 'buddies': '', + 'keep': '0', + 'icon-color': '#40011d,#79079a', + 'activity': 'org.laptop.WebActivity', + 'mime_type': ''} - props = {'title:text': 'title', + uid = datastore.create(props, '') + print "created uid", uid + + props = {'title:text': 'test activity title changed', 'title_set_by_user': '1', 'buddies': '', 'keep': '0', @@ -15,10 +27,13 @@ def main(): 'activity': 'org.laptop.WebActivity', 'mime_type': 'text/plain'} - uid = datastore.create(props, os.path.abspath('tests/web_data.json')) - print "created uid", uid + datastore.update(uid, props, os.path.abspath('tests/web_data.json')) + print "updated uid", uid - result, count = datastore.find(dict(fulltext='title')) + #import time;time.sleep(1.0) + + result, count = datastore.find(dict(fulltext='test')) + print result assert result[0]['uid'] == uid for k, v in result[0].items(): print "\t", k, v |