[Sugar-devel] Speak answering maths questions

2010-05-29 Thread Tim McNamara
Hi all,

*About*
This email is asking for feedback on different alternatives of implementing
a feedback request. It also goes through a lot of thought processes that
have resulted in my preferred suggestion.

This is mainly addressed at Sugar devs, but thought Alastair  Grant from
Wellington this morning might be interested.


*Background  = User story*
This morning while we were testing with some parents, the question came up
whether Speak could respond to maths problems, e.g. if you entered 10+2,
would speak respond with 12?


*First thoughts*
I thought this was quite a neat suggestion and have encountered a few ways
to implement it. To start with, I thought a smart way to indicate that you
wanted Speak to tell you an answer would be to use the equals sign after
maths. That leads to a construction like this:

if text.rstrip()[-1:] == '=':
try:
text = str(eval(text.rstrip()[:-1]))
except:
# SyntaxError is called when eval can't handle the input,
# but I think we should obscure all errors
pass

We need to convert the result of the eval to a string because speaking seems
to get confused when it encounters an integer. The practical result of the
code above is to produce results similar to this below:

 text = '3+4= '
 str(eval(text.rstrip()[:-1]))
'7'

One problem with this approach is integer division. Speak I am not quite
sure yet how to simply convert all integers within text to floats and keep
things succint  snappy. I thought it would be better to bring something
back to the list and have a chat about trade offs.

Also, what do people think about the risks of exposing eval() to users? My
thoughts are that as we're forcing an '=' to be at the end of the string, it
will always result in SyntaxErrors. if something dangerous is attempted to
be evaluated.

 eval('str')
type 'str'

vs.

 eval('str=')
Traceback (most recent call last):
  File stdin, line 1, in module
  File string, line 1
str=
  ^
SyntaxError: unexpected EOF while parsing


Even so, is there a simple way to expose mathematical operators but prevent
calls to functions  methods?

*Where to implement?*

The easiest place for the user would be to be agnostic of mode [1]. E.g.
whenever an equals sign appears at the end, try to answer the maths and say
the result.

it is very easy to tel someone 'add an equals sign at the end'. However,
since we have a Robot mode, it's probably best to throw it in there [2].
However, it's probably best for code maintenance to put the evaluation in
the 'brain.py', rather than in the voice, so that's where solution [3] puts
it.

[1] activity.py trunk:377

Will evaluate maths problems agnostic of mode:

def _entry_activate_cb(self, entry):
# the user pressed Return, say the text and clear it out
text = entry.props.text.rstrip()
maths_problem = False
if text:
self.face.look_ahead()

# solve the maths problem
if text[-1:] == '=':
try:
text = str(eval(text[:-1]))
maths_problem = True
except:
pass

# speak the text
if self._mode == MODE_BOT and not maths_problem:
self.face.say(
brain.respond(self.voices.props.value, text))
else:
self.face.say(text)

[2] activity.py trunk:377

Will evaluate maths only if we're in robot mode

def _entry_activate_cb(self, entry):
# the user pressed Return, say the text and clear it out
text = entry.props.text.rstrip()
if text:
self.face.look_ahead()

# speak the text
if self._mode == MODE_BOT:
if text[-1:] == '=':
try:
text = str(eval(text[:-1]))
except:
self.face.say(text)
self.face.say(
brain.respond(self.voices.props.value, text))
else:
self.face.say(text)


[3] brain.py trunk:66:

Moving the logic from [2], to the brain of the program.

def respond(voice, text):
if text.rstrip()[-1:] == '=':
try:
text = str(eval(text.rstrip()[:-1]))
except:
pass

if _kernel is None:
return text
else:
return _kernel.respond(text)

*Summary*

I personally prefer [1] because it means that you don't need to change
modes. However, that does mean we're overloading the default speech mode. If
there's no support, then [3] is probably be the best way to keep logic in
the right place.

Thanks
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Chat sharing errors

2010-05-29 Thread Peter Robinson
On Fri, May 28, 2010 at 7:51 PM, Thomas C Gilliard
satel...@bendbroadband.com wrote:


 I just connected wirelessly

 1- ) Mirabelle USB
 Started Chat as shared in Mirabelle
 2- )Blueberry.vmx
 Joined
 3- ) XO-1 os230py  (Sugar 0.88.0)
 Joined


 XO-1 saw all connections colors and text
 Blueberry saw 1/2 of connections with color balance were  plus text
 Mirabelle saw only its own broadcasts in color all others were ?plus
 text

 Is Mirabelle configured to require the Gadget Service?

What is the gadget service?

Peter
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] ANNOUNCE: Sugar 0.88 for the XO-1

2010-05-29 Thread forster
os240py

font in Write is small and text does not fill the screen width
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] hulahop

2010-05-29 Thread Stefan George
Hi,

 

 

 

I would like to load a Website into the WebView(). This Website has some
Javascript that manipulates the dom after loading the website.

 

 

 

Do I get this manipulated dom If I get the dom wv.get_dom_window() to
proceed it with python? Would that be possible?

 

 

 

