Re: [Sugar-devel] Text-to-speech on the XO 1.5 with 10.1.3
Thank Mikus. Thats fantastic. Turtle Art now has text to speech http://tonyforster.blogspot.com/2011/02/turtle-art-text-to-speech.html Tony Haven't sugarized espeak, but can run it from the command line: espeak "hello" --stdout | aplay mikus ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [IAEP] Feedback needed: pippy use cases?
I wanted to add that I agree with Steve. I have been working with 5th-8th graders, many of whom love Turtle Art, Scratch, and Etoys. When they get the "bug" from this kind of programming, I want to introduce them to Pippy, but, like Steve said, I am not sure what to do other than press run. Gerald On Wed, Feb 23, 2011 at 4:45 AM, Steve Thomas wrote: > An interface and examples like: http://tryruby.org/ would be a nice. It;s > a "hand's on tutorial" that walks you through learning ruby step by step and > you feel like you are actually doing and learning something. Ideally you > could also build a framework where users could create their own "lesson's" > following a similar format. > > Part of the challenge of the existing Pippy is while it has some nice fun > examples they don't "invite you in" to start coding the way tryruby.orgdoes. > To me when I first saw it I wasn't sure what I was supposed to do > other than hit "Run!'. > > FYI, the "Thanks" program does not work on my XO. > > Stephen > http://mrstevesscience.blogspot.com/ > > > > On Tue, Feb 22, 2011 at 11:03 PM, Anish Mangal > wrote: > >> Hi, >> >> As Pippy maintainer, I'm looking for inputs as to how is Pippy >> intended to be used in a classroom environment and how is it currently >> used. In particular: >> >> 1. What grades use Pippy? Could it be used in lower grades with some >> changes? If so, what could be the nature of those changes? >> >> 2. Collaborative code editing? How much is it actually used? What >> could be made better? >> >> 3. Sharing/reviewing of examples by other kids/teachers? >> >> 4. Would more explanatory code comments in Pippy examples help? >> >> 5. Would having a central repository of having pippy code examples >> help... For example, the ability to download/upload to a url like >> pippy.sugarlabs.org? >> >> 6. Would it help to have the examples in different languages wherever >> possible (spanish, for example)? >> >> Inputs will help guide future releases of Pippy. >> >> -- >> Anish >> ___ >> IAEP -- It's An Education Project (not a laptop project!) >> i...@lists.sugarlabs.org >> http://lists.sugarlabs.org/listinfo/iaep >> > > > ___ > IAEP -- It's An Education Project (not a laptop project!) > i...@lists.sugarlabs.org > http://lists.sugarlabs.org/listinfo/iaep > ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] Text-to-speech on the XO 1.5 with 10.1.3
Gonzalzo, Thanks for your help with this. I can see now pasting text into Speak. And I understand about Read Ebooks. What the teachers were asking for was for the ability to have text read in Browse and Write. The use case would be highlighting text and then taking some action which results in the text being spoken by the XO. Let me know if you need more detail or information. Thanks again. Gerald On Wed, Feb 23, 2011 at 1:35 AM, Gonzalo Odiard wrote: > Read Ebooks activity have text to speech capabilities, and i am adding this > to Read activity too. > Can you describe what you and your teachers need? > > Gonzalo > > On Tue, Feb 22, 2011 at 9:39 PM, Dr. Gerald Ardito < > gerald.ard...@gmail.com> wrote: > >> Hello all. >> >> I am working with some teachers and students using XO 1.5 and version >> 10.1.3 of the software. >> The teachers really want to make use of a text to speech functionality. >> I can't seem to find out how this works. >> >> I would appreciate any help you can offer. >> >> Thanks. >> Gerald >> >> ___ >> Sugar-devel mailing list >> Sugar-devel@lists.sugarlabs.org >> http://lists.sugarlabs.org/listinfo/sugar-devel >> >> > ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] Text-to-speech on the XO 1.5 with 10.1.3
Mikus, Thanks. Gerald On Wed, Feb 23, 2011 at 2:52 AM, Mikus Grinbergs wrote: > Haven't sugarized espeak, but can run it from the command line: > > espeak "hello" --stdout | aplay > > > mikus > > ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] Feedback needed: pippy use cases?
On Tue, Feb 22, 2011 at 11:03 PM, Anish Mangal wrote: > Hi, > > As Pippy maintainer, I'm looking for inputs as to how is Pippy > intended to be used in a classroom environment and how is it currently > used. In particular: > > 1. What grades use Pippy? Could it be used in lower grades with some > changes? If so, what could be the nature of those changes? > > 2. Collaborative code editing? How much is it actually used? What > could be made better? > > 3. Sharing/reviewing of examples by other kids/teachers? > > 4. Would more explanatory code comments in Pippy examples help? > > 5. Would having a central repository of having pippy code examples > help... For example, the ability to download/upload to a url like > pippy.sugarlabs.org? > > 6. Would it help to have the examples in different languages wherever > possible (spanish, for example)? > > Inputs will help guide future releases of Pippy. Pippy is used to edit code snippets that get imported into Turtle Art. It would be nice to be able to import the Turtle Art environment so that these snippets can be tested in Pippy. It is also of interest to some Turtle Art users to import some of the Pippy libraries in their sample code. -walter > > -- > Anish > ___ > Sugar-devel mailing list > Sugar-devel@lists.sugarlabs.org > http://lists.sugarlabs.org/listinfo/sugar-devel > -- Walter Bender Sugar Labs http://www.sugarlabs.org ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] Feedback needed: pippy use cases?
Hi, As Pippy maintainer, I'm looking for inputs as to how is Pippy intended to be used in a classroom environment and how is it currently used. In particular: 1. What grades use Pippy? Could it be used in lower grades with some changes? If so, what could be the nature of those changes? 2. Collaborative code editing? How much is it actually used? What could be made better? 3. Sharing/reviewing of examples by other kids/teachers? 4. Would more explanatory code comments in Pippy examples help? 5. Would having a central repository of having pippy code examples help... For example, the ability to download/upload to a url like pippy.sugarlabs.org? 6. Would it help to have the examples in different languages wherever possible (spanish, for example)? Inputs will help guide future releases of Pippy. -- Anish ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [PATCH /sugar-jhbuild/source/pippy/data/math/factorial] Fix n variable error within the Factorial program in Pippy
On Tue, Feb 22, 2011 at 11:36:41PM -0300, Anish Mangal wrote: > I've uploaded a new Pippy (39) to aslo. It should have the change > (along with a bunch of pep8 and pylint cleanups) whenever its made > public. ef3edc36c1a1c06f19823bc7b99a880c48675dfa Reviewed-by: James Cameron Sad to see the pep8 and pylint example changes go in, now there's nothing for the kids to fix, it all looks too perfect. Noted the change to credits near the end of the patch. Thanks. 7a851677a70b56cd662b1fb25a4cc40f79d08da4 Reviewed-by: James Cameron Noted the simultaneous change of activity/activity.info and pippy_app.py. Have you any idea what pippy_activity_version() is for? I can't figure it out. I can't find a caller. Activity.get_activity_version() seems to work fine in other contexts. By the way, Pippy-38 contained .pippy_app.py.swp by accident. -- James Cameron http://quozl.linux.org.au/ ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] Text-to-speech on the XO 1.5 with 10.1.3
Haven't sugarized espeak, but can run it from the command line: espeak "hello" --stdout | aplay mikus ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [PATCH /sugar-jhbuild/source/pippy/data/math/factorial] Fix n variable error within the Factorial program in Pippy
Hi, I've uploaded a new Pippy (39) to aslo. It should have the change (along with a bunch of pep8 and pylint cleanups) whenever its made public. Thanks for making Pippy better :-) On Mon, Feb 21, 2011 at 23:11, James Cameron wrote: > On Mon, Feb 21, 2011 at 11:46:49AM -0500, Rafael Ortiz wrote: >> This patch was attached by Francis to the bug. >> >> http://bugs.sugarlabs.org/attachment/ticket/2604/ >> factorial-nfix-ticket2604.patch > > Thanks. Looks like my mistake. > >> Pippy's maintainer should add it to the next version. > > Agreed. > > Reviewed-by: James Cameron > > -- > James Cameron > http://quozl.linux.org.au/ > ___ > Sugar-devel mailing list > Sugar-devel@lists.sugarlabs.org > http://lists.sugarlabs.org/listinfo/sugar-devel > -- Anish | an...@sugarlabs.org ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] Text-to-speech on the XO 1.5 with 10.1.3
Read Ebooks activity have text to speech capabilities, and i am adding this to Read activity too. Can you describe what you and your teachers need? Gonzalo On Tue, Feb 22, 2011 at 9:39 PM, Dr. Gerald Ardito wrote: > Hello all. > > I am working with some teachers and students using XO 1.5 and version > 10.1.3 of the software. > The teachers really want to make use of a text to speech functionality. > I can't seem to find out how this works. > > I would appreciate any help you can offer. > > Thanks. > Gerald > > ___ > Sugar-devel mailing list > Sugar-devel@lists.sugarlabs.org > http://lists.sugarlabs.org/listinfo/sugar-devel > > ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [DESIGN] insert image in Write
It might be re-purposed generally for media controls, which would be a good place for the image insert icon, and the view controls could be moved to the activity sub-toolbar. > > This also makes more room on the Browse main toolbar. > > http://wiki.sugarlabs.org/go/Design_Team/Proposals/Toolbars > > > I don't see in these toolbars, any logic. The View (zoom, full screen) controls, don't have relation with the activity toolbar, and in the Browse example are not relation between edit controls / view controls and the reload button. May be need to re-think how include the two upper corners in the useful toolbar area. We can exclude them from the area who auto display the frame. Gonzalo ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] Text-to-speech on the XO 1.5 with 10.1.3
On Wed, Feb 23, 2011 at 12:13:22PM +1100, fors...@ozonline.com.au wrote: > Chat also has text to speech > it might be tapping into some common library? Yes. Speak uses espeak via command line, as Chris pointed out. I found that in the source too. I didn't find anything in Chat. In 10.1.3, apart from Speak, I'm not aware of a way to either: - select some text and press a button to have it read out. - tab to screen objects and have them read out. Both these features are available in other contexts for sight impaired usage. I've no idea if that is what was required. There appears to be some way to use Alt/Shift/S to deliver the current selection to a speech proxy via DBus, but it doesn't do anything for me on 10.1.3. sugar.git/src/jarabe/view/keyhandler.py -- James Cameron http://quozl.linux.org.au/ ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] Text-to-speech on the XO 1.5 with 10.1.3
Hi, > Chat also has text to speech > it might be tapping into some common library? There's a remarkable aversion to looking at source code in this thread. :) Speak.activity/espeak_cmd.py: import espeak ... def speak(self, status, text): subprocess.call(["espeak", "-w", wavpath, "-p", str(status.pitch), "-s", str(rate), "-v", status.voice.name, text], stdout=subprocess.PIPE) - Chris. -- Chris Ball One Laptop Per Child ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] Text-to-speech on the XO 1.5 with 10.1.3
Chat also has text to speech it might be tapping into some common library? Tony The Sugar Speak activity provides a keyboard to speech function. The learner types words, then presses enter. The text is spoken. I'm personally not aware of a general purpose text to speech function for the rest of the Sugar user interface, but someone else may know of one. -- James Cameron http://quozl.linux.org.au/ ___ Devel mailing list de...@lists.laptop.org http://lists.laptop.org/listinfo/devel _ This mail has been virus scanned by Australia On Line see http://www.australiaonline.net.au/mailscanning ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] Text-to-speech on the XO 1.5 with 10.1.3
James, Thanks. This is very helpful. Gerald On Wed, Feb 23, 2011 at 1:00 AM, James Cameron wrote: > The Sugar Speak activity provides a keyboard to speech function. The > learner types words, then presses enter. The text is spoken. > > I'm personally not aware of a general purpose text to speech function > for the rest of the Sugar user interface, but someone else may know of > one. > > -- > James Cameron > http://quozl.linux.org.au/ > ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] Text-to-speech on the XO 1.5 with 10.1.3
The Sugar Speak activity provides a keyboard to speech function. The learner types words, then presses enter. The text is spoken. I'm personally not aware of a general purpose text to speech function for the rest of the Sugar user interface, but someone else may know of one. -- James Cameron http://quozl.linux.org.au/ ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [DESIGN] insert image in Write
Hi Fred, On 22 Feb 2011, at 21:42, Frederick Grose wrote: > On Tue, Feb 22, 2011 at 2:02 PM, Simon Schampijer wrote: > Hi Gary, > > a small design question regarding inserting an image in the Write document: > it took me a while to figure out where the option is - it is currently placed > under the table toolbar. However you can insert an image in the document or a > table. > > Do you maybe have ideas for a better fit for that icon? > > Regards, > Simon > > Yes, > > The 'Eye' icon can be easily confused with the Record media activity. > > It might be re-purposed generally for media controls, which would be a good > place for the image insert icon, and the view controls could be moved to the > activity sub-toolbar. Hmmm, this seems to have little to do with Simon's need to find a more obvious place for the insert image tool, unless you think this single tool should replace the current content of the Write View secondary toolbar? The View toolbar eye icon is already used in a number of activities, are you proposing to update these? We also have at least one Activity that has a pretty full Activity secondary toolbar* and a pretty full View toolbar (Turtle Blocks/Art). * the extra space is used for different export formats into the Journal, we should do this for Write's export formats as well (currently hiding under the Keep icon). Actually, Walter does have a couple of import from Journal tools in the TA Activity toolbar, perhaps Write's insert image tool could be considered there as an import image from Journal function? --Gary > This also makes more room on the Browse main toolbar. > > http://wiki.sugarlabs.org/go/Design_Team/Proposals/Toolbars > > --Fred > ___ > Sugar-devel mailing list > Sugar-devel@lists.sugarlabs.org > http://lists.sugarlabs.org/listinfo/sugar-devel ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] Text-to-speech on the XO 1.5 with 10.1.3
Hello all. I am working with some teachers and students using XO 1.5 and version 10.1.3 of the software. The teachers really want to make use of a text to speech functionality. I can't seem to find out how this works. I would appreciate any help you can offer. Thanks. Gerald ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [DESIGN] insert image in Write
Hi Simon, On 22 Feb 2011, at 19:02, Simon Schampijer wrote: > Hi Gary, > > a small design question regarding inserting an image in the Write document: > it took me a while to figure out where the option is - it is currently placed > under the table toolbar. However you can insert an image in the document or a > table. > > Do you maybe have ideas for a better fit for that icon? H, this was the best choice at the time given all the existing features needing a home in the toolbar, it was a tough call. If you're getting deployment feedback that it is a primary function*, consider removing all (at least two but maybe more) of the primary toolbar separators, fix the invisible separator that pushes the Stop icon to the right** and then move the insert image icon up the the primary toolbar. I fear you'll find that Write look even more scary and complicated, so be really sure inserting images is considered a primary use feature, or possibly taking some other tool/s off the primary toolbar (e.g. bold, italic, and underline could move into the text font secondary toolbar). * FWIW I used to find inserting images somewhat unsafe in Write, sometimes messing up the text layout even after removing the image, low memory issues/crashes, frustratingly slow screen refreshes, frequent crashed during collaboration; make sure use of images is well tested by a deployment if this becomes a primary Write feature! ** the default invisible separator eats up space and will cause the Stop icon to fall off the toolbar on XO size screens, look at Calculate source for the fix. Sorry, no easy choices with such an already feature busy activity ;) --Gary > Regards, > Simon > ___ > Sugar-devel mailing list > Sugar-devel@lists.sugarlabs.org > http://lists.sugarlabs.org/listinfo/sugar-devel ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [PATCH] Don't set default timezone
On 02/22/2011 02:07 AM, Sascha Silbe wrote: Excerpts from Daniel Drake's message of Mon Feb 21 23:22:11 +0100 2011: Drop the text value from the default gconf schema. This allows the systemwide timezone to be used as a default. Sugar users can still make their own choice (overriding the systemwide default) in the control panel. Acked-by: Sascha Silbe Please don't push yet; I'll merge your patch once we split off sucrose-0.92. Sascha For me it is ok to let the patch in 0.92 is a simple bugfix in the end. Regards, Simon ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [DESIGN] insert image in Write
On Tue, Feb 22, 2011 at 2:02 PM, Simon Schampijer wrote: > Hi Gary, > > a small design question regarding inserting an image in the Write document: > it took me a while to figure out where the option is - it is currently > placed under the table toolbar. However you can insert an image in the > document or a table. > > Do you maybe have ideas for a better fit for that icon? > > Regards, > Simon Yes, The 'Eye' icon can be easily confused with the Record media activity. It might be re-purposed generally for media controls, which would be a good place for the image insert icon, and the view controls could be moved to the activity sub-toolbar. This also makes more room on the Browse main toolbar. http://wiki.sugarlabs.org/go/Design_Team/Proposals/Toolbars --Fred ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [ASLO] Release Blocku-3
Activity Homepage: http://activities.sugarlabs.org/addon/4399 Sugar Platform: 0.82 - 0.90 Download Now: http://activities.sugarlabs.org/downloads/file/27231/blocku-3.xo Release notes: Initial release. Version 1.0. Custom game mode now fully works. Other various bug fixes. Has basic localization support. Sugar Labs Activities http://activities.sugarlabs.org ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [DESIGN] insert image in Write
Hi Gary, a small design question regarding inserting an image in the Write document: it took me a while to figure out where the option is - it is currently placed under the table toolbar. However you can insert an image in the document or a table. Do you maybe have ideas for a better fit for that icon? Regards, Simon ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [PATCH sugar] Convert Journal entries that have been saved to a storage device pre 0.84
Converts the entries to the new format [1] when the device is plugged into the machine. [1] http://wiki.sugarlabs.org/go/Features/Journal_Entry_Sharing --- src/jarabe/journal/volumestoolbar.py | 132 +- 1 files changed, 131 insertions(+), 1 deletions(-) diff --git a/src/jarabe/journal/volumestoolbar.py b/src/jarabe/journal/volumestoolbar.py index 2d842f1..72b5918 100644 --- a/src/jarabe/journal/volumestoolbar.py +++ b/src/jarabe/journal/volumestoolbar.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007, One Laptop Per Child +# Copyright (C) 2007, 2011, One Laptop Per Child # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,6 +23,11 @@ import gobject import gio import gtk import gconf +import cPickle +import xapian +import simplejson +import tempfile +import shutil from sugar.graphics.radiotoolbutton import RadioToolButton from sugar.graphics.palette import Palette @@ -33,6 +38,126 @@ from jarabe.journal import model from jarabe.view.palettes import VolumePalette +_JOURNAL_0_METADATA_DIR = '.olpc.store' + + +def _get_id(document): +"""Get the ID for the document in the xapian database.""" +tl = document.termlist() +try: +term = tl.skip_to('Q').term +if len(term) == 0 or term[0] != 'Q': +return None +return term[1:] +except StopIteration: +return None + + +def _convert_entries(root): +"""Convert entries written by the datastore version 0. + +The metadata and the preview will be written using the new +scheme for writing Journal entries to removable storage +devices. + +- entries that do not have an associated file are not +converted. +- if an entry has no title we set it to Untitled and rename +the file accordingly, taking care of creating a unique +filename + +""" +try: +database = xapian.Database(os.path.join(root, _JOURNAL_0_METADATA_DIR, +'index')) +except xapian.DatabaseError: +logging.exception('Convert DS-0 Journal entries: error reading db: %s', + os.path.join(root, _JOURNAL_0_METADATA_DIR, 'index')) +return + +metadata_dir_path = os.path.join(root, model.JOURNAL_METADATA_DIR) +if not os.path.exists(metadata_dir_path): +try: +os.mkdir(metadata_dir_path) +except EnvironmentError: +logging.error('Convert DS-0 Journal entries: ' + 'error creating the Journal metadata directory.') +return + +for posting_item in database.postlist(''): +try: +document = database.get_document(posting_item.docid) +except xapian.DocNotFoundError, e: +logging.debug('Convert DS-0 Journal entries: error getting ' + 'document %s: %s', posting_item.docid, e) +continue +_convert_entry(root, document) + + +def _convert_entry(root, document): +try: +metadata_loaded = cPickle.loads(document.get_data()) +except cPickle.PickleError, e: +logging.debug('Convert DS-0 Journal entries: ' + 'error converting metadata: %s', e) +return + +if not ('activity_id' in metadata_loaded and +'mime_type' in metadata_loaded and +'title' in metadata_loaded): +return + +metadata = {} + +uid = _get_id(document) +if uid is None: +return + +for key, value in metadata_loaded.items(): +metadata[str(key)] = str(value[0]) + +if 'uid' not in metadata: +metadata['uid'] = uid + +filename = metadata.pop('filename', None) +if not filename: +return +if not os.path.exists(os.path.join(root, filename)): +return + +if not metadata.get('title'): +metadata['title'] = _('Untitled') +fn = model.get_file_name(metadata['title'], + metadata['mime_type']) +new_filename = model.get_unique_file_name(root, fn) +os.rename(os.path.join(root, filename), + os.path.join(root, new_filename)) +filename = new_filename + +preview_path = os.path.join(root, _JOURNAL_0_METADATA_DIR, +'preview', uid) +if os.path.exists(preview_path): +preview_fname = filename + '.preview' +new_preview_path = os.path.join(root, +model.JOURNAL_METADATA_DIR, +preview_fname) +if not os.path.exists(new_preview_path): +shutil.copy(preview_path, new_preview_path) + +metadata_fname = filename + '.metadata' +metadata_path = os.path.join(root, model.JOURNAL_METADATA_DIR, + metadata_fname) +if not os.path.exists(metadata_path): +(fh, fn) = tempfile.mkstemp(dir=root
Re: [Sugar-devel] [PATCH] Convert Journal entries that have been saved to a storage device in 0.82
On 02/19/2011 02:13 PM, Sascha Silbe wrote: Excerpts from Simon Schampijer's message of Mon Feb 14 23:04:42 +0100 2011: [src/jarabe/journal/volumestoolbar.py] +import cPickle I was about to suggest "import cPickle as pickle" instead, but can't find anything in the docs to back up my preference. Yes, I looked that up as well, but kept it like that, it is the module name in the end [1]. [1] http://docs.python.org/library/pickle.html +import json Like for the other patch we should use simplejson for 0.92. Yes, done. [_get_id()] +"""Get the ID for the document in the xapian database.""" +tl = document.termlist() +try: +term = tl.skip_to('Q').term +if len(term) == 0 or term[0] != 'Q': +return None +return term[1:] +except StopIteration: +return None The old data store contains code with a very similar function that's more succinct: def get_all_ids(self): return [ti.term[1:] for ti in self.read_index._index.allterms('Q')] Is there a noticable performance benefit from using skip_to() instead of allterms()? Hmmm, I actually have the code from the old DS. I did not do performance tests on it. [_convert_entries()] +"""Converts the entries written by the datastore version 0. +The metadata and the preview will be written using the new +scheme for writing Journal entries to removable storage +devices. PEP 257. ;) Done. +try: +database = xapian.Database(os.path.join(root, _JOURNAL_0_METADATA_DIR, +'index')) +except xapian.DatabaseError, e: +logging.error('Convert DS-0 Journal entry. Error reading db: %s', + os.path.join(root, _JOURNAL_0_METADATA_DIR, 'index')) +return How about: "Error reading Xapian data base written by pre-0.84 data store"? And s/error/exception/ so we log the full error. "e" can be dropped. Dropped the e and the s/error/exception/. The error messages all have the same format (starting with: 'Convert DS-0 Journal entries:') and reflect the name of the functions as well. So I would like to keep them or we should change them all. +metadata_dir_path = os.path.join(root, model.JOURNAL_METADATA_DIR) +if not os.path.exists(metadata_dir_path): +os.mkdir(metadata_dir_path) We need to catch EnvironmentError. Done. +for i in range(1, database.get_lastdocid() + 1): +try: +document = database.get_document(i) +except xapian.DocNotFoundError, e: +logging.debug('Convert DS-0 Journal entry. ' \ + 'Error getting document %s: %s', i, e) +continue Since Xapian 1.0.0 [1] there's a better way [2]: for posting_item in database.postlist(''): document = database.get(posting_item.docid) Done. Since all we need below this point (and inside the loop) is document, this is a good place to start a new function (_convert_entry()). Gets rid of one level of indentation (for the code inside the new function). Done. +try: +metadata_loaded = cPickle.loads(document.get_data()) +except cPickle.PickleError, e: +logging.debug('Convert DS-0 Journal entry. ' \ + 'Error converting metadata: %s', e) +continue > Should be at least warning. Maybe even exception (i.e. error). Backslash isn't necessary; indentation doesn't match (proportional font?). Since we don't fail and keep on iterating through the items I think that a debug message is enough. I wanted this code to be a 'try to convert if possible' approach what I want to reflect in the priority level for the messages as well. +if 'activity_id' in metadata_loaded and \ +'mime_type' in metadata_loaded and \ +'title' in metadata_loaded: A good opportunity for using guardian style again to get rid of one level of indentation: Done. for property in ['activity_id', 'mime_type', 'title']: if property not in metadata_loaded: return +metadata = {} + +uid = _get_id(document) +if uid is None: +continue + +for key, value in metadata_loaded.items(): +metadata[str(key)] = str(value[0]) What exactly does the JSON look like? (I can't easily tell from the source) Here is an example of the metadata: metadata={'activity_id': [dbus.String(u'82ed9018485d6c4d2e8227e737747e8946b6')], 'title_set_by_user': [dbus.String(u\ '0')], 'vid': ['1.0'], 'title': [dbus.String(u'Write Activity')], 'timestamp': ['1293567361'], 'mtime': ['1293567361.0'], dbus.String(u'share-scope'): [dbus\ .String(u'private')], 'filename': [u'Write Activity.odt'], 'icon-color': [dbus.String(u'#FF2B34,#F8E800')], 'activity': [dbus.String(u'org.laptop.AbiWordAct\ ivity')], dbus.String(u'suggested_filename'): [dbus.String(u'Write
[Sugar-devel] [ASLO] Release Follow Me-14
Activity Homepage: http://activities.sugarlabs.org/addon/4354 Sugar Platform: 0.82 - 0.90 Download Now: http://activities.sugarlabs.org/downloads/file/27230/follow_me-14.xo Release notes: * Fully and properly implements the sugar arrow pointer. Sugar Labs Activities http://activities.sugarlabs.org ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [PATCH] Don't set default timezone
On 22 February 2011 07:07, Sascha Silbe wrote: > Please don't push yet; I'll merge your patch once we split off > sucrose-0.92. Why is that? Isn't it suitable for master? ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel