[Sugar-devel] Getting Journal entries off an XO at the end of a project?

Sascha Silbe silbe at activitycentral.com
Tue Jan 17 06:39:13 EST 2012

Excerpts from Christoph Derndorfer's message of 2012-01-13 19:56:51 +0100:

> (a) Have the pupils copy relevant files they want to keep to USB drives via
> the Journal or the Sugar commander Activity

> (b) Ask them to favorite things they want to keep in the Journal and then
> run a script that copies all of these entries to a USB drive or possibly
> even a network share

Given that you're still running Sugar 0.82, one of these is probably the
best option (in addition to doing a full backup, as explained in my
previous mail).

Whether the data file is usable outside of Sugar (i.e. in a standard
format) depends on each activity.

Writing a script that dumps all data files of starred entries is pretty
straightforward if you borrow some functions from jarabe.journal.model
(=> GPLv2+). You _will_ loose the metadata (description, tags, etc.) in
any case: Even when using the UI to write the files, the metadata isn't
in a format recognised by any other system.

The script would look something like this:

=== snip ===
#!/usr/bin/env python
# License: GPL version 3
import os
import shutil

from sugar import mime
from sugar.datastore import datastore

[copy get_file_name() and get_unique_file_name() from

mount_point = '/media/CHERRY_TREE'
for entry in datastore.find({'keep': '1'})[0]:
    title = entry.metadata.get('title') or 'Untitled'
    mime_type = entry.metadata.get('mime_type')
    target_name = get_unique_file_name(mount_point,
                                       get_file_name(title, mime_type))
    target_path = os.path.join(mount_point, target_name)
    shutil.copyfile(entry.file_path, target_path)

=== snip ===

Untested on Sugar 0.82. Backup/Restore access the data store directly
via D-Bus rather than through sugar.datastore.datastore, so I don't know
if the API changed in subtle ways; a quick check confirmed that all of
the functions imported (not copied) above were available in Sugar


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20120117/17c25ddf/attachment.pgp>

More information about the Sugar-devel mailing list