Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorChristophe 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)
commit37bea560e5661711f7c683282cc5d1c2b7e22dd7 (patch)
tree792469a33e01b639ae02750c4d997e431358992c /bin
parentdb36b97d47c0a20f7823335cb7c78c83ff6accdc (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.py29
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)
+