diff options
author | Christophe Gueret <christophe.gueret@gmail.com> | 2011-04-26 14:26:09 (GMT) |
---|---|---|
committer | Christophe Gueret <christophe.gueret@gmail.com> | 2011-04-26 14:26:09 (GMT) |
commit | 37bea560e5661711f7c683282cc5d1c2b7e22dd7 (patch) | |
tree | 792469a33e01b639ae02750c4d997e431358992c /bin | |
parent | db36b97d47c0a20f7823335cb7c78c83ff6accdc (diff) |
Added initial code
Diffstat (limited to 'bin')
-rwxr-xr-x[-rw-r--r--] | bin/datastore-service.py (renamed from bin/datastore-service) | 6 | ||||
-rw-r--r-- | bin/test.py | 29 |
2 files changed, 34 insertions, 1 deletions
diff --git a/bin/datastore-service b/bin/datastore-service.py index cbfc475..e8d9961 100644..100755 --- a/bin/datastore-service +++ b/bin/datastore-service.py @@ -10,6 +10,7 @@ import dbus.glib from carquinyol.datastore import DataStore from sugar import logger + # Path handling profile = os.environ.get('SUGAR_PROFILE', 'default') base_dir = os.path.join(os.path.expanduser('~'), '.sugar', profile) @@ -18,7 +19,8 @@ if not os.path.exists(log_dir): os.makedirs(log_dir) # setup logger -logger.start('datastore') +# logger.start('datastore') + # build the datastore dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) @@ -27,6 +29,7 @@ connected = True ds = DataStore() + # and run it mainloop = gobject.MainLoop() @@ -51,6 +54,7 @@ signal.signal(signal.SIGTERM, handle_shutdown) def main(): try: + print "test" mainloop.run() except KeyboardInterrupt: logging.info("DataStore shutdown by user") diff --git a/bin/test.py b/bin/test.py new file mode 100644 index 0000000..4ccd715 --- /dev/null +++ b/bin/test.py @@ -0,0 +1,29 @@ +''' +Created on Apr 8, 2011 + +@author: cgueret +''' + +import os +import dbus +from sugar.datastore import datastore + +if os.path.exists("/tmp/olpc-session-bus"): + os.environ["DBUS_SESSION_BUS_ADDRESS"] = "unix:path=/tmp/olpc-session-bus" + +if __name__ == "__main__": + try: + entry = datastore.create() + entry.metadata['title'] = 'Terminal-test' + print entry.metadata.get_dictionary().copy() + datastore.write(entry) + + query = {} + query['query'] = '*Terminal*' + objects, count = datastore.find(query, limit=2) + print objects, count + except dbus.DBusException: + print 'ERROR: Unable to connect to the datastore.\n' + except Exception, e: + print 'ERROR: %s' % (e) + |