Sample large datastore

Tomeu Vizoso tomeu at tomeuvizoso.net
Mon May 19 04:30:26 EDT 2008


On Mon, May 19, 2008 at 9:55 AM, Martin Langhoff
<martin.langhoff at gmail.com> wrote:
> n Mon, May 19, 2008 at 7:20 PM, Tomeu Vizoso <tomeu at tomeuvizoso.net> wrote:
>> Do you think this would be enough?
>
> That'll be *perfect* for this :-)

Ok, then something like this should do the job:

---

import sys
import os
import unittest
import time
import tempfile
import shutil
from datetime import datetime

import dbus

DS_DBUS_SERVICE = "org.laptop.sugar.DataStore"
DS_DBUS_INTERFACE = "org.laptop.sugar.DataStore"
DS_DBUS_PATH = "/org/laptop/sugar/DataStore"

bus = dbus.SessionBus()
proxy = bus.get_object(DS_DBUS_SERVICE, DS_DBUS_PATH)
data_store = dbus.Interface(proxy, DS_DBUS_INTERFACE)

for i in range(0, 10):
    results, count = data_store.find({}, ['uid'])
    print count
    for props in results:
        props2 = data_store.get_properties(props['uid'])
        data_store.create(props2, '', True)

---

If you run it from an ssh session, you'll need to

export DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/olpc-session-bus

And if you kill the journal first, it will be much faster because it
won't be burning cpu cycles updating the UI.

Good luck,

Tomeu



More information about the Devel mailing list