My Idea is to use the readability (
http://lab.arc90.com/experiments/readability/
http://lab.arc90.com/experiments/readability/ 
http://lab.arc90.com/experiments/readability/
http://lab.arc90.com/experiments/readability/ ) script this way. To load a
website with readability and extract the converted HTML into python.

 

 

 

Thanks for your replies,

 

 

 

Stefan

 

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Support for EPUB with Read in sugar-jhbuild?

2010-05-29 Thread James Simmons
Sayamindu,

I'm still working on my e-book book and not being able to read EPUBs
in Read under sugar-jhbuild has become a blocker for me.  I'm trying
to figure out what's wrong but print statements don't seem to ever
come out.  The only clue I've got is the stack trace I already sent to
you.

The code that runs the method that's failing looks like this:

mimetype = mime.get_for_file(filepath)
if mimetype == 'application/epub+zip':
if not _EPUB_SUPPORT:
self.close()
self._epub = True
self._setup_epub_viewer()
self._document = epubadapter.EpubDocument(self._view,
filepath.replace('file://', ''))
else:
self._setup_evince_viewer()
try:
self._document = evince.factory_get_document(filepath)
except GError, e:
_logger.error('Can not load document: %s', e)
return

I don't know what self.close() does.  It isn't enough to stop the
lines following from running and failing.

I did notice one odd thing.  epubpadapter.py is in the same directory
as readactivity.py, but epubadapter does an import of epubview and
that file is NOT in the same directory, but in a subdirectory called
epubview.  So that might be someting.

James Simmons


On Mon, Apr 26, 2010 at 3:04 PM, Sayamindu Dasgupta sayami...@gmail.com wrote:
 On Mon, Apr 26, 2010 at 1:12 AM, James Simmons nices...@gmail.com wrote:
 Sayamindu,

 I installed pywebkitgtk on Fedora 11 and I still get this when trying
 to read an EPUB using sugar-jhbuild:

 Traceback (most recent call last):
  File 
 /home/jim/sugar-jhbuild/install/lib/python2.6/site-packages/sugar/activity/activity.py,
 line 437, in __canvas_map_cb
    self.read_file(self._jobject.file_path)
  File 
 /home/jim/sugar-jhbuild/install/share/sugar/activities/Read.activity/readactivity.py,
 line 595, in read_file
    self._load_document('file://' + self._tempfile)
  File 
 /home/jim/sugar-jhbuild/install/share/sugar/activities/Read.activity/readactivity.py,
 line 796, in _load_document
    self._setup_epub_viewer()
  File 
 /home/jim/sugar-jhbuild/install/share/sugar/activities/Read.activity/readactivity.py,
 line 760, in _setup_epub_viewer
    self._view = epubadapter.View()
 NameError: global name 'epubadapter' is not defined

 This looks pretty much like what I was getting yesterday before I
 installed pywebkitgtk.

 James Simmons


 This is quite odd - it works fine for me. Read uses git submodules,
 but epubadapter.py is not a part of any submodule. Could you check if
 the epubadapter.py is getting installed or not ?

 Thanks,
 Sayamindu



 On Sun, Apr 25, 2010 at 11:56 AM, Sayamindu Dasgupta
 sayami...@gmail.com wrote:
 Hi,

 On Sun, Apr 25, 2010 at 8:51 AM, James Simmons nices...@gmail.com wrote:
 I'm doing another FLOSS Manual on e-books and Sugar and one of the
 things I'd like to do is get some screen shots of the Read Activity
 reading an EPUB e-book.  I modified Get Internet Archive Books to
 download EPUBs and that seems to work OK, but when I try to launch
 Read on one of them it fails to start and complains of a missing
 adapter.  As I remember it, EPUB support depended on something called
 webkit, something like that, that was an alternative to gecko.  There
 was some discussion here on whether we should support both that and
 gecko.  So I have two questions:

 1). How do I get Read as delivered by sugar-jhbuld to work with EPUBs?

 2). Does Read support EPUBs on SoaS right now?  If not, what are our
 future plans regarding EPUB support?


 Read should be able to render EPUB files if pywebkitgtk is installed.
 Thanks,
 Sayamindu


 --
 Sayamindu Dasgupta
 [http://sayamindu.randomink.org/ramblings]
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Speak answering maths questions

2010-05-29 Thread Chris Ball
Hi Tim,

I'd suggest looking at the parsing logic in the Calculate activity --
it deals with the same problems.

- Chris.
-- 
Chris Ball   c...@laptop.org
One Laptop Per Child
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] hulahop

2010-05-29 Thread Lucian Branescu
Yes, you can access the DOM from python. Google for extra info. If you
can't find anything, I did something similar in my last year's
project, which you can find here
http://git.sugarlabs.org/projects/browse/repos/lucians-ssb/trees/master

Look at usercode.py

On 29 May 2010 11:26, Stefan George stefan.geo...@genesisware.com wrote:
 Hi,







 I would like to load a Website into the WebView(). This Website has some
 Javascript that manipulates the dom after loading the website.







 Do I get this manipulated dom If I get the dom wv.get_dom_window() to
 proceed it with python? Would that be possible?







 My Idea is to use the readability
 (http://lab.arc90.com/experiments/readability/
 http://lab.arc90.com/experiments/readability/ ) script this way. To load a
 website with readability and extract the converted HTML into python.







 Thanks for your replies,







 Stefan



 ___
 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] [Sugar-Devel] Sugar Web Engine

2010-05-29 Thread Lucian Branescu
In case you don't already know, I'm doing a GSoC project on improving
the browser engine situation in Sugar
http://wiki.sugarlabs.org/go/Summer_of_Code/2010/AbstractBrowser

My exams haven't finished yet (last one on Wednesday), so before I
start working, I want the opinion of people that use web engines in
sugar applications or that are otherwise interested in web engines for
sugar on how to proceed.

I'd like answers to questions like Should I drop hulahop and focus on
webkit? or Is an API like hulahop's nice?, etc.

I'd like to set up a meeting on #sugar-meeting on Monday between 9 AM
and 9 PM GMT, depending on the availability of attendees.

Individual chats/ml are also welcome, but an IRC meeting would be ideal.
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] Patch: Paint ticket OLPC #3695

2010-05-29 Thread Gonzalo Odiard
Use radio button to see the tool you are using.

--
Gonzalo


0001-fix-OLPC-3695.patch
Description: Binary data
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel