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

Christoph Derndorfer christoph.derndorfer at gmail.com
Wed Jan 18 05:20:50 EST 2012


On Tue, Jan 17, 2012 at 12:39 PM, Sascha Silbe <silbe at activitycentral.com>wrote:

> 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
> src/jarabe/journal/model.py]
>
>
> 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)
>    entry.destroy()
>
> === 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
> 0.82.0.


Thanks for the additional information and explanations, this is very
helpful indeed! :-)

Christoph

-- 
Christoph Derndorfer

volunteer, OLPC (Austria) [www.olpc.at]
editor, OLPC News [www.olpcnews.com]
contributor, TechnikBasteln [www.technikbasteln.net]

e-mail: christoph at derndorfer.eu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20120118/cf397c0a/attachment.html>


More information about the Sugar-devel mailing list