Re: [Sugar-devel] [PATCH] Calculate/functions.py
On 3 June 2010 16:00, James Cameron qu...@laptop.org wrote: On Thu, Jun 03, 2010 at 03:51:46PM +1200, Tim McNamara wrote: Thanks for taking the time to review that patch. But wait, there's more. Tested-by: James Cameron qu...@laptop.org shift_right() also mentions self on the argument list, which stops it from working right. After that is fixed, shift_left() and shift_right() are usable in Calculate. Applied. Tim diff --git a/functions.py b/functions.py index ddc1088..b101a4c 100644 --- a/functions.py +++ b/functions.py @@ -1,3 +1,5 @@ +#!/usr/bin/python + # functions.py, functions available in Calculate, # by Reinier Heeres rein...@heeres.eu # @@ -14,14 +16,20 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +''' +Functions library for the Calculate Activity. + +The functions module is designed to be added as a plugin for the +Calculate Activity's astparser.AstParser class. -# Any variable or function in this module that does not start with an -# underscore ('_') will be available in Calculate through astparser.py. -# Docstrings will automatically be added to the help index for that function. -# However, instead of setting the docstring on a function in the simple way we -# add it after the function definition so that they can more easily be -# localized through gettext. +Variables and functions that do not start with an underscore ('_') +will be available in Calculate through astparser.py. +Docstrings will automatically be added to the help index for that function. +However, instead of setting the docstring on a function in the simple way we +add it after the function definition so that they can more easily be +localized through gettext. +''' import types import math import random @@ -67,10 +75,10 @@ _FUNCTIONS = [ _('tan'), _('tanh'), _('xor'), -] +] def _d(val): -'''Return a _Decimal object.''' +'''Returns a _Decimal object, an alias of decimal.Decimal.''' if isinstance(val, _Decimal): return val @@ -94,79 +102,180 @@ def _inv_scale_angle(x): return x / _angle_scaling def abs(x): + +Calculates the absolute value of x in floating point. +When x is less than 0, it returns -x. + + abs(10) +10.0 + abs(_Decimal(-10)) +10.0 + return math.fabs(x) -abs.__doc__ = _( -'abs(x), return absolute value of x, which means -x for x 0') +abs.__doc__ = _(abs.__doc__) def acos(x): + +Calculates the arc cosine of x. + +The arc cosine of x is the angle for which the cosine is x. + + acos(-0.2) +1.7721542475852274 + acos(_Decimal('-0.20')) +1.7721542475852274 + +x must be between -1 and 1. + acos(20) +Traceback (most recent call last): +... +ValueError: math domain error + return _inv_scale_angle(math.acos(x)) -acos.__doc__ = _( -'acos(x), return the arc cosine of x. This is the angle for which the cosine \ -is x. Defined for -1 = x 1') +acos.__doc__ = _(acos.__doc__) def acosh(x): + +Calculates the arc hyperbolic cosine of x. + +This is the value y for which the hyperbolic cosine equals x.' + + acosh(20) +3.6882538673612966 + acosh(20.0) +3.6882538673612966 + acosh(_Decimal('20.0')) +3.6882538673612966 + return math.acosh(x) -acosh.__doc__ = _( -'acosh(x), return the arc hyperbolic cosine of x. This is the value y for \ -which the hyperbolic cosine equals x.') +acosh.__doc__ = _(acosh.__doc__) def And(x, y): + +Logical Boolean operator and. + +Returns True if both x and y evaluate to True, +otherwise it returns False. + + And(True, True) +True + And(False, False) +False + And(True, False) +False + And(False, True) +False + return x y -And.__doc__ = _( -'And(x, y), logical and. Returns True if x and y are True, else returns False') +And.__doc__ = _(And.__doc__) def add(x, y): + +Adds x and y, returning their sum. + +If either of the varibles is an instance of decimal.Decimal, +the function will coerce the other to be that type. + if isinstance(x, _Decimal) or isinstance(y, _Decimal): x = _d(x) y = _d(y) return x + y -add.__doc__ = _('add(x, y), return x + y') +add.__doc__ = _(add.__doc__) def asin(x): + +Calculates the arc sine of x. + +This is the angle for which the sine is ix. +Accepts an x value of -1 to 1. + + asin(_Decimal('-0.20')) +-0.2013579207903308 + asin(_Decimal('-020')) +Traceback (most recent call last): +... +ValueError: math domain error + return _inv_scale_angle(math.asin(x)) -asin.__doc__ = _( -'asin(x), return the arc sine of x. This is the angle for which the sine is ix. \ -Defined for -1 = x = 1') +asin.__doc__ = _(asin.__doc__) def
[Sugar-devel] [ASLO] Release Our Music MC-4
Activity Homepage: http://activities.sugarlabs.org/addon/4227 Sugar Platform: 0.84 - 0.88 Download Now: http://activities.sugarlabs.org/downloads/file/26928/ourmusicmc-4.xo Release notes: Correction to auto default font sizing 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] [ASLO] Release Our Music-4
Activity Homepage: http://activities.sugarlabs.org/addon/4226 Sugar Platform: 0.82 - 0.88 Download Now: http://activities.sugarlabs.org/downloads/file/26927/ourmusic-4.xo Release notes: Correction to auto default font sizing 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] Paint : avoid line size 1
On Wed, Jun 02, 2010 at 08:11:37PM -0300, Gonzalo Odiard wrote: From 86d4934c0cab8c00482cb9644fd92bcdee660de8 Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard godi...@gmail.com Date: Wed, 2 Jun 2010 20:11:29 -0300 Subject: [PATCH] avoid line size 1 Reviewed-by: James Cameron qu...@laptop.org -- 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] [Tecnologia] More Sugar 0.88 bugs to work on
El Wed, 02-06-2010 a las 21:43 +0200, Tomeu Vizoso escribió: Are you sure this isn't only on the emulator case? Oh, yeah... this is where I had seen it. And, sadly, there are no better alternatives to wait for X to come up. Even xinit resorts to polling with a short delay. -- // Bernie Innocenti - http://codewiz.org/ \X/ Sugar Labs - http://sugarlabs.org/ ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] review process changes
El Thu, 03-06-2010 a las 11:55 +1000, James Cameron escribió: I don't see a way to make each module a project. The Patchwork project sugar would have to encompass all Sugar modules and activities. Patchwork prevents me from adding another project paint that shares the same mailing list. Bernie, do you agree with my assessment of Patchwork in this respect? I don't know Patchwork well enough to tell. I've installed it on request of Andres and others, but quite frankly I don't feel any necessity to augment the traditional email workflow with a web application. To track patches addressed to me, I simply keep them marked as unread until I've taken action, like I would do with any other message. Other people may prefer to use the flag bit or custom tags. To find reviews and new versions of the same patch, I simply use threading in my email client. To help maintain correct threading, both git send-email and git format-patch provide an --in-reply-to option to specify the Message-Id of the review. To help distinguish among several projects in the same mailing-list, git-format-patch provides a handy --subject-prefix option which we can set to sugar-toolkit, sugar-artwork, and so on. In the rare case that a patch really falls through the crack, whoever posted can simply resend it after a few days, or ping. Note: it's important to specify the maintainer(s) as --to of the patch, plus the mailing-list as --cc. This is the complete workflow for submitters: 1) commit your changes git commit -s -v foo.py 2) create a patch git format-patch --subject-prefix=sugar-toolkit --in-reply-to=123456 -1 3) send patch to maintainer and mailing list git send-email --to erikos --cc sugar-devel 0001-foo.patch 4) wait for maintainer grant Acked-by tag while !acked(): sleep(1) 5) adjust patch to append any tags obtained (Reviewed-by, Tested-by, Acked-by...) git commit --amend 6) rebase and push to centralized repo git pull --rebase git push Steps 5-6 can be carried on by anyone. git-send-email can be fine-tuned for maximum comfort. This is my global .gitconfig: ---cut--- [sendemail] chainreplyto = false from = Bernie Innocenti ber...@codewiz.org aliasesfile = /home/bernie/.gitaliases aliasfiletype = mutt # requires a local SMTP server #smtpserver = /usr/sbin/sendmail # when smtp is blocked smtpserver = smtp.codewiz.org smtpuser = bernie smtpssl = true ---cut--- The .gitaliases is a big time saver. For Sugar, I have the following entries: ---cut--- alias silbe Sascha Silbe si...@sugarlabs.org alias tomeu Tomeu Vizoso to...@tomeuvizoso.net alias erikos Simon Schampijer si...@schampijer.de alias mstone Michael Stone mich...@laptop.org alias anish Anish Mangal anishmangal2...@gmail.com ---cut--- -- // Bernie Innocenti - http://codewiz.org/ \X/ Sugar Labs - http://sugarlabs.org/ ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [RELEASE] sugar-toolkit-0.88.1
== Source == http://download.sugarlabs.org/sources/sucrose/glucose/sugar-toolkit/sugar-toolkit-0.88.1.tar.bz2 == News == * Titel: bundlebuilder should not use locale name #1968 Author: Walter Bender * Title: Race condition with name widget in the activity toolbar #1948 Author: Aleksey Lim * Title: Cannot delete stalled download from journal #1987 Author: Aleksey Lim * Title: Japanese translations: 40 strings translated Author: Korakurider Thanks for all these great contributions! ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [RELEASE] sugar-0.88.1
== Source == http://download.sugarlabs.org/sources/sucrose/glucose/sugar/sugar-0.88.1.tar.bz2 == News == * keyboard control panel chokes on non-empty option group #2022 Sascha Silbe * once we fail to launch Xephyr, successive launches fail #1860 Tomeu Vizoso * Failure to cleanup temporary files after filesystem full errors #1876 Aleksey Lim * resume journal entry race may duplicate resumed activity id #1719 Aleksey Lim * sugar-emulator: better error message if X server is unreachable #1755 Sascha Silbe * doesn't automatically connect to network at startup anymore (on XO-1) #1883 Simon Schampijer * broken log statement in OlpcMeshManager._activate_connection() #1890 Sascha Silbe * Register menu item does not disappear after successful registration #1837 Kenny Meyer ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [RELEASE] sugar-artwork-0.88.1
== Source == http://download.sugarlabs.org/sources/sucrose/glucose/sugar-artwork/sugar-artwork-0.88.1.tar.bz2 == News == * GTK deprecated API troubles #1899 Aleksey Lim, Bernie Innocenti, Benjamin Berg ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [ANNOUNCE] Sucrose 0.88.1 Tarballs Due
Dear Sucrose Maintainers, please provide source tarballs for the Sucrose 0.88.1 bug fix release [1] by the end of today June 3rd and announce them as explained at [2]. This will be our first bug fix release, so please be extra careful to not introduce any regressions and have your changes well tested. Sorry about the late notice and don't worry if some fixes cannot make this one, we'll have more bug fix releases if needed. Thanks, Your Release Team [1] http://wiki.sugarlabs.org/go/0.88/Roadmap#Schedule [2] http://sugarlabs.org/go/Development_Team/Release#Module_release ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [PATCH] Pippy example - Koch snowflake
Hi, I've added a few new examples to Pippy. They're available in my repository ( http://git.sugarlabs.org/projects/pippy/repos/dgaletic-gsoc2010); I haven't made an .xo since I'm having some problems with my Sugar installation. Since this is about learning Python, in each of them I've tried to have several places where the learner is invited to modify come code. This one draws the Koch snowflake using pygame. The user can decrease/increase the number of triangles with left and right arrows. diff --git a/data/GSOC examples/Koch snowflake b/data/GSOC examples/Koch snowfla new file mode 100644 index 000..2fb218e --- /dev/null +++ b/data/GSOC examples/Koch snowflake @@ -0,0 +1,208 @@ +# This example draws a shape called the Koch snowflake. + +import pippy, pygame, sys +from pygame.locals import * +from random import * +import math + +# always need to init first thing +pygame.init() + +# XO screen is 1200x900 +size = width, height = 1200, 900 + +# create the window and keep track of the surface +# for drawing into +screen = pygame.display.set_mode(size) + +# turn off the cursor +pygame.mouse.set_visible(False) + + +# Set some variables. +# Snowflakes are white! +color = (255,255,255) + +# the center point of the screen +# We need it because we'll place out triangle around it. +center = width / 2, height / 2 + +# Side of an equilateral triangle (the one we start with). +# Here it is defined relative to the resolution of the screen. +# Practice: We could play with other values, absolute (like a = 100) or +# relative (a = height / 2, a = width / 3, etc). What looks best for you? +a = height/1.4 + +# Height of that triangle. +# Just a simple geometry formula, nothing Python-special about it. +h = int(a * math.sqrt(3) / 2) + +# These will be the vertices for the starting triangle. +# The triangle vertices are named like this: +# +#C +# / \ +# A _ B +# +A = center[0]- a/2, center[1] + h/3 +B = A[0] + a, A[1] +# To find the third point, we need slightly more advanced math. +# If you with to understand it, you could try finding some material about trigo +# We use the coordinates of vertice A to calculate where point C will be. +C = A[0] + math.cos(math.pi/3) * a, A[1] - math.sin(math.pi/3) * a + +# This class will allow us to store data about a line. +class Line(object): +def __init__(self, a = A, b = B): +# This is how a line object will remember its points and length. +self.A = a +self.B = b +self.points = [self.A, self.B] + +# We use the Pythagorean theorem to calculate the length of a line +# from the coordinates of its points. +self.length = math.sqrt( (a[0]-b[0])**2 + (a[1]-b[1])**2 ) + +# Projection of the line on the x axis. +# We use it to figure out the angle which the line closes with the x ax +projection_length = b[0] - a[0] + +# If the line is descending, the angle is negative. Trigonometry, again +if b[1] a[1]: +self.angle = -math.acos(projection_length / self.length) +else: +self.angle = math.acos(projection_length / self.length) + +# To draw new shapes, an old line must be split into its thirds. +def split(self): +third = self.length / 3.0 +self.D = self.A[0] + math.cos(self.angle) * third, \ + self.A[1] - math.sin(self.angle) * third +self.E = self.A[0] + math.cos(self.angle) * 2*third, \ + self.A[1] - math.sin(self.angle) * 2*third +self.points.append(self.D) +self.points.append(self.E) + +# Give a line (from which we'll need the coordinates of its starting point) and +# an angle, calculate the position of a new point - the vertex of out snowflake +# The length of its sides should be 1/3 of the length of the line from which +# it is made. +def calculate_new_point(line, angle): +p = line.D[0] + math.cos(angle + line.angle) * line.length / 3, \ +line.D[1] - math.sin(angle + line.angle) * line.length / 3 +return p + + +# The following function from a single line, like this: +# +# A___B +# +# creates four lines, like this: +# +# F +# A_D/ \E_B +# +def transform_line(line): +line.split() +C = calculate_new_point(line, math.pi/3) +line1 = Line(line.A, line.D) +line2 = Line(line.D, C) +line3 = Line(C, line.E) +line4 = Line(line.E, line. B) +lines = [line1, line2, line3, line4] +return lines + +# For each line in starting_lines, call transform_line(). +# Repeat depth times for each line created this way. +def produce_lines(starting_lines, depth): +all_lines = starting_lines +for i in range(depth): +new_lines = [] +for line in all_lines: + new_lines += transform_line(line) +# clearn the old lines first +all_lines = [] +all_lines = new_lines +return all_lines + +# Write the lines on screen. +def draw_lines(lines): +for line in lines: +pygame.draw.line(screen,
[Sugar-devel] [PATCH] Pippy example - Sierpinski triangle
This Python script draws the Sierpinski triangle. As with my Koch snowflake example, the user can modify the number of triangles using left and right arrows. diff --git a/data/GSOC examples/Sierpinski - graphics b/data/GSOC examples/Sierp new file mode 100644 index 000..449277a --- /dev/null +++ b/data/GSOC examples/Sierpinski - graphics @@ -0,0 +1,146 @@ +# This example draws what is called the Sierpinski triangle. +# First, one black triangle is created. +# After that it is removed and in its place three smaller black triangles are c +# which leaves a white hole (also shaped like a triangle, but upside down!) in +# +# This can continue for any number of steps - you can split the smaller +# triangles into even smaller ones and so on. +# We have, however, limited it to 8 to keep our computers from freezing due to +# too much calculations! If you change it to a higher number, that will probabl +# +# This code is similar to the code in Koch snowflake example so you +# could first go through that to understand this example better. + +import pippy, pygame, sys +from pygame.locals import * +from math import sin, cos +from math import pi as Pi + +class Triangle(object): +def __init__(self, first_vertex, length, displacement_angle = 0 ): +# remember your first vertex +self.A = first_vertex +# calculate the other two +self.B = self.A[0] + length * cos(Pi/3 + displacement_angle), \ + self.A[1] - length * sin(Pi/3 + displacement_angle) +self.C = self.A[0] + length * cos(displacement_angle), \ + self.A[1] - length * sin(displacement_angle) +# remember your length +self.length = length +# calculate the midpoints of each line +# m1 for AB, m2 for BC, m3 for CA +# m1 and m3 are calculated the same way as points B and C, but with +# half the length. +self.m1 = self.A[0] + length/2 * cos(Pi/3 + displacement_angle), \ + self.A[1] - length/2 * sin(Pi/3 + displacement_angle) +self.m3 = self.A[0] + length/2 * cos(displacement_angle), \ + self.A[1] - length/2 * sin(displacement_angle) +# m2 is 120 degrees (2*Pi/3) from C, half the length. +# ... but we don't actually need it for anything. +self.m2 = self.C[0] + length/2 * cos(2*Pi/3 + displacement_angle), \ + self.C[1] - length/2 * sin(2*Pi/3 + displacement_angle) + +# create three new triangles from yourself. +def split(self): +new_triangles = [] +new_triangles.append(Triangle(self.A, self.length/2)) +new_triangles.append(Triangle(self.m1, self.length/2)) +new_triangles.append(Triangle(self.m3, self.length/2)) +return new_triangles + +# This is how a triangle draws itself. +def draw(self, screen, color): +points = [self.A, self.B, self.C] +pygame.draw.polygon(screen, color, points) + +# always need to init first thing before drawing +pygame.init() + +# XO screen is 1200x900 +size = width, height = 1200, 800 + +# create the window and keep track of the surface +# for drawing into +screen = pygame.display.set_mode(size) + +# The font we'll use to display the current depth. +font_size = 36 +font = pygame.font.Font(None, font_size) + +black = (0, 0, 0) +white = (255, 255, 255) + +starting_point = (200, 750) +side_length = 800 + +t1 = Triangle(starting_point, side_length) +t2 = Triangle((800, 600), 150) + +depth = 0 + +all_triangles = [t1] +new_triangles = [] + +recalculate = False + +while pippy.pygame.next_frame(): +for event in pygame.event.get(): +if event.type == QUIT: +sys.exit() +# When R arrow is pressed, go one step further. +# This means splitting the existing triangle(s) into new ones. +# Note that all the triangles have to be recalculated before redrawn. +elif event.type == KEYDOWN and event.key == K_RIGHT and depth 8: +depth += 1 +recalculate = True +# When L arrow is pressed, go one step back, reducing the number of +# triangles. +# Note that all the triangles have to be recalculated before redrawn. +elif event.type == KEYDOWN and event.key == K_LEFT and depth 0: +depth -= 1 +recalculate = True +elif event.type == KEYDOWN: +sys.exit() +screen.fill(white) +# Display the current step. +msg = Step: + str(depth) + /8 +text = font.render(msg , True, black) +text_box = text.get_rect() +text_box.top = 130 +text_box.left = 50 +# Display the instructions +text2 = font.render(Use left and right arrows., True, black) +text_box2 = text2.get_rect() +text_box2.top = 100 +text_box2.left = 50 +# Write the instructions and the current step on the screen. +screen.blit(text, text_box) +screen.blit(text2, text_box2) + +# If the depth was changed (L or R pressed), recalculate
[Sugar-devel] [PATCH] Pippy example - Opening websites
This example covers some basic functionality of urllib2 - opening a website, reading from it and finding its title. diff --git a/data/GSOC examples/Opening websites b/data/GSOC examples/Opening we new file mode 100644 index 000..97ee16f --- /dev/null +++ b/data/GSOC examples/Opening websites @@ -0,0 +1,64 @@ +# This example demonstrates how urllib2 can be used to open websites and read +# some data from them. + +import urllib2 + +# define a function which will open a bunch of links we give it in a list +def open_sites(links): +sites = [] +for url in urls: +print Opening: + url +# try to open that site +try: +site = urllib2.urlopen(url) +except: +# Does an error occur with any of the default urls? +# Practice: If so, could you fix it? +print An error has occured, skipping + url +print +raw_input(...press enter key to continue...) +continue +if site.geturl() != url: +print Careful! Site + url + has redirected you to + site.get +print Site + site.geturl() + is now open. +print +sites.append(site) +raw_input(...press enter key to continue...) +print +return sites + +url1 = http://www.google.com; +url2 = http://www.sugarlabs.org; +url3 = www.wikipedia.org +urls = [url1, url2, url3] + +sites = open_sites(urls) + +print +print Let's read those sites and find their titles. +print +raw_input(...press enter key to continue...) +print + +for site in sites: +site_content = site.read() +title_at = site_content.find(title) + 7 +print The title of site at + site.geturl() + begins at its index + s +title_ends = site_content.find(/title, title_at) +title = site_content[title_at:title_ends] +# In Python, \ is the so-called escape character. Since some characters h +# special meanings, like or ' opening and closing a string, we have to te +# the interpreter to ignore such meanings when we wish to put those precise +# characters in a string (or print them). In the following line, we wish to +# print the character so we escape it - by putting \ in before it. +# Practice: What would we have to do to print an escape character \ ? +print The title is: \ + title + \ +print +# An index of -1 refers to the first element from the end. Thus, this +# comparison checks whether the current element is the last one. +# Practice: Why would we want that? +if site == sites[-1]: +raw_input(...press enter to finish..:) +else: +raw_input(...press enter key to continue...) +print ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [PATCH] Pippy example - multiplication table
This example neatly prints the multiplication table with dimensions the user entered. diff --git a/data/GSOC examples/multiplication table b/data/GSOC examples/multip new file mode 100644 index 000..4601f01 --- /dev/null +++ b/data/GSOC examples/multiplication table @@ -0,0 +1,69 @@ +import time +import os + +print This will draw the multiplication table with dimensions of your choice. +print Feel free to modify and drawing speed and other variables. + +# how many numbers per second? Default is 5. +drawing_speed = 5 + +# raw_input() will get whatever text you enter with your keyboard. +# int() will give an error if it can't turn that text into a number. +try: +print How many numbers wide? +x = int(raw_input()) + +print How many numbers high? +y = int(raw_input()) +# If there's an error in the try: block of code, the following will happen. +# The program will print an error message and quit. +except: +print That is not a valid number. +sys.exit() + +# In case everything went well, the program didn't quit and is now here. +# The following will create two lists of numbers, each starting with 1 and +# ending with whatever you entered as x (row list) and y (column list). +# Practice: By default, both lists start with 1. What if we changed that? +row = range(1, x+1) +column = range(1, y+1) + +# From now on, everything we want to print on the screen we'll store +# in the output variable. First we make it an empty string, and then add to i +# whatever we want to print. +output = +# the first printed line, for decoration: +# add the beginning of it +output += |---|-- +# for each number in a row, add eight dashes and mark the end of line with \n +# \n is called a 'newline' and it makes your console start writing a new line. +output += len(row) * +\n +# What the second line starts with. \t marks one tab. +output += |\t|\t + +# Now, we would like to print the first row of numbers, which +# represent the factors we'll multiply. Add each number from row +# to the output string. str(number) turns a number to characters +# (like number 42 to characters '4' and '2') +for number in row: +output += str(number) + \t + +# add another decorative line +output += \n + |---|-- + len(row) * + \n + +# for each number in the first column, multiply it with each number in the +# first row. One by one, add the results to output and print it. +for factor1 in column: +output += |+ str(factor1) + \t|\t +for factor2 in row: +output += str(factor1*factor2) + \t +# clear the screen from what was last printed (old output) so +# we can print the new output (with one result added) +os.system('clear') +print output +# Pause the program. If drawing_speed is 5, it will pause for +# 1/5 seconds (0.2 seconds), which gives us five characters +# per seconds. +time.sleep(1.0 / drawing_speed) +# mark the end of the line +output += \n ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [PATCH] Pippy example - file writing and reading
This example demonstrates some basic text file reading and writing. diff --git a/data/GSOC examples/file writing and reading b/data/GSOC examples/fi new file mode 100644 index 000..13b7436 --- /dev/null +++ b/data/GSOC examples/file writing and reading @@ -0,0 +1,41 @@ +import time + +print This example demonstrates how to create a text file, write something to + +print How shall we call the file? +filename = raw_input() + +print Where would you like to store the file? (can be left empty) +# Practice: Where does the file get stored if we leave this empty? +directory = raw_input() + +full_name = directory + filename + +print Please enter the text you would like to store. +text = raw_input() + +# Open the file in the write mode. +my_file = open(full_name, w) + +# Let's write the current time to that file. +# \n is the way of saying i'm finished with that line, move to the next one. +current_time = time.ctime() +my_file.write(The following text was written at: + current_time + \n) + +# Write our text to the open file. +my_file.write(text) +my_file.write(\n) + +# Close the file. +my_file.close() + +# Now lets read from that same file. This is how reading is done. +# First: Open the file in read mode. +my_file = open(full_name, r) +# Second: Read from it. +from_file = my_file.read() +# Third: Close the file. +my_file.close() + +# Print what we've read. +print from_file ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [PATCH] Pippy example - birthday reminder
This example works as a birthday reminder. It demonstrates the use of dictionaries and several other things (like functions) already covered in the existing examples, but now put in a larger program. PS. I now notice I've pushed this code with switch in comments instead of if-else, I'll change that. Dinko Galetic diff --git a/data/GSOC examples/birthday reminder b/data/GSOC examples/birthday new file mode 100644 index 000..eca9458 --- /dev/null +++ b/data/GSOC examples/birthday reminder @@ -0,0 +1,201 @@ +# The purpose of this example is to demonstrate what is a dictionary in Python. +# This will also cover: +# functions, +# switch, and +# writing to text files. + + +# This function adds a birthday to the list of birthdays. +# Simple, isn't it? +# There's one flaw, though: In case we've already stored the data for that +# person, it will overwrite that data. +def add_birthday(person, day, birthdays): +birthdays[person] = day + +# This does the same as the previous function, but checks if we already have +# the birthday of that person remembered and warns us in that case. +# Practice: This function is not used in this example, only defined. +# Could you change the code so that it is used instead of +# the default add_birthday function? +def add_birthday_safer(person, day, birthdays): +if birthdays.has_key(person): +print You've already entered + person + 's birthday as:, +print birthdays[person] +print Would you like to overwrite that with + day + (y/n)? +response = raw_input(Response: ) +# Practice: Add some more possible answers (like with capital letters) +if response == n or response == no: +# return marks the end of the function +return +else: +birthdays[person] = day + +# To change an existing record: just overwrite whatever was there before! +# It will simply add a new record if there wasn't a person with the given name, +# and that is fine. Because of that, we don't have to check if the record exist +def change_birthday(person, day, birthdays): +birthdays[person] = day + +# This function deletes a birthday. +def forget_birthday(person, birthdays): +if birthdays.has_key(person): +del birthdays[person] +else: +print No such person. + +# This function check if it's anyone's birthday today. +def check_birthdays(birthdays): +# this will get us the today's date in the form ddmm, the same +# as we enter it. We don't need the year, most people have birthdays +# each year. :) +# Practice: Who doesn't? +today = time.strftime(%d%m) + +none_today = True + +for person in birthdays: +bday = birthdays[person] +# How do we know which birthday is it? +# Easy: current year - birth year. +# time.strftime(%Y) gets us the current year, and the birth year +# is written in bday variable, from 4th index to the last. +# Since both are written as strings, we have to turn them to numbers +# before we can subtract them, and we do that by passing them to the in +# function. When they are subtracted, turn the result back into a strin +# by passing it to the str() function. +which = str( int(time.strftime(%Y)) - int(bday[4:]) ) + +if bday[0:4] == today: +print It's + person + 's + which + . birthday, yay! +none_today = False + +if none_today: +print No birthdays today. + +# Practice: Could we make the output of this function nicer? +# For example, change it to the form of dd.mm. instead of ddmmyyy ? +def print_birthdays(birthdays): +for person, day in birthdays.items(): +print person + was born on + day + . +if len(birthdays.items()) == 0: +print There are no birthdays memorised. + +# This function takes a name and finds that person's birthday. +def find_birthday(name, birthdays): +if birthdays.has_key(name): +print name + 's birthday is on: + birthdays[name] +else: +print You never entered + name + 's birthday! + + +def save_to_file(filename, bdays): +# Warning: If there already exists a file with this name, opening it in w +# mode will delete the existing file and create a blank one! +# Opening in append mode adds everything to the end of an existing file, +# but we won't use it here. +# Practice: Try writing a program which appends to text files to see how it +f = open(filename, w) +# Practice: What does str(bdays) give us? Try it on a dictionary variable! +text = str(bdays) +f.write(text) +f.close() + +def load_from_file(filename): +my_file = open(filename, r) +text_from_file = my_file.read() + +# eval() takes text and then runs it as if it were Python code. +# For us, it will turn a textual representation of a dictionary to a functi +# Python dictionary. +bday_dictionary = eval(text_from_file) + +#
[Sugar-devel] Storage leak in sugar-session
I often let an XO-1 sit powered up but not doing anything for a week or more. Occasionally, after it's been idle for a while and I try to do something, it acts like it's out of memory. This has been happening for a long time, but until recently, I haven't looked in the right place to get useful numbers. This one is running 140py [mur...@xo-0d-57-33 ~]$ uptime 04:58:04 up 8 days, 5:59, 1 user, load average: 0.00, 0.00, 0.00 [mur...@xo-0d-57-33 ~]$ ps -eF UID PID PPID CSZ RSS PSR STIME TTY TIME CMD ... olpc 1940 1876 0 30669 100996 0 May13 ?00:10:39 python /usr/bin/suga ... [mur...@xo-0d-57-33 ~]$ uptime 01:15:42 up 12 days, 2:17, 1 user, load average: 0.00, 0.00, 0.00 [mur...@xo-0d-57-33 ~]$ ps -eF UID PID PPID CSZ RSS PSR STIME TTY TIME CMD ... olpc 1940 1876 0 38761 130900 0 May13 ?00:15:33 python /usr/bin/sugar-session ... [mur...@xo-0d-57-33 ~]$ uptime 00:07:23 up 17 days, 1:08, 1 user, load average: 3.55, 2.47, 1.10 olpc 1940 1876 0 48409 164468 0 May13 ?00:31:41 python /usr/bin/sugar-session Note the load average. I could login using ssh to collect that info, but it took a long long time. Is this an interesting problem? Do you want a bug report so it doesn't get lost? I don't know my way around sugar and I've never chased a storage leak in Python. Is there something I should do to collect more info? -- These are my opinions, not necessarily my employer's. I hate spam. ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] review process changes
On Thu, Jun 3, 2010 at 09:07, Bernie Innocenti ber...@codewiz.org wrote: El Thu, 03-06-2010 a las 11:55 +1000, James Cameron escribió: I don't see a way to make each module a project. The Patchwork project sugar would have to encompass all Sugar modules and activities. Patchwork prevents me from adding another project paint that shares the same mailing list. Bernie, do you agree with my assessment of Patchwork in this respect? I don't know Patchwork well enough to tell. I've installed it on request of Andres and others, but quite frankly I don't feel any necessity to augment the traditional email workflow with a web application. To track patches addressed to me, I simply keep them marked as unread until I've taken action, like I would do with any other message. Other people may prefer to use the flag bit or custom tags. To find reviews and new versions of the same patch, I simply use threading in my email client. To help maintain correct threading, both git send-email and git format-patch provide an --in-reply-to option to specify the Message-Id of the review. To help distinguish among several projects in the same mailing-list, git-format-patch provides a handy --subject-prefix option which we can set to sugar-toolkit, sugar-artwork, and so on. In the rare case that a patch really falls through the crack, whoever posted can simply resend it after a few days, or ping. Note: it's important to specify the maintainer(s) as --to of the patch, plus the mailing-list as --cc. This is the complete workflow for submitters: Thanks, this is really useful. A few observations: - how to link tickets and patches? One way is to always end the commit message with a link to the bug: http://bugs.sugarlabs.org/ticket/1622 This is what git-bz does automatically. With proper email search, you can get all tracmail and patch reviews with a single search. - queue control: I still feel it will be harder to find the right patch to review but at the same time, in all the other projects I submit patches to, I need to ping people in irc to get them reviewed. Should we move from a system with a strict queue to a ping-based system? If so, we may need a patch manager as mentioned in http://producingoss.com/en/producingoss.html#patch-manager Regards, Tomeu 1) commit your changes git commit -s -v foo.py 2) create a patch git format-patch --subject-prefix=sugar-toolkit --in-reply-to=123456 -1 3) send patch to maintainer and mailing list git send-email --to erikos --cc sugar-devel 0001-foo.patch 4) wait for maintainer grant Acked-by tag while !acked(): sleep(1) 5) adjust patch to append any tags obtained (Reviewed-by, Tested-by, Acked-by...) git commit --amend 6) rebase and push to centralized repo git pull --rebase git push Steps 5-6 can be carried on by anyone. git-send-email can be fine-tuned for maximum comfort. This is my global .gitconfig: ---cut--- [sendemail] chainreplyto = false from = Bernie Innocenti ber...@codewiz.org aliasesfile = /home/bernie/.gitaliases aliasfiletype = mutt # requires a local SMTP server #smtpserver = /usr/sbin/sendmail # when smtp is blocked smtpserver = smtp.codewiz.org smtpuser = bernie smtpssl = true ---cut--- The .gitaliases is a big time saver. For Sugar, I have the following entries: ---cut--- alias silbe Sascha Silbe si...@sugarlabs.org alias tomeu Tomeu Vizoso to...@tomeuvizoso.net alias erikos Simon Schampijer si...@schampijer.de alias mstone Michael Stone mich...@laptop.org alias anish Anish Mangal anishmangal2...@gmail.com ---cut--- -- // Bernie Innocenti - http://codewiz.org/ \X/ Sugar Labs - http://sugarlabs.org/ ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [PATCH] fix trivial typo in extension loading exception
On Thu, Jun 3, 2010 at 03:57, James Cameron qu...@laptop.org wrote: On Wed, Jun 02, 2010 at 11:19:08AM +0200, Tomeu Vizoso wrote: On Wed, Jun 2, 2010 at 06:39, James Cameron qu...@laptop.org wrote: On Tue, Jun 01, 2010 at 08:17:32AM +, Sascha Silbe wrote: While you're at it, can you avoid the escaping by using different quotes and replace % with , (for consistency with our style guidelines - it doesn't really make a difference in this particular case), please? Heh. ?Sure. ?Tell me where your style guidelines are? Diversion. What we're missing from the process at the moment is the people who apply the patches are supposed to say so as a reply to the thread. Either nobody is applying these reviewed patches, or those who are applying them are not saying so. ?;-} Unfortunately, the old process is still in place. A new process will enter into effect when the wiki is changed. I think you should test a proposed new process and not wait for it to enter into effect. If you don't have time to test the process, then it means the new process cannot be adopted, because it is untested. Well, but I guess we want to test a particular new process and for that, it needs to be written somewhere. Otherwise, each of us could end up testing a different process. Bernie was going to propose concrete changes but then got diverted to the realness summit. Is something stopping the other interested parties to propose the process they think is better? Regards, Tomeu -- 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] [PATCH] Disable default system username
On Thu, 3 Jun 2010 11:35:31 +1000, James Cameron qu...@laptop.org wrote: What does this do? What is it for? Otherwise it won't let the user select the username at the first boot. :) ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [PATCH] Disable default system username
On Thu, Jun 3, 2010 at 15:50, mabente mabe...@paraguayeduca.org wrote: On Thu, 3 Jun 2010 11:35:31 +1000, James Cameron qu...@laptop.org wrote: What does this do? What is it for? Otherwise it won't let the user select the username at the first boot. :) The idea of using GConf for it is that downstream is easy to modify without having to patch any rpm. I think you build scripts should be already setting some GConf defaults but if not, I think SoaS does it as well. Regards, Tomeu ___ 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] Striking Activity for XO 1.0 (Peru)
Hello all I have a consultation, we need a striking activity to install in the XO. That is striking? That calls the visual attention of the persons who look at the XO. Do you can please, send a list of striking activities to prove them locally? ---Hernan ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] Striking Activity for XO 1.0 (Peru)
Physics is amazing. On 3 Jun 2010 16:27, Hernan Pachas hernan.pac...@gmail.com wrote: Hello all I have a consultation, we need a striking activity to install in the XO. That is striking? That calls the visual attention of the persons who look at the XO. Do you can please, send a list of striking activities to prove them locally? ---Hernan ___ 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] Soliciting SoaS v.4 Codename Colour Suggestions
We'd like to kick off the process for the upcoming Sugar on a Stick v.4 already, while gearing up for the SoaS PR at LinuxTag, too. And so we're looking forward to your ideas and suggestions on the codename and colour selections for the next release iteration. These will be discussed at the next meeting, which is scheduled to take place on Monday, June 7 on 1900 UTC in #sugar-meeting. Thanks, --Sebastian ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] journal backup
The final patches look pretty good. I have a minor improvement, so you don't have to hard-code the scripts path. From 0e3be0059df40283fb28c2358499433da4362b5d Mon Sep 17 00:00:00 2001 From: Martin Abente mabe...@paraguayeduca.org Date: Thu, 3 Jun 2010 14:34:08 -0400 Subject: [PATCH] Bin path script resolution Organization: Paraguay Educa --- src/jarabe/journal/backup.py | 14 +- src/jarabe/model/processmanagement.py | 10 ++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/jarabe/journal/backup.py b/src/jarabe/journal/backup.py index 1b12660..f15b17d 100644 --- a/src/jarabe/journal/backup.py +++ b/src/jarabe/journal/backup.py @@ -26,11 +26,12 @@ from sugar.graphics import style from sugar.graphics.icon import Icon from sugar.graphics.xocolor import XoColor +from jarabe.model import processmanagement from jarabe.model.session import get_session_manager from jarabe.model.processmanagement import ProcessManagement -PATH_BACKUP = '/usr/bin/journal-backup-volume' -PATH_RESTORE = '/usr/bin/journal-restore-volume' +BACKUP_SCRIPT = 'journal-backup-volume' +RESTORE_SCRIPT = 'journal-restore-volume' class Backup(gtk.Window): @@ -41,7 +42,10 @@ class Backup(gtk.Window): self._type_ps = type_ps self._mount_path = mount_path -if self._isValidType(self._type_ps): +self._backup_script = processmanagement.find_and_absolutize(BACKUP_SCRIPT) +self._restore_script = processmanagement.find_and_absolutize(RESTORE_SCRIPT) + +if self._isValidType(self._type_ps) and self._backup_script and self._restore_script: if ((not self._mount_path == ) and (not self._mount_path == None)): self._progressBarHandler = None @@ -160,9 +164,9 @@ class Backup(gtk.Window): if ((not self._mount_path == ) and (not self._mount_path == None)): if self._isValidType(self._type_ps): if self._type_ps == 'backup': -self._process_management.do_process([PATH_BACKUP, self._mount_path, self._get_serial_number()]) +self._process_management.do_process([self._backup_script, self._mount_path, self._get_serial_number()]) elif self._type_ps == 'restore': -self._process_management.do_process([PATH_RESTORE, self._mount_path, self._get_serial_number()]) +self._process_management.do_process([self._restore_script, self._mount_path, self._get_serial_number()]) def _set_status_started(self, model, data=None): self._message.set_text(_(Is running, Please wait)) diff --git a/src/jarabe/model/processmanagement.py b/src/jarabe/model/processmanagement.py index d28ad64..972afc9 100644 --- a/src/jarabe/model/processmanagement.py +++ b/src/jarabe/model/processmanagement.py @@ -20,6 +20,7 @@ import gobject import glib import gio +from sugar import env from gettext import gettext as _ BYTES_TO_READ = 100 @@ -86,3 +87,12 @@ def _handle_process_end(pid, condition, (myself, stderr)): myself.emit('process-management-finished') else: myself._notify_error(stderr) + +def find_and_absolutize(script_name): +paths = env.os.environ['PATH'].split(':') +for path in paths: +looking_path = path + '/' + script_name +if env.os.path.isfile(looking_path): +return looking_path + +return None -- 1.6.0.4 ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] Soliciting SoaS v.4 Codename Colour Suggestions
'O-helo Berries http://www2.hawaii.edu/~mkamimur/Protective/ohelo_berries.htm http://www.google.com/images?q=ohelo+berriesoe=utf-8rls=com.ubuntu:en-US:unofficialclient=firefox-aum=1ie=UTF-8source=univei=IQkITPevOIzANoiclLYEsa=Xoi=image_result_groupct=titleresnum=4ved=0CDIQsAQwAw The *'O-helo* that grows at higher altitudes and is abundant in the Hawai'i Volcanoes National Park http://www.instanthawaii.com/cgi-bin/hawaii?%2100euIidhnb70KedqRdArujfaI20hr1vXvm2ufdgfo2m7n5d6eOj1FaCSRggHu1eOm90trj7aO0bnTonBTAfvIlOanfazvobUTgEku2mvn0C0uCew80CSRArrodiZOvC6 and Volcano area. The plant is usually small, from 6 inches to waste high, though it can ocassionally be larger. The plant has many branches with small rounded leaves. Young leaves at the thops are redish with green mature leaves. Related to the cranberry plant, the berries of the 'O-helo are edible and quite delicious. They range in color from bright red to yellows and oranges and the color is not necessairly indicative of the ripeness. The berries can be slightly tart to very sweet, depending on the plant and the maturity of the berries. While 'O-helo grows berries throughout the year and plants with berries may be next to ones that just had berries - there are definate seasons where more berries are produced. The 'O-helo berry was considered sacred to the Volcano Goddess Pele and offerings of branches with fruit were made into the Ki-lauea volcano. Today the berry is a favorite staple of the *Hawaiian Ne-ne- Goose* http://www.instanthawaii.com/cgi-bin/hawaii?%2100vuvl2TrfAYTofs1E0kejaFK93urjnanseqIgCt04e8Fe29ffrYafiTQndoe2ebvobrTrn5ntaMm5nTrj71Kl3dtMApT0fsIinEr2vuve2df1gnomm1n5doe3jKF7C6Rng2 as well as people. *Important Note: Because the 'O-helo berry is eaten by the protected Ne-ne- Goose do not pick any berries you find in the park.* Related to the 'O-helo is the 'O-helo kau la- au. This plant grows much taller, up to 6 ft and is more of a bush. The leaves and berries are much larger as well. The berries are also edible and when ripe can be quite sweet - though this variety is much harder to find. Good Mana! Tom Gilliard Sebastian Dziallas wrote: We'd like to kick off the process for the upcoming Sugar on a Stick v.4 already, while gearing up for the SoaS PR at LinuxTag, too. And so we're looking forward to your ideas and suggestions on the codename and colour selections for the next release iteration. These will be discussed at the next meeting, which is scheduled to take place on Monday, June 7 on 1900 UTC in #sugar-meeting. Thanks, --Sebastian ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel inline: OHELO.jpeg___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] tuchpad revelde
Hola como estan a todos los de la lista tengo un problema en un colegio de una comunidad se entregaron XO y la mayoria de los casos de problemas tecnicos son de touchpad que es muy revelde para solucionar este problema temporalmente uso la combinacion de teclas para calibrarlo pero algunos de usted ha podido solucionar esto -- Abrazoss.. Kevin Mauricio Benavides Castro XO and XS Technical Support Member of the Volunteer Group for OLPC and sugarlabs www.wiki.laptop.org/go/user/kevin.benavides http://www.sistemascastros.netne.net/ - Linux User: #12356 ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] tuchpad revelde
Kevin I hope I understand you correctly. There is a patch which has been applied to later builds. http://wiki.laptop.org/go/Touchpad_driver_changes I know it is in the os140py build and later. The touchpad is monitored and if it gives bad data it is automatically recalibrated. The result is that there are more frequent periods of bad behaviour but they only last for a few seconds Tony Hola como estan a todos los de la lista tengo un problema en un colegio de una comunidad se entregaron XO y la mayoria de los casos de problemas tecnicos son de touchpad que es muy revelde para solucionar este problema temporalmente uso la combinacion de teclas para calibrarlo pero algunos de usted ha podido solucionar esto -- Abrazoss.. Kevin Mauricio Benavides Castro XO and XS Technical Support Member of the Volunteer Group for OLPC and sugarlabs www.wiki.laptop.org/go/user/kevin.benavides http://www.sistemascastros.netne.net/ - Linux User: #12356 div dir=ltrHola como estan a todos los de la lista tengo un problema en un colegio de una comunidad se entregaron XO y la mayoria de los casos de problemas tecnicos son de touchpad que es muy revelde para solucionar este problema temporalmente uso la combinacion de teclas para calibrarlobr brpero algunos de usted ha podido solucionar estobr clear=allbr-- brAbrazoss..brbrKevin Mauricio Benavides Castro brXO and XS Technical SupportbrMember of the Volunteer Group for OLPC and sugarlabsbra href=http://www.wiki.laptop.org/go/user/kevin.benavides;www.wiki.laptop.org/go/user/kevin.benavides/a br bra href=http://www.sistemascastros.netne.net/;http://www.sistemascastros.netne.net//abr-brLinux User: #12356brbr /div ___ 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] ANNOUNCE: Sugar 0.88 for the XO-1
El Sat, 29-05-2010 a las 19:19 +1000, fors...@ozonline.com.au escribió: os240py font in Write is small and text does not fill the screen width Please, try editing /usr/bin/sugar to force SUGAR_SCALING=100. Does this change fix the bug? -- // Bernie Innocenti - http://codewiz.org/ \X/ Sugar Labs - http://sugarlabs.org/ ___ 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
On Thu, Jun 03, 2010 at 08:27:09PM -0400, Bernie Innocenti wrote: El Sat, 29-05-2010 a las 19:19 +1000, fors...@ozonline.com.au escribi??: os240py font in Write is small and text does not fill the screen width Please, try editing /usr/bin/sugar to force SUGAR_SCALING=100. Tested. Does this change fix the bug? No. (But it does fix the size of icons in the activity ring). -- 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] Storage leak in sugar-session
On Thu, Jun 03, 2010 at 03:00:09AM -0700, Hal Murray wrote: [mur...@xo-0d-57-33 ~]$ uptime 00:07:23 up 17 days, 1:08, 1 user, load average: 3.55, 2.47, 1.10 olpc 1940 1876 0 48409 164468 0 May13 ?00:31:41 python /usr/bin/sugar-session Note the load average. I could login using ssh to collect that info, but it took a long long time. I would look for other causes of high load average. Check for other processes running. Is this an interesting problem? Do you want a bug report so it doesn't get lost? Yes, and yes. bugs.sugarlabs.org for the sugar-session VSZ growth case. I don't know my way around sugar and I've never chased a storage leak in Python. Is there something I should do to collect more info? Yes, regularly capture /proc/${PID}/smaps of the sugar-session process, where ${PID} is the process ID. ${PID} may be trivially obtained with pgrep. So run this script for a few days: #!/bin/sh DIR=/home/olpc/sugar-session-smaps mkdir -p ${DIR} while true; do PID=$(pgrep -f sugar-session) if [ -n ${PID} ]; then STAMP=$(date +%s) cat /proc/${PID}/smaps ${DIR}/${STAMP} fi sleep 60 done That will tell us which segments of the process virtual memory are growing. It's likely to be one particular segment, but this will verify it, and give us an idea of when it is growing, and how rapidly. p.s. don't use the phrase sugar-session in the name of the script. -- 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] Paint: hide brush when leave area
Thanks. I will add a function to detect the brush_like_tools. Gonzalo On Thu, Jun 3, 2010 at 4:03 AM, James Cameron qu...@laptop.org wrote: On Wed, Jun 02, 2010 at 08:03:29PM -0300, Gonzalo Odiard wrote: From 3ac11e0be2adc0c805788c38ab90b3226d625a89 Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard godi...@gmail.com Date: Wed, 2 Jun 2010 20:01:10 -0300 Subject: [PATCH] hide brush when mouse leave area --- Area.py | 15 ++- 1 files changed, 14 insertions(+), 1 deletions(-) diff --git a/Area.py b/Area.py index 8a5e523..c83f38f 100644 --- a/Area.py +++ b/Area.py @@ -97,11 +97,15 @@ class Area(gtk.DrawingArea): gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK| gtk.gdk.EXPOSURE_MASK | +gtk.gdk.LEAVE_NOTIFY_MASK| +gtk.gdk.ENTER_NOTIFY_MASK| Unnecessary change of spacing for expression. gtk.gdk.KEY_PRESS_MASK) self.connect(expose_event,self.expose) self.connect(motion_notify_event, self.mousemove) self.connect(button_press_event, self.mousedown) +self.connect(leave_notify_event, self.mouseleave) +self.connect(enter_notify_event, self.mouseenter) self.connect(button_release_event, self.mouseup) self.connect(key_press_event, self.key_press) @@ -353,8 +357,17 @@ class Area(gtk.DrawingArea): self.desenha = True widget.queue_draw() - +def mouseleave(self,widget,event): +if self.tool['name'] in ['pencil','eraser','brush','rainbow']: We are seeing this test more and more. What pain you will experience when you add another tool name to that list. Perhaps it should be a list in the object attributes, or even a function. +self.drawing = True +widget.queue_draw_area(self.x_cursor-size, self.y_cursor-size, size*2, size*2) size is not defined, generates traceback in log. +def mouseenter(self,widget,event): +if self.tool['name'] in ['pencil','eraser','brush','rainbow']: +self.drawing = False +widget.queue_draw_area(self.x_cursor-size, self.y_cursor-size, size*2, size*2) size is not defined. The call to queue_draw_area could be factored. Counter-proposal: From e0b197a8b8058399c557d4e591b2cac4833ffdf2 Mon Sep 17 00:00:00 2001 From: James Cameron qu...@laptop.org Date: Thu, 3 Jun 2010 16:59:10 +1000 Subject: [PATCH] hide brush when mouse leave area Adds an enter and leave event handler for the drawing area, in order to draw or not draw the outline cursor. Tested-by: James Cameron qu...@laptop.org --- Area.py | 20 +--- 1 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Area.py b/Area.py index 570d093..a7f0bd0 100644 --- a/Area.py +++ b/Area.py @@ -97,11 +97,15 @@ class Area(gtk.DrawingArea): gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK| gtk.gdk.EXPOSURE_MASK | -gtk.gdk.KEY_PRESS_MASK) - +gtk.gdk.LEAVE_NOTIFY_MASK | +gtk.gdk.ENTER_NOTIFY_MASK | +gtk.gdk.KEY_PRESS_MASK) + self.connect(expose_event,self.expose) self.connect(motion_notify_event, self.mousemove) self.connect(button_press_event, self.mousedown) +self.connect(leave_notify_event, self.mouseleave) +self.connect(enter_notify_event, self.mouseenter) self.connect(button_release_event, self.mouseup) self.connect(key_press_event, self.key_press) @@ -353,8 +357,18 @@ class Area(gtk.DrawingArea): self.desenha = True widget.queue_draw() +def mouseleave(self, widget, event): +if self.tool['name'] in ['pencil','eraser','brush','rainbow']: +self.drawing = True +size = self.tool['line size'] +widget.queue_draw_area(self.x_cursor-size, self.y_cursor-size, size*2, size*2) + +def mouseenter(self, widget, event): +if self.tool['name'] in ['pencil','eraser','brush','rainbow']: +self.drawing = False +size = self.tool['line size'] +widget.queue_draw_area(self.x_cursor-size, self.y_cursor-size, size*2, size*2) - def mousemove(self,widget,event): Make the Area object (GtkDrawingArea) recognize that the mouse is moving. -- 1.7.1 -- James Cameron http://quozl.linux.org.au/ ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel