[Sugar-devel] [PATCH v3] Downgrading activities not allowed. (SL#2164)

2010-10-16 Thread shanjit
Downgrading an activity is now made possible. When a .xo file of a version 
older than the currently installed version is clicked, a downgrading option is 
made available, by popping up of a confirmation alert. Depending upton the 
choice selected you can downgrade the activity.

v1 -> v2. Named according to the nomenclature suggested,inline function 
used,signal emission condition revised,global variables removed.

v2 -> v3. Taking care of all calling of misc.resume.
Signed-off-by: Shanjit Singh Jajmann , Anubhav Aggarwal 

---
 src/jarabe/journal/misc.py |   29 +---
 src/jarabe/journal/versionalert.py |  121 
 src/jarabe/model/bundleregistry.py |9 ++-
 3 files changed, 145 insertions(+), 14 deletions(-)
 create mode 100644 src/jarabe/journal/versionalert.py

diff --git a/src/jarabe/journal/misc.py b/src/jarabe/journal/misc.py
index 32a2847..99ea2d4 100644
--- a/src/jarabe/journal/misc.py
+++ b/src/jarabe/journal/misc.py
@@ -30,6 +30,7 @@ from sugar.graphics.xocolor import XoColor
 from sugar import mime
 from sugar.bundle.activitybundle import ActivityBundle
 from sugar.bundle.contentbundle import ContentBundle
+from sugar.bundle.bundle import AlreadyInstalledException
 from sugar import util
 
 from jarabe.view import launcher
@@ -150,6 +151,7 @@ def get_activities(metadata):
 
 def resume(metadata, bundle_id=None):
 registry = bundleregistry.get_registry()
+version_downgrade = False
 
 if is_activity_bundle(metadata) and bundle_id is None:
 
@@ -159,20 +161,25 @@ def resume(metadata, bundle_id=None):
 bundle = ActivityBundle(file_path)
 if not registry.is_installed(bundle):
 logging.debug('Installing activity bundle')
-registry.install(bundle)
+try:
+registry.install(bundle)
+except AlreadyInstalledException:
+v_alert = VersionAlert()
+v_alert.give_bundle(bundle)
+version_downgrade= True
 else:
 logging.debug('Upgrading activity bundle')
 registry.upgrade(bundle)
-
-logging.debug('activityfactory.creating bundle with id %r',
-bundle.get_bundle_id())
-installed_bundle = registry.get_bundle(bundle.get_bundle_id())
-if installed_bundle:
-launch(installed_bundle)
-else:
-logging.error('Bundle %r is not installed.',
-  bundle.get_bundle_id())
-
+if not version_downgrade:
+logging.debug('activityfactory.creating bundle with id %r',
+bundle.get_bundle_id())
+installed_bundle = registry.get_bundle(bundle.get_bundle_id())
+if installed_bundle:
+launch(installed_bundle)
+else:
+logging.error('Bundle %r is not installed.',
+  bundle.get_bundle_id())
+ 
 elif is_content_bundle(metadata) and bundle_id is None:
 
 logging.debug('Creating content bundle')
diff --git a/src/jarabe/journal/versionalert.py 
b/src/jarabe/journal/versionalert.py
new file mode 100644
index 000..2f27a2f
--- /dev/null
+++ b/src/jarabe/journal/versionalert.py
@@ -0,0 +1,121 @@
+
+# Copyright (C) 2008 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# 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
+
+import gtk
+from gettext import gettext as _
+
+from sugar.graphics import style
+from jarabe.model import bundleregistry
+from sugar.activity import activityfactory
+
+class VersionAlert(gtk.Window):
+
+def __init__(self):
+gtk.Window.__init__(self)
+
+self.set_border_width(style.LINE_WIDTH)
+offset = style.GRID_CELL_SIZE
+width = gtk.gdk.screen_width() - offset * 3
+height = gtk.gdk.screen_height() - offset * 8.5
+self.set_size_request(width, height)
+self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
+self.set_decorated(gtk.WINDOW_TOPLEVEL)
+self.set_resizable(False)
+self.set_modal(False)
+
+self._main_view = gtk.EventBox()
+self._vbox = gtk.VBox()
+self._vbox.set_spacing(style.DEFAULT_SPACING)
+self._vbox.set_border_width(style.GRID_CELL_SIZE - 30)
+self._main_view.modify_bg(gtk.STATE_NORMAL,
+

Re: [Sugar-devel] [Dextrose] [PATCH] Downgrading activities not allowed. (#2164)

2010-10-16 Thread Bernie Innocenti
On Sat, 2010-10-16 at 03:07 +0530, shan...@seeta.in wrote:
> +
> +# Copyright (C) 2008 One Laptop Per Child

Why assign copyright to OLPC two years ago? This new file should be
copyrighted in 2010 by Seeta (or maybe Activity Central).

-- 
   // 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] [PATCH sugar-base 10/17] style cleanup: prefer ' for strings

2010-10-16 Thread Sascha Silbe
Tomeu prefers ' for strings, so let's use it wherever we don't have a good
reason to use ".

Signed-off-by: Sascha Silbe 

diff --git a/src/sugar/dispatch/saferef.py b/src/sugar/dispatch/saferef.py
index 709d292..1632b34 100644
--- a/src/sugar/dispatch/saferef.py
+++ b/src/sugar/dispatch/saferef.py
@@ -190,7 +190,7 @@ class BoundNonDescriptorMethodWeakref(BoundMethodWeakref):
 an attribute named differenty than the function's name such as in:
 
 class A: pass
-def foo(self): return "foo"
+def foo(self): return 'foo'
 A.bar = foo
 
 But this shouldn't be a common use case. So, on platforms where methods
diff --git a/src/sugar/logger.py b/src/sugar/logger.py
index 3837857..ebb766d 100644
--- a/src/sugar/logger.py
+++ b/src/sugar/logger.py
@@ -113,7 +113,7 @@ def start(log_filename=None):
 traceback.print_stack()
 
 logging.basicConfig(level=logging.WARNING,
-format="%(created)f %(levelname)s %(name)s: %(message)s",
+format='%(created)f %(levelname)s %(name)s: %(message)s',
 stream=SafeLogWrapper(sys.stderr))
 root_logger.handlers[0].handleError = handleError
 
@@ -182,22 +182,22 @@ def trace(logger=None, logger_name=None, skip_args=None, 
skip_kwargs=None,
 if not enabled:
 return f(*args, **kwargs)
 
-params_formatted = ", ".join(
+params_formatted = ', '.join(
 [trace_repr.repr(a)
 for (idx, a) in enumerate(args) if idx not in skip_args] + \
 ['%s=%s' % (k, trace_repr.repr(v))
 for (k, v) in kwargs.items() if k not in skip_kwargs])
 
-trace_logger.log(TRACE, "%s(%s) invoked", f.__name__,
+trace_logger.log(TRACE, '%s(%s) invoked', f.__name__,
 params_formatted)
 
 try:
 res = f(*args, **kwargs)
 except:
-trace_logger.exception("Exception occured in %s", f.__name__)
+trace_logger.exception('Exception occured in %s', f.__name__)
 raise
 
-trace_logger.log(TRACE, "%s(%s) returned %s", f.__name__,
+trace_logger.log(TRACE, '%s(%s) returned %s', f.__name__,
 params_formatted, trace_repr.repr(res))
 
 return res
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar-base 05/17] PEP8 cleanup: fix spaces around operators and parentheses

2010-10-16 Thread Sascha Silbe
Signed-off-by: Sascha Silbe 

diff --git a/maint-helper.py b/maint-helper.py
index 8496f06..b963e7f 100755
--- a/maint-helper.py
+++ b/maint-helper.py
@@ -22,7 +22,7 @@ import re
 import datetime
 import subprocess
 
-source_exts = [ '.py', '.c', '.h', '.cpp' ]
+source_exts = ['.py', '.c', '.h', '.cpp']
 COPYRIGHT = 'Copyright (C) '
 
 
@@ -43,7 +43,7 @@ def get_name_and_version():
 print 'Cannot find the package name and version.'
 sys.exit(0)
 
-return [ match.group(2), match.group(1) ]
+return [match.group(2), match.group(1)]
 
 
 def cmd_help():
@@ -54,7 +54,7 @@ maint-helper.py check-licenses   - check licenses in the 
source'
 
 
 def cmd_build_snapshot():
-[ name, version ] = get_name_and_version()
+[name, version] = get_name_and_version()
 
 print 'Update git...'
 
@@ -88,7 +88,7 @@ def cmd_build_snapshot():
 else:
 sugar_news = ''
 
-[ name, version ] = get_name_and_version()
+name, version = get_name_and_version()
 sugar_news += '%s - %s - %s\n\n' % (name, version, alphatag)
 
 f = open('NEWS', 'r')
@@ -130,8 +130,8 @@ def cmd_build_snapshot():
 
 
 def check_licenses(path, license, missing):
-matchers = { 'LGPL' : 'GNU Lesser General Public',
- 'GPL'  : 'GNU General Public License' }
+matchers = {'LGPL': 'GNU Lesser General Public License',
+'GPL': 'GNU General Public License'}
 
 license_file = os.path.join(path, '.license')
 if os.path.isfile(license_file):
diff --git a/src/sugar/dispatch/saferef.py b/src/sugar/dispatch/saferef.py
index 655f9a1..37443fb 100644
--- a/src/sugar/dispatch/saferef.py
+++ b/src/sugar/dispatch/saferef.py
@@ -8,7 +8,7 @@ aren't handled by the core weakref module).
 import weakref, traceback
 
 
-def safeRef(target, onDelete = None):
+def safeRef(target, onDelete=None):
 """Return a *safe* weak reference to a callable target
 
 target -- the object to be weakly referenced, if it's a
@@ -33,7 +33,7 @@ def safeRef(target, onDelete = None):
 if callable(onDelete):
 return weakref.ref(target, onDelete)
 else:
-return weakref.ref( target )
+return weakref.ref(target)
 
 
 class BoundMethodWeakref(object):
@@ -72,7 +72,7 @@ class BoundMethodWeakref(object):
 
 _allInstances = weakref.WeakValueDictionary()
 
-def __new__( cls, target, onDelete=None, *arguments,**named ):
+def __new__(cls, target, onDelete=None, *arguments, **named):
 """Create new instance or return current instance
 
 Basically this method of construction allows us to
@@ -85,14 +85,14 @@ class BoundMethodWeakref(object):
 of already-referenced methods.
 """
 key = cls.calculateKey(target)
-current =cls._allInstances.get(key)
+current = cls._allInstances.get(key)
 if current is not None:
-current.deletionMethods.append( onDelete)
+current.deletionMethods.append(onDelete)
 return current
 else:
-base = super( BoundMethodWeakref, cls).__new__( cls )
+base = super(BoundMethodWeakref, cls).__new__(cls)
 cls._allInstances[key] = base
-base.__init__( target, onDelete, *arguments,**named)
+base.__init__(target, onDelete, *arguments, **named)
 return base
 
 def __init__(self, target, onDelete=None):
@@ -114,55 +114,51 @@ class BoundMethodWeakref(object):
 methods = self.deletionMethods[:]
 del self.deletionMethods[:]
 try:
-del self.__class__._allInstances[ self.key ]
+del self.__class__._allInstances[self.key]
 except KeyError:
 pass
 for function in methods:
 try:
-if callable( function ):
-function( self )
+if callable(function):
+function(self)
 except Exception, e:
 try:
 traceback.print_exc()
 except AttributeError, err:
-print '''Exception during saferef %s cleanup function 
%s: %s'''%(
-self, function, e
-)
+print ('Exception during saferef %s cleanup function'
+' %s: %s' % (self, function, e))
 self.deletionMethods = [onDelete]
-self.key = self.calculateKey( target )
+self.key = self.calculateKey(target)
 self.weakSelf = weakref.ref(target.im_self, remove)
 self.weakFunc = weakref.ref(target.im_func, remove)
 self.selfName = str(target.im_self)
 self.funcName = str(target.im_func.__name__)
 
-def calculateKey( cls, target ):
+def calculateKey(cls, target):
 """Calculate the reference key for this reference
 
 Currently this is a two-tuple of the id()'s of 

[Sugar-devel] [PATCH sugar-base 01/17] fix EOL spaces

2010-10-16 Thread Sascha Silbe
Signed-off-by: Sascha Silbe 

diff --git a/maint-helper.py b/maint-helper.py
index 50f7d07..fea9b3c 100755
--- a/maint-helper.py
+++ b/maint-helper.py
@@ -16,7 +16,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-# Latest source available at git://dev.laptop.org/sugar 
+# Latest source available at git://dev.laptop.org/sugar
 
 import os
 import sys
diff --git a/src/sugar/dispatch/dispatcher.py b/src/sugar/dispatch/dispatcher.py
index 6855a5b..8fcbe51 100644
--- a/src/sugar/dispatch/dispatcher.py
+++ b/src/sugar/dispatch/dispatcher.py
@@ -15,11 +15,11 @@ def _make_id(target):
 
 class Signal(object):
 """Base class for all signals
-
+
 Internal attributes:
 receivers -- { receriverkey (id) : weakref(receiver) }
 """
-
+
 def __init__(self, providing_args=None):
 """providing_args -- A list of the arguments this signal can pass 
along in
a send() call.
@@ -31,7 +31,7 @@ class Signal(object):
 
 def connect(self, receiver, sender=None, weak=True, dispatch_uid=None):
 """Connect receiver to sender for signal
-
+
 receiver -- a function or an instance method which is to
 receive signals.  Receivers must be
 hashable objects.
@@ -39,7 +39,7 @@ class Signal(object):
 if weak is True, then receiver must be weak-referencable
 (more precisely saferef.safeRef() must be able to create
 a reference to the receiver).
-
+
 Receivers must be able to accept keyword arguments.
 
 If receivers have a dispatch_uid attribute, the receiver will
@@ -54,13 +54,13 @@ class Signal(object):
 By default, the module will attempt to use weak
 references to the receiver objects.  If this parameter
 is false, then strong references will be used.
-
+
 dispatch_uid -- an identifier used to uniquely identify a particular
 instance of a receiver. This will usually be a string, though it
 may be anything hashable.
 
 returns None
-"""   
+"""
 if dispatch_uid:
 lookup_key = (dispatch_uid, _make_id(sender))
 else:
@@ -77,13 +77,13 @@ class Signal(object):
 
 def disconnect(self, receiver=None, sender=None, weak=True, 
dispatch_uid=None):
 """Disconnect receiver from sender for signal
-
+
 receiver -- the registered receiver to disconnect. May be none if
 dispatch_uid is specified.
 sender -- the registered sender to disconnect
 weak -- the weakref state to disconnect
 dispatch_uid -- the unique identifier of the receiver to disconnect
-
+
 disconnect reverses the process of connect.
 
 If weak references are used, disconnect need not be called.
@@ -106,7 +106,7 @@ class Signal(object):
 
 sender -- the sender of the signal
 Either a specific object or None.
-
+
 named -- named arguments which will be passed to receivers.
 
 Returns a list of tuple pairs [(receiver, response), ... ].
diff --git a/src/sugar/dispatch/saferef.py b/src/sugar/dispatch/saferef.py
index 8bcfd8a..7c9e1db 100644
--- a/src/sugar/dispatch/saferef.py
+++ b/src/sugar/dispatch/saferef.py
@@ -66,9 +66,9 @@ class BoundMethodWeakref(object):
 same BoundMethodWeakref instance.
 
 """
-
+
 _allInstances = weakref.WeakValueDictionary()
-
+
 def __new__( cls, target, onDelete=None, *arguments,**named ):
 """Create new instance or return current instance
 
@@ -91,7 +91,7 @@ class BoundMethodWeakref(object):
 cls._allInstances[key] = base
 base.__init__( target, onDelete, *arguments,**named)
 return base
-
+
 def __init__(self, target, onDelete=None):
 """Return a weak-reference-like instance for a bound method
 
@@ -131,7 +131,7 @@ class BoundMethodWeakref(object):
 self.weakFunc = weakref.ref(target.im_func, remove)
 self.selfName = str(target.im_self)
 self.funcName = str(target.im_func.__name__)
-
+
 def calculateKey( cls, target ):
 """Calculate the reference key for this reference
 
@@ -140,7 +140,7 @@ class BoundMethodWeakref(object):
 """
 return (id(target.im_self),id(target.im_func))
 calculateKey = classmethod( calculateKey )
-
+
 def __str__(self):
 """Give a friendly representation of the object"""
 return """%s( %s.%s )"""%(
@@ -148,19 +148,19 @@ class BoundMethodWeakref(object):
 self.selfName,
 self.funcName,
 )
-
+
 __repr__ = __str__
-
+
 def __nonzero__( self ):
 """Whether we are still a valid reference"""
 return self() is not None
-
+
 def __cmp__( self, other ):
 """Compare with another 

[Sugar-devel] [PATCH sugar-base 04/17] sugar.dispatch.saferef: don't use assert for critical code paths

2010-10-16 Thread Sascha Silbe
assert a debugging tool, not meant to guard critical code paths. See e.g.
"Language Reference" section 6.3, first paragraph:

> Assert statements are a convenient way to insert debugging assertions into a
> program:

The same section also explains that enabling optimization will cause assert
statements not to be evaluated.

Signed-off-by: Sascha Silbe 

diff --git a/src/sugar/dispatch/saferef.py b/src/sugar/dispatch/saferef.py
index b0ceef9..655f9a1 100644
--- a/src/sugar/dispatch/saferef.py
+++ b/src/sugar/dispatch/saferef.py
@@ -23,11 +23,12 @@ def safeRef(target, onDelete = None):
 if target.im_self is not None:
 # Turn a bound method into a BoundMethodWeakref instance.
 # Keep track of these instances for lookup by disconnect().
-assert hasattr(target, 'im_func'), """safeRef target %r has 
im_self, but no im_func, don't know how to create reference"""%( target,)
-reference = get_bound_method_weakref(
-target=target,
-onDelete=onDelete
-)
+if not hasattr(target, 'im_func'):
+raise TypeError("safeRef target %r has im_self, but no"
+" im_func, don't know how to create reference" %
+(target, ))
+reference = get_bound_method_weakref(target=target,
+onDelete=onDelete)
 return reference
 if callable(onDelete):
 return weakref.ref(target, onDelete)
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar-base 03/17] PEP8 cleanup: fix number of blank lines

2010-10-16 Thread Sascha Silbe
Signed-off-by: Sascha Silbe 

diff --git a/maint-helper.py b/maint-helper.py
index d7c5d5b..8496f06 100755
--- a/maint-helper.py
+++ b/maint-helper.py
@@ -23,12 +23,15 @@ import datetime
 import subprocess
 
 source_exts = [ '.py', '.c', '.h', '.cpp' ]
+COPYRIGHT = 'Copyright (C) '
+
 
 def is_source(path):
 for ext in source_exts:
 if path.endswith(ext):
 return True
 
+
 def get_name_and_version():
 f = open('configure.ac', 'r')
 config = f.read()
@@ -42,12 +45,14 @@ def get_name_and_version():
 
 return [ match.group(2), match.group(1) ]
 
+
 def cmd_help():
 print 'Usage: \n\
 maint-helper.py build-snapshot   - build a source snapshot \n\
 maint-helper.py fix-copyright [path] - fix the copyright year \n\
 maint-helper.py check-licenses   - check licenses in the source'
 
+
 def cmd_build_snapshot():
 [ name, version ] = get_name_and_version()
 
@@ -123,6 +128,7 @@ def cmd_build_snapshot():
 
 print 'Done.'
 
+
 def check_licenses(path, license, missing):
 matchers = { 'LGPL' : 'GNU Lesser General Public',
  'GPL'  : 'GNU General Public License' }
@@ -164,6 +170,7 @@ def check_licenses(path, license, missing):
 missing[license] = []
 missing[license].append(full_path)
 
+
 def cmd_check_licenses():
 missing = {}
 check_licenses(os.getcwd(), 'LGPL', missing)
@@ -174,7 +181,6 @@ def cmd_check_licenses():
 print path
 print '\n'
 
-COPYRIGHT = 'Copyright (C) '
 
 def fix_copyright(path):
 for item in os.listdir(path):
@@ -212,9 +218,11 @@ def fix_copyright(path):
 f.write(result)
 f.close()
 
+
 def cmd_fix_copyright(path):
 fix_copyright(path)
 
+
 if len(sys.argv) < 2:
 cmd_help()
 elif sys.argv[1] == 'build-snapshot':
diff --git a/src/sugar/dispatch/dispatcher.py b/src/sugar/dispatch/dispatcher.py
index 8fcbe51..c9e1dd1 100644
--- a/src/sugar/dispatch/dispatcher.py
+++ b/src/sugar/dispatch/dispatcher.py
@@ -8,11 +8,13 @@ from sugar.dispatch import saferef
 
 WEAKREF_TYPES = (weakref.ReferenceType, saferef.BoundMethodWeakref)
 
+
 def _make_id(target):
 if hasattr(target, 'im_func'):
 return (id(target.im_self), id(target.im_func))
 return id(target)
 
+
 class Signal(object):
 """Base class for all signals
 
diff --git a/src/sugar/dispatch/saferef.py b/src/sugar/dispatch/saferef.py
index 7c9e1db..b0ceef9 100644
--- a/src/sugar/dispatch/saferef.py
+++ b/src/sugar/dispatch/saferef.py
@@ -7,6 +7,7 @@ aren't handled by the core weakref module).
 
 import weakref, traceback
 
+
 def safeRef(target, onDelete = None):
 """Return a *safe* weak reference to a callable target
 
@@ -33,6 +34,7 @@ def safeRef(target, onDelete = None):
 else:
 return weakref.ref( target )
 
+
 class BoundMethodWeakref(object):
 """'Safe' and reusable weak references to instance methods
 
@@ -179,6 +181,7 @@ class BoundMethodWeakref(object):
 return function.__get__(target)
 return None
 
+
 class BoundNonDescriptorMethodWeakref(BoundMethodWeakref):
 """A specialized BoundMethodWeakref, for platforms where instance methods
 are not descriptors.
@@ -239,6 +242,7 @@ class BoundNonDescriptorMethodWeakref(BoundMethodWeakref):
 return getattr(target, function.__name__)
 return None
 
+
 def get_bound_method_weakref(target, onDelete):
 """Instantiates the appropiate BoundMethodWeakRef, depending on the 
details of
 the underlying class method implementation"""
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar-base 11/17] pylint cleanup: replace disable-msg with disable

2010-10-16 Thread Sascha Silbe
Adapt to upstream format change.

Signed-off-by: Sascha Silbe 

diff --git a/src/sugar/logger.py b/src/sugar/logger.py
index ebb766d..b4cba6c 100644
--- a/src/sugar/logger.py
+++ b/src/sugar/logger.py
@@ -65,7 +65,7 @@ def set_level(level):
 logging.warning('Invalid log level: %r', level)
 
 
-# pylint: disable-msg=E1101,F0401
+# pylint: disable=E1101,F0401
 def _except_hook(exctype, value, traceback):
 # Attempt to provide verbose IPython tracebacks.
 # Importing IPython is slow, so we import it lazily.
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar-base 09/17] PEP8 cleanup: import only one module per import statement

2010-10-16 Thread Sascha Silbe
Signed-off-by: Sascha Silbe 

diff --git a/src/sugar/dispatch/saferef.py b/src/sugar/dispatch/saferef.py
index 6eb0d9e..709d292 100644
--- a/src/sugar/dispatch/saferef.py
+++ b/src/sugar/dispatch/saferef.py
@@ -5,7 +5,8 @@ Provides a way to safely weakref any function, including bound 
methods (which
 aren't handled by the core weakref module).
 """
 
-import weakref, traceback
+import weakref
+import traceback
 
 
 def safeRef(target, onDelete=None):
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar-base 16/17] pylint cleanup: Signal._live_receivers: mark receiverkey as unused

2010-10-16 Thread Sascha Silbe
Follow the convention of marking known-unused (but required for
de-marshalling purposes) variables by postfixing them with an underscore.

Signed-off-by: Sascha Silbe 

diff --git a/src/sugar/dispatch/dispatcher.py b/src/sugar/dispatch/dispatcher.py
index eb2dd7e..dd6230b 100644
--- a/src/sugar/dispatch/dispatcher.py
+++ b/src/sugar/dispatch/dispatcher.py
@@ -168,7 +168,7 @@ class Signal(object):
 """
 none_senderkey = _make_id(None)
 
-for (receiverkey, r_senderkey), receiver in self.receivers:
+for (receiverkey_, r_senderkey), receiver in self.receivers:
 if r_senderkey == none_senderkey or r_senderkey == senderkey:
 if isinstance(receiver, WEAKREF_TYPES):
 # Dereference the weak reference.
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar-base 07/17] PEP8 cleanup: ensure lines are shorter than 80 characters

2010-10-16 Thread Sascha Silbe
This is important for Sugar because the XO has a small screen where long lines
would make the code hard to understand (because you need to constantly scroll
horizontally).

Signed-off-by: Sascha Silbe 

diff --git a/src/sugar/dispatch/__init__.py b/src/sugar/dispatch/__init__.py
index 776b1bc..eecf049 100644
--- a/src/sugar/dispatch/__init__.py
+++ b/src/sugar/dispatch/__init__.py
@@ -1,6 +1,7 @@
 """Multi-consumer multi-producer dispatching mechanism
 
-Originally based on pydispatch (BSD) 
http://pypi.python.org/pypi/PyDispatcher/2.0.1
+Originally based on pydispatch (BSD)
+http://pypi.python.org/pypi/PyDispatcher/2.0.1
 See license.txt for original license.
 
 Heavily modified for Django's purposes.
diff --git a/src/sugar/dispatch/dispatcher.py b/src/sugar/dispatch/dispatcher.py
index 2138703..eb2dd7e 100644
--- a/src/sugar/dispatch/dispatcher.py
+++ b/src/sugar/dispatch/dispatcher.py
@@ -18,8 +18,8 @@ class Signal(object):
 """
 
 def __init__(self, providing_args=None):
-"""providing_args -- A list of the arguments this signal can pass 
along in
-   a send() call.
+"""providing_args -- A list of the arguments this signal can pass along
+in a send() call.
 """
 self.receivers = []
 if providing_args is None:
@@ -64,7 +64,8 @@ class Signal(object):
 lookup_key = (_make_id(receiver), _make_id(sender))
 
 if weak:
-receiver = saferef.safeRef(receiver, 
onDelete=self._remove_receiver)
+receiver = saferef.safeRef(receiver,
+onDelete=self._remove_receiver)
 
 for r_key, _ in self.receivers:
 if r_key == lookup_key:
@@ -72,7 +73,8 @@ class Signal(object):
 else:
 self.receivers.append((lookup_key, receiver))
 
-def disconnect(self, receiver=None, sender=None, weak=True, 
dispatch_uid=None):
+def disconnect(self, receiver=None, sender=None, weak=True,
+dispatch_uid=None):
 """Disconnect receiver from sender for signal
 
 receiver -- the registered receiver to disconnect. May be none if
@@ -137,8 +139,9 @@ class Signal(object):
 Return a list of tuple pairs [(receiver, response), ... ],
 may raise DispatcherKeyError
 
-if any receiver raises an error (specifically any subclass of 
Exception),
-the error instance is returned as the result for that receiver.
+if any receiver raises an error (specifically any subclass of
+Exception), the error instance is returned as the result for that
+receiver.
 """
 
 responses = []
diff --git a/src/sugar/dispatch/saferef.py b/src/sugar/dispatch/saferef.py
index 37443fb..6eb0d9e 100644
--- a/src/sugar/dispatch/saferef.py
+++ b/src/sugar/dispatch/saferef.py
@@ -185,8 +185,8 @@ class BoundNonDescriptorMethodWeakref(BoundMethodWeakref):
 
 It assumes that the function name and the target attribute name are the
 same, instead of assuming that the function is a descriptor. This approach
-is equally fast, but not 100% reliable because functions can be stored on 
an
-attribute named differenty than the function's name such as in:
+is equally fast, but not 100% reliable because functions can be stored on
+an attribute named differenty than the function's name such as in:
 
 class A: pass
 def foo(self): return "foo"
@@ -241,11 +241,12 @@ class BoundNonDescriptorMethodWeakref(BoundMethodWeakref):
 
 
 def get_bound_method_weakref(target, onDelete):
-"""Instantiates the appropiate BoundMethodWeakRef, depending on the 
details of
-the underlying class method implementation"""
+"""Instantiates the appropiate BoundMethodWeakRef, depending on the details
+of the underlying class method implementation"""
 if hasattr(target, '__get__'):
 # target method is a descriptor, so the default implementation works:
 return BoundMethodWeakref(target=target, onDelete=onDelete)
 else:
 # no luck, use the alternative implementation:
-return BoundNonDescriptorMethodWeakref(target=target, 
onDelete=onDelete)
+return BoundNonDescriptorMethodWeakref(target=target,
+onDelete=onDelete)
-- 
1.7.1

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


[Sugar-devel] Patch review: adding the module name to the subject (was: Re: [PATCH] Change the logic used to determine the format used to save files.)

2010-10-16 Thread Sascha Silbe
Excerpts from Sascha Silbe's message of Fri Oct 15 23:46:25 +0200 2010:

> Check out the --subject-prefix option of git format-patch. git send-email
> delegates the actual patch preparation to git format-patch (unless you
> pass it a pre-formatted patch as a file).

Forgot to mention: Because it's the same string per repository, the
easiest way to handle this is to set the subject prefix in the git
configuration:

sascha.si...@twin:~/sugar-jhbuild/source/sugar-base$ git config 
format.subjectprefix "PATCH sugar-base"
sascha.si...@twin:~/sugar-jhbuild/source/sugar-base$ cd ../sugar-toolkit/
sascha.si...@twin:~/sugar-jhbuild/source/sugar-toolkit$ git config 
format.subjectprefix "PATCH sugar-toolkit"
sascha.si...@twin:~/sugar-jhbuild/source/sugar-toolkit$ cd ../sugar
sascha.si...@twin:~/sugar-jhbuild/source/sugar$ git config format.subjectprefix 
"PATCH sugar"
sascha.si...@twin:~/sugar-jhbuild/source/sugar$ cd ../sugar-datastore/
sascha.si...@twin:~/sugar-jhbuild/source/sugar-datastore$ git config 
format.subjectprefix "PATCH sugar-datastore"

Sascha
-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/


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


[Sugar-devel] [PATCH sugar-base 13/17] maint-helper: rename parameter to avoid name clash with built-in function

2010-10-16 Thread Sascha Silbe
Renaming license to license_name even makes the code slightly easier to
understand.

Signed-off-by: Sascha Silbe 

diff --git a/maint-helper.py b/maint-helper.py
index 4f8a0be..8bd35ce 100755
--- a/maint-helper.py
+++ b/maint-helper.py
@@ -129,21 +129,21 @@ def cmd_build_snapshot():
 print 'Done.'
 
 
-def check_licenses(path, license, missing):
+def check_licenses(path, license_name, missing):
 matchers = {'LGPL': 'GNU Lesser General Public License',
 'GPL': 'GNU General Public License'}
 
 license_file = os.path.join(path, '.license')
 if os.path.isfile(license_file):
 f = open(license_file, 'r')
-license = f.readline().strip()
+license_name = f.readline().strip()
 f.close()
 
 for item in os.listdir(path):
 full_path = os.path.join(path, item)
 
 if os.path.isdir(full_path):
-check_licenses(full_path, license, missing)
+check_licenses(full_path, license_name, missing)
 else:
 check_source = is_source(item)
 
@@ -158,7 +158,7 @@ def check_licenses(path, license, missing):
 f.close()
 
 miss_license = True
-if source.find(matchers[license]) > 0:
+if source.find(matchers[license_name]) > 0:
 miss_license = False
 
 # Special cases.
@@ -166,9 +166,9 @@ def check_licenses(path, license, missing):
 miss_license = False
 
 if miss_license:
-if license not in missing:
-missing[license] = []
-missing[license].append(full_path)
+if license_name not in missing:
+missing[license_name] = []
+missing[license_name].append(full_path)
 
 
 def cmd_check_licenses():
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar-base 06/17] sugar.dispatch.dispatcher: remove fallback for Python 2.3

2010-10-16 Thread Sascha Silbe
Other pieces of the piece rely on Python 2.5, so there's no point in keeping
this. pep8 complained about lack of spacing in front of the inline comment,
so it needed touching anyway.

Signed-off-by: Sascha Silbe 

diff --git a/src/sugar/dispatch/dispatcher.py b/src/sugar/dispatch/dispatcher.py
index c9e1dd1..2138703 100644
--- a/src/sugar/dispatch/dispatcher.py
+++ b/src/sugar/dispatch/dispatcher.py
@@ -1,9 +1,4 @@
 import weakref
-try:
-set
-except NameError:
-from sets import Set as set # Python 2.3 fallback
-
 from sugar.dispatch import saferef
 
 WEAKREF_TYPES = (weakref.ReferenceType, saferef.BoundMethodWeakref)
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar-base 14/17] sugar.dispatch.saferef: ignore incorrect pylint warning

2010-10-16 Thread Sascha Silbe
pylint isn't smart enough to figure out our class magic, so squelch the
warning.

Signed-off-by: Sascha Silbe 

diff --git a/src/sugar/dispatch/saferef.py b/src/sugar/dispatch/saferef.py
index 1632b34..56166d9 100644
--- a/src/sugar/dispatch/saferef.py
+++ b/src/sugar/dispatch/saferef.py
@@ -115,6 +115,7 @@ class BoundMethodWeakref(object):
 methods = self.deletionMethods[:]
 del self.deletionMethods[:]
 try:
+# pylint: disable=W0212
 del self.__class__._allInstances[self.key]
 except KeyError:
 pass
-- 
1.7.1

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


[Sugar-devel] [PATCH v3 sugar] Disable Start menu item for entries that can't be opened(Bug#328)

2010-10-16 Thread Mukul Gupta
The patch disables the Start and Start With menu items for files
which can't be opened by any installed activity and instead
replace it with a hover dropdown with a menu item 'No activity
installed to start entry'
---
 src/jarabe/journal/palettes.py |   42 +++
 1 files changed, 25 insertions(+), 17 deletions(-)

v1->v2: Patch remade as per pep8 standards
v2->v3: Revised English wording and optimised behaviour for bundles

diff --git a/src/jarabe/journal/palettes.py b/src/jarabe/journal/palettes.py
index 7c3e5ff..aa09cf0 100644
--- a/src/jarabe/journal/palettes.py
+++ b/src/jarabe/journal/palettes.py
@@ -62,22 +62,30 @@ class ObjectPalette(Palette):
 Palette.__init__(self, primary_text=title,
  icon=activity_icon)
 
-if metadata.get('activity_id', ''):
-resume_label = _('Resume')
-resume_with_label = _('Resume with')
-else:
-resume_label = _('Start')
-resume_with_label = _('Start with')
-menu_item = MenuItem(resume_label, 'activity-start')
-menu_item.connect('activate', self.__start_activate_cb)
-self.menu.append(menu_item)
-menu_item.show()
+if misc.get_activities(metadata) or misc.is_bundle(metadata):
+if metadata.get('activity_id', ''):
+resume_label = _('Resume')
+resume_with_label = _('Resume with')
+else:
+resume_label = _('Start')
+resume_with_label = _('Start with')
+menu_item = MenuItem(resume_label, 'activity-start')
+menu_item.connect('activate', self.__start_activate_cb)
+self.menu.append(menu_item)
+menu_item.show()
 
-menu_item = MenuItem(resume_with_label, 'activity-start')
-self.menu.append(menu_item)
-menu_item.show()
-start_with_menu = StartWithMenu(self._metadata)
-menu_item.set_submenu(start_with_menu)
+menu_item = MenuItem(resume_with_label, 'activity-start')
+self.menu.append(menu_item)
+menu_item.show()
+start_with_menu = StartWithMenu(self._metadata)
+menu_item.set_submenu(start_with_menu)
+
+else:
+resume_label = _('No activity is available to start entry')
+menu_item = MenuItem(resume_label)
+menu_item.set_sensitive(False)
+self.menu.append(menu_item)
+menu_item.show()
 
 client = gconf.client_get_default()
 color = XoColor(client.get_string('/desktop/sugar/user/color'))
@@ -204,9 +212,9 @@ class StartWithMenu(gtk.Menu):
 
 if not self.get_children():
 if metadata.get('activity_id', ''):
-resume_label = _('No activity to resume entry')
+resume_label = _('No activity is available to resume entry')
 else:
-resume_label = _('No activity to start entry')
+resume_label = _('No activity is available to start entry')
 menu_item = MenuItem(resume_label)
 menu_item.set_sensitive(False)
 self.append(menu_item)
-- 
1.7.0.4

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


[Sugar-devel] [PATCH sugar-base 08/17] PEP8 cleanup: don't use has_key()

2010-10-16 Thread Sascha Silbe
has_key() has been deprecated for quite some time now.

Signed-off-by: Sascha Silbe 

diff --git a/maint-helper.py b/maint-helper.py
index b963e7f..4f8a0be 100755
--- a/maint-helper.py
+++ b/maint-helper.py
@@ -79,7 +79,7 @@ def cmd_build_snapshot():
 
 print 'Update NEWS.sugar...'
 
-if os.environ.has_key('SUGAR_NEWS'):
+if 'SUGAR_NEWS' in os.environ:
 sugar_news_path = os.environ['SUGAR_NEWS']
 if os.path.isfile(sugar_news_path):
 f = open(sugar_news_path, 'r')
@@ -166,7 +166,7 @@ def check_licenses(path, license, missing):
 miss_license = False
 
 if miss_license:
-if not missing.has_key(license):
+if license not in missing:
 missing[license] = []
 missing[license].append(full_path)
 
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar-base 02/17] maint-helper.py: remove outdated URL

2010-10-16 Thread Sascha Silbe
The git repository of Sugar should be easy enough to discover these days. If
we want to make it easier, a README would be a better place.

Signed-off-by: Sascha Silbe 

diff --git a/maint-helper.py b/maint-helper.py
index fea9b3c..d7c5d5b 100755
--- a/maint-helper.py
+++ b/maint-helper.py
@@ -16,8 +16,6 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-# Latest source available at git://dev.laptop.org/sugar
-
 import os
 import sys
 import re
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar-base 15/17] pylint cleanup: sugar.dispatch.saferef: remove unused variable

2010-10-16 Thread Sascha Silbe
Signed-off-by: Sascha Silbe 

diff --git a/src/sugar/dispatch/saferef.py b/src/sugar/dispatch/saferef.py
index 56166d9..bb73b5d 100644
--- a/src/sugar/dispatch/saferef.py
+++ b/src/sugar/dispatch/saferef.py
@@ -126,7 +126,7 @@ class BoundMethodWeakref(object):
 except Exception, e:
 try:
 traceback.print_exc()
-except AttributeError, err:
+except AttributeError:
 print ('Exception during saferef %s cleanup function'
 ' %s: %s' % (self, function, e))
 self.deletionMethods = [onDelete]
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar-base 17/17] sugar.mime: ignore incorrect pylint warning

2010-10-16 Thread Sascha Silbe
pylint isn't smart enough to analyse the contents of gio, so squelch the
warning.

Signed-off-by: Sascha Silbe 

diff --git a/src/sugar/mime.py b/src/sugar/mime.py
index 7f3f5ff..c4b847b 100644
--- a/src/sugar/mime.py
+++ b/src/sugar/mime.py
@@ -134,6 +134,7 @@ def get_mime_description(mime_type):
 return generic_type['name']
 
 import gio
+# pylint: disable=E1101
 return gio.content_type_get_description(mime_type)
 
 
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar-base 12/17] pylint: sugar.logger: allow overriding module name

2010-10-16 Thread Sascha Silbe
"traceback" is the name of a parameter of the function we are wrapping,
so we shouldn't change it.

Signed-off-by: Sascha Silbe 

diff --git a/src/sugar/logger.py b/src/sugar/logger.py
index b4cba6c..c242194 100644
--- a/src/sugar/logger.py
+++ b/src/sugar/logger.py
@@ -65,7 +65,7 @@ def set_level(level):
 logging.warning('Invalid log level: %r', level)
 
 
-# pylint: disable=E1101,F0401
+# pylint: disable=E1101,F0401,W0621
 def _except_hook(exctype, value, traceback):
 # Attempt to provide verbose IPython tracebacks.
 # Importing IPython is slow, so we import it lazily.
-- 
1.7.1

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


Re: [Sugar-devel] [PATCH v2 sugar] Disable Start menu item for entries that can't be opened(Bug#328)

2010-10-16 Thread Mukul Gupta
Team,

Thank you. Appreciate your feedback.
I have revised the patch which restores its existing behavior for bundles
and have incorporated Frederick's idea of having a common and an
understandable English wording.

http://lists.sugarlabs.org/archive/sugar-devel/2010-October/027925.html

Looking forward to your feedback.

Regards,

Mukul Gupta
On Fri, Oct 15, 2010 at 8:03 PM, Aleksey Lim  wrote:

> On Fri, Oct 15, 2010 at 04:19:43PM +0530, Mukul Gupta wrote:
> > The patch disables the Start and Start With menu items for files
> > which can't be opened by any installed activity and instead
> > replace it with a hover dropdown with a menu item 'No activity
> > installed to start entry'
> > ---
> >  src/jarabe/journal/palettes.py |   38
> +++---
> >  1 files changed, 23 insertions(+), 15 deletions(-)
> >
> > v1->v2: Patch remade as per pep8 standards
> >
> > diff --git a/src/jarabe/journal/palettes.py
> b/src/jarabe/journal/palettes.py
> > index 7c3e5ff..2ab93fe 100644
> > --- a/src/jarabe/journal/palettes.py
> > +++ b/src/jarabe/journal/palettes.py
> > @@ -62,22 +62,30 @@ class ObjectPalette(Palette):
> >  Palette.__init__(self, primary_text=title,
> >   icon=activity_icon)
> >
> > -if metadata.get('activity_id', ''):
> > -resume_label = _('Resume')
> > -resume_with_label = _('Resume with')
> > -else:
> > -resume_label = _('Start')
> > -resume_with_label = _('Start with')
> > -menu_item = MenuItem(resume_label, 'activity-start')
> > -menu_item.connect('activate', self.__start_activate_cb)
> > -self.menu.append(menu_item)
> > -menu_item.show()
>
> > +if misc.get_activities(metadata):
> There is an issue. For bundles, it will change existed beahviour
> (click on bundles, .xo and .xol, sugar install/start it), you need to
> check for bundles as well (misc.is_*_bundle).
>
> > +if metadata.get('activity_id', ''):
> > +resume_label = _('Resume')
> > +resume_with_label = _('Resume with')
> > +else:
> > +resume_label = _('Start')
> > +resume_with_label = _('Start with')
> > +menu_item = MenuItem(resume_label, 'activity-start')
> > +menu_item.connect('activate', self.__start_activate_cb)
> > +self.menu.append(menu_item)
> > +menu_item.show()
> >
> > -menu_item = MenuItem(resume_with_label, 'activity-start')
> > -self.menu.append(menu_item)
> > -menu_item.show()
> > -start_with_menu = StartWithMenu(self._metadata)
> > -menu_item.set_submenu(start_with_menu)
> > +menu_item = MenuItem(resume_with_label, 'activity-start')
> > +self.menu.append(menu_item)
> > +menu_item.show()
> > +start_with_menu = StartWithMenu(self._metadata)
> > +menu_item.set_submenu(start_with_menu)
> > +
> > +else:
> > +resume_label = _('No activity installed to start entry')
> > +menu_item = MenuItem(resume_label)
> > +menu_item.set_sensitive(False)
> > +self.menu.append(menu_item)
> > +menu_item.show()
> >
> >  client = gconf.client_get_default()
> >  color = XoColor(client.get_string('/desktop/sugar/user/color'))
> > --
> > 1.7.0.4
> >
>
> --
> Aleksey
>
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCH sugar-base 00/17] style cleanup series

2010-10-16 Thread Sascha Silbe
This is the sugar-base part of the style cleanups I've wanted to
land at least two releases ago, but kept missing the window.

I have done some basic testing, but naturally cannot test all code
paths I've touched (some even appear to be unused). This is why I'd like
to land this right after we branched off sucrose-0.90: to ensure it gets
enough testing before the next release.

After this series sugar-base is pep8 and pylint clean.

Sascha Silbe (17):
  fix EOL spaces
  maint-helper.py: remove outdated URL
  PEP8 cleanup: fix number of blank lines
  sugar.dispatch.saferef: don't use assert for critical code paths
  PEP8 cleanup: fix spaces around operators and parentheses
  sugar.dispatch.dispatcher: remove fallback for Python 2.3
  PEP8 cleanup: ensure lines are shorter than 80 characters
  PEP8 cleanup: don't use has_key()
  PEP8 cleanup: import only one module per import statement
  style cleanup: prefer ' for strings
  pylint cleanup: replace disable-msg with disable
  pylint: sugar.logger: allow overriding module name
  maint-helper: rename parameter to avoid name clash with built-in
function
  sugar.dispatch.saferef: ignore incorrect pylint warning
  pylint cleanup: sugar.dispatch.saferef: remove unused variable
  pylint cleanup: Signal._live_receivers: mark receiverkey as unused
  sugar.mime: ignore incorrect pylint warning

 maint-helper.py  |   40 +--
 src/sugar/dispatch/__init__.py   |3 +-
 src/sugar/dispatch/dispatcher.py |   42 
 src/sugar/dispatch/saferef.py|  102 --
 src/sugar/logger.py  |   14 +++---
 src/sugar/mime.py|1 +
 6 files changed, 107 insertions(+), 95 deletions(-)

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


Re: [Sugar-devel] [PATCH v2 sugar] Disable Start menu item for entries that can't be opened(Bug#328)

2010-10-16 Thread Aleksey Lim
On Sat, Oct 16, 2010 at 05:29:35PM +0530, Mukul Gupta wrote:
> Team,
> 
> Thank you. Appreciate your feedback.
> I have revised the patch which restores its existing behavior for bundles
> and have incorporated Frederick's idea of having a common and an
> understandable English wording.
> 
> http://lists.sugarlabs.org/archive/sugar-devel/2010-October/027925.html

hint: there is --in-reply-to (the value should be something like Message-ID:
tag in existed ML post) git argument to attach new `git send-email` emails
to already exsited ML thread, it will help peopel to track pacthces
for the same issue)

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


[Sugar-devel] [PATCH v3 sugar] Disable Start menu item for entries that can't be opened(Bug#328)

2010-10-16 Thread Mukul Gupta
The patch disables the Start and Start With menu items for files
which can't be opened by any installed activity and instead
replace it with a hover dropdown with a menu item 'No activity
installed to start entry'
---
 src/jarabe/journal/palettes.py |   42 +++
 1 files changed, 25 insertions(+), 17 deletions(-)

v1->v2: Patch remade as per pep8 standards
v2->v3: Revised English wording and optimised behaviour for bundles

diff --git a/src/jarabe/journal/palettes.py b/src/jarabe/journal/palettes.py
index 7c3e5ff..aa09cf0 100644
--- a/src/jarabe/journal/palettes.py
+++ b/src/jarabe/journal/palettes.py
@@ -62,22 +62,30 @@ class ObjectPalette(Palette):
 Palette.__init__(self, primary_text=title,
  icon=activity_icon)
 
-if metadata.get('activity_id', ''):
-resume_label = _('Resume')
-resume_with_label = _('Resume with')
-else:
-resume_label = _('Start')
-resume_with_label = _('Start with')
-menu_item = MenuItem(resume_label, 'activity-start')
-menu_item.connect('activate', self.__start_activate_cb)
-self.menu.append(menu_item)
-menu_item.show()
+if misc.get_activities(metadata) or misc.is_bundle(metadata):
+if metadata.get('activity_id', ''):
+resume_label = _('Resume')
+resume_with_label = _('Resume with')
+else:
+resume_label = _('Start')
+resume_with_label = _('Start with')
+menu_item = MenuItem(resume_label, 'activity-start')
+menu_item.connect('activate', self.__start_activate_cb)
+self.menu.append(menu_item)
+menu_item.show()
 
-menu_item = MenuItem(resume_with_label, 'activity-start')
-self.menu.append(menu_item)
-menu_item.show()
-start_with_menu = StartWithMenu(self._metadata)
-menu_item.set_submenu(start_with_menu)
+menu_item = MenuItem(resume_with_label, 'activity-start')
+self.menu.append(menu_item)
+menu_item.show()
+start_with_menu = StartWithMenu(self._metadata)
+menu_item.set_submenu(start_with_menu)
+
+else:
+resume_label = _('No activity is available to start entry')
+menu_item = MenuItem(resume_label)
+menu_item.set_sensitive(False)
+self.menu.append(menu_item)
+menu_item.show()
 
 client = gconf.client_get_default()
 color = XoColor(client.get_string('/desktop/sugar/user/color'))
@@ -204,9 +212,9 @@ class StartWithMenu(gtk.Menu):
 
 if not self.get_children():
 if metadata.get('activity_id', ''):
-resume_label = _('No activity to resume entry')
+resume_label = _('No activity is available to resume entry')
 else:
-resume_label = _('No activity to start entry')
+resume_label = _('No activity is available to start entry')
 menu_item = MenuItem(resume_label)
 menu_item.set_sensitive(False)
 self.append(menu_item)
-- 
1.7.0.4

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


Re: [Sugar-devel] [PATCH v3 sugar] Disable Start menu item for entries that can't be opened(Bug#328)

2010-10-16 Thread Aleksey Lim
On Sat, Oct 16, 2010 at 05:16:31PM +0530, Mukul Gupta wrote:
> The patch disables the Start and Start With menu items for files
> which can't be opened by any installed activity and instead
> replace it with a hover dropdown with a menu item 'No activity
> installed to start entry'
> ---
>  src/jarabe/journal/palettes.py |   42 +++
>  1 files changed, 25 insertions(+), 17 deletions(-)
> 
> v1->v2: Patch remade as per pep8 standards
> v2->v3: Revised English wording and optimised behaviour for bundles
> 
> diff --git a/src/jarabe/journal/palettes.py b/src/jarabe/journal/palettes.py
> index 7c3e5ff..aa09cf0 100644
> --- a/src/jarabe/journal/palettes.py
> +++ b/src/jarabe/journal/palettes.py
> @@ -62,22 +62,30 @@ class ObjectPalette(Palette):
>  Palette.__init__(self, primary_text=title,
>   icon=activity_icon)
>  
> -if metadata.get('activity_id', ''):
> -resume_label = _('Resume')
> -resume_with_label = _('Resume with')
> -else:
> -resume_label = _('Start')
> -resume_with_label = _('Start with')
> -menu_item = MenuItem(resume_label, 'activity-start')
> -menu_item.connect('activate', self.__start_activate_cb)
> -self.menu.append(menu_item)
> -menu_item.show()
> +if misc.get_activities(metadata) or misc.is_bundle(metadata):
> +if metadata.get('activity_id', ''):
> +resume_label = _('Resume')
> +resume_with_label = _('Resume with')
> +else:
> +resume_label = _('Start')
> +resume_with_label = _('Start with')
> +menu_item = MenuItem(resume_label, 'activity-start')
> +menu_item.connect('activate', self.__start_activate_cb)
> +self.menu.append(menu_item)
> +menu_item.show()
>  
> -menu_item = MenuItem(resume_with_label, 'activity-start')
> -self.menu.append(menu_item)
> -menu_item.show()
> -start_with_menu = StartWithMenu(self._metadata)
> -menu_item.set_submenu(start_with_menu)
> +menu_item = MenuItem(resume_with_label, 'activity-start')
> +self.menu.append(menu_item)
> +menu_item.show()
> +start_with_menu = StartWithMenu(self._metadata)
> +menu_item.set_submenu(start_with_menu)
> +
> +else:
> +resume_label = _('No activity is available to start entry')
> +menu_item = MenuItem(resume_label)
> +menu_item.set_sensitive(False)
> +self.menu.append(menu_item)
> +menu_item.show()
>  
>  client = gconf.client_get_default()
>  color = XoColor(client.get_string('/desktop/sugar/user/color'))
> @@ -204,9 +212,9 @@ class StartWithMenu(gtk.Menu):
>  
>  if not self.get_children():
>  if metadata.get('activity_id', ''):

+1 for the rest but not sure about this one:
> -resume_label = _('No activity to resume entry')
> +resume_label = _('No activity is available to resume entry')
>  else:
> -resume_label = _('No activity to start entry')
> +resume_label = _('No activity is available to start entry')
we will break translators work w/o the reason (new wording leaves meaning
the same), afaik it is not common practice, better will be changing en
translation via translate.sl.o rather than in code.

>  menu_item = MenuItem(resume_label)
>  menu_item.set_sensitive(False)
>  self.append(menu_item)
> -- 
> 1.7.0.4
> 

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


[Sugar-devel] [PATCH Paint] Changes made to save the last added text item. (OLPC #5917)

2010-10-16 Thread Ishan Bansal
New variable text_status defined which could keep the track of the status of
text being entered and save it when activity is stopped.

Signed-off-by: ishan bansal ,anubhav aggarwal 

---
 Area.py |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/Area.py b/Area.py
index 2dca7da..012b640 100644
--- a/Area.py
+++ b/Area.py
@@ -112,6 +112,8 @@ class Area(gtk.DrawingArea):
 self.connect("key_press_event", self.key_press)
 self.connect("leave_notify_event", self.mouseleave)
 self.connect("enter_notify_event", self.mouseenter)
+
+self.textstatus = -1
 
 target = [('text/uri-list', 0, TARGET_URI)]
 self.drag_dest_set(gtk.DEST_DEFAULT_ALL, target,
@@ -303,6 +305,7 @@ class Area(gtk.DrawingArea):
 # text
 if self.tool['name'] == 'text':
 self.d.text(widget,event)
+self.text_status = 0
 
 # This fixes a bug that made the text viewer get stuck in the canvas
 elif self.estadoTexto is 1:
@@ -473,6 +476,10 @@ class Area(gtk.DrawingArea):
 self.configure_line(self.line_size)
 self.d.polygon(widget,coords,True,self.tool['fill'],"moving")
 
+if self.tool['name'] == 'text':
+   if self.text_status == 0:
+  self.text_status = 1
+  
 gtk.gdk.event_request_motions (event)
 
 def mouseup(self,widget,event): 
@@ -571,6 +578,10 @@ class Area(gtk.DrawingArea):
 size = self.tool['line size']
 widget.queue_draw_area(self.x_cursor-size, self.y_cursor-size, 
size*2, size*2)
 
+if self.tool['name'] == 'text':
+   if self.text_status == 1:
+ self.d.text(widget,event)
+ 
 def mouseenter(self, widget, event):
 if self.tool['name'] in ['pencil','eraser','brush','rainbow']:
 self.drawing = False
-- 
1.7.0.4

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


[Sugar-devel] [DESIGN] Downgrading activities not allowed. (SL#2164)

2010-10-16 Thread Aleksey Lim
On Sat, Oct 16, 2010 at 01:31:02PM +0530, shan...@seeta.in wrote:
> Downgrading an activity is now made possible. When a .xo file of a version 
> older than the currently installed version is clicked, a downgrading option 
> is made available, by popping up of a confirmation alert. Depending upton the 
> choice selected you can downgrade the activity.

Do we have designers feedback about should downgrade alert be a window
or regular alert in Journal (didn't find something in ML).

(btw I got noting while trying to resume older versin .xo)

> v1 -> v2. Named according to the nomenclature suggested,inline function 
> used,signal emission condition revised,global variables removed.
> 
> v2 -> v3. Taking care of all calling of misc.resume.
> Signed-off-by: Shanjit Singh Jajmann , Anubhav Aggarwal 
> 
> ---
>  src/jarabe/journal/misc.py |   29 +---
>  src/jarabe/journal/versionalert.py |  121 
> 
>  src/jarabe/model/bundleregistry.py |9 ++-
>  3 files changed, 145 insertions(+), 14 deletions(-)
>  create mode 100644 src/jarabe/journal/versionalert.py
> 
> diff --git a/src/jarabe/journal/misc.py b/src/jarabe/journal/misc.py
> index 32a2847..99ea2d4 100644
> --- a/src/jarabe/journal/misc.py
> +++ b/src/jarabe/journal/misc.py
> @@ -30,6 +30,7 @@ from sugar.graphics.xocolor import XoColor
>  from sugar import mime
>  from sugar.bundle.activitybundle import ActivityBundle
>  from sugar.bundle.contentbundle import ContentBundle
> +from sugar.bundle.bundle import AlreadyInstalledException
>  from sugar import util
>  
>  from jarabe.view import launcher
> @@ -150,6 +151,7 @@ def get_activities(metadata):
>  
>  def resume(metadata, bundle_id=None):
>  registry = bundleregistry.get_registry()
> +version_downgrade = False
>  
>  if is_activity_bundle(metadata) and bundle_id is None:
>  
> @@ -159,20 +161,25 @@ def resume(metadata, bundle_id=None):
>  bundle = ActivityBundle(file_path)
>  if not registry.is_installed(bundle):
>  logging.debug('Installing activity bundle')
> -registry.install(bundle)
> +try:
> +registry.install(bundle)
> +except AlreadyInstalledException:
> +v_alert = VersionAlert()
> +v_alert.give_bundle(bundle)
> +version_downgrade= True
>  else:
>  logging.debug('Upgrading activity bundle')
>  registry.upgrade(bundle)
> -
> -logging.debug('activityfactory.creating bundle with id %r',
> -bundle.get_bundle_id())
> -installed_bundle = registry.get_bundle(bundle.get_bundle_id())
> -if installed_bundle:
> -launch(installed_bundle)
> -else:
> -logging.error('Bundle %r is not installed.',
> -  bundle.get_bundle_id())
> -
> +if not version_downgrade:
> +logging.debug('activityfactory.creating bundle with id %r',
> +bundle.get_bundle_id())
> +installed_bundle = registry.get_bundle(bundle.get_bundle_id())
> +if installed_bundle:
> +launch(installed_bundle)
> +else:
> +logging.error('Bundle %r is not installed.',
> +  bundle.get_bundle_id())
> + 
>  elif is_content_bundle(metadata) and bundle_id is None:
>  
>  logging.debug('Creating content bundle')
> diff --git a/src/jarabe/journal/versionalert.py 
> b/src/jarabe/journal/versionalert.py
> new file mode 100644
> index 000..2f27a2f
> --- /dev/null
> +++ b/src/jarabe/journal/versionalert.py
> @@ -0,0 +1,121 @@
> +
> +# Copyright (C) 2008 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
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# 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
> +
> +import gtk
> +from gettext import gettext as _
> +
> +from sugar.graphics import style
> +from jarabe.model import bundleregistry
> +from sugar.activity import activityfactory
> +
> +class VersionAlert(gtk.Window):
> +
> +def __init__(self):
> +gtk.Window.__init__(self)
> +
> +self.set_border_width(style.LINE_WIDTH)
> +offset = style.GRID_CELL_SIZE
> +width = gtk.gdk.screen_width() - offset * 3
> +height = gtk.gdk.screen_height() - offset * 8.5
> +  

Re: [Sugar-devel] [PATCH 0/3 sugar-datastore] PEP8 / pylint cleanups

2010-10-16 Thread Aleksey Lim
On Fri, Oct 15, 2010 at 05:36:09PM +, Sascha Silbe wrote:
> Make sugar-datastore as PEP8 / pylint clean as possible (again). All remaining
> complaints are pylint bugs (doesn't recognise keyword arguments in decorators)
> resp. shortcomings in pep8 (cannot selectively disable a warning for a
> specific piece of code).
> 
> Sascha Silbe (3):
>   PEP8 cleanups
>   datastore, migration: remove unused import traceback
>   indexstore: disable pylint warning W0221 for parse_query
> 
>  src/carquinyol/datastore.py |1 -
>  src/carquinyol/filestore.py |3 ++-
>  src/carquinyol/indexstore.py|2 +-
>  src/carquinyol/layoutmanager.py |1 +
>  src/carquinyol/migration.py |1 -
>  5 files changed, 4 insertions(+), 4 deletions(-)

Commited, with edditional patches and HACKING file w/ instruction to
use sugar-lint in git pre-commit hook.

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


Re: [Sugar-devel] [DESIGN] Downgrading activities not allowed. (SL#2164)

2010-10-16 Thread Gary Martin
On 16 Oct 2010, at 14:14, Aleksey Lim  wrote:

> On Sat, Oct 16, 2010 at 01:31:02PM +0530, shan...@seeta.in wrote:
>> Downgrading an activity is now made possible. When a .xo file of a version 
>> older than the currently installed version is clicked, a downgrading option 
>> is made available, by popping up of a confirmation alert. Depending upton 
>> the choice selected you can downgrade the activity.
> 
> Do we have designers feedback about should downgrade alert be a window
> or regular alert in Journal (didn't find something in ML).

FWIW, I'd vote for use of the regular Sugar alert strip that appears below the 
toolbar. Using floating window dialogues goes against the fullscreen Sugar 
design.

--Gary

> (btw I got noting while trying to resume older versin .xo)
> 
>> v1 -> v2. Named according to the nomenclature suggested,inline function 
>> used,signal emission condition revised,global variables removed.
>> 
>> v2 -> v3. Taking care of all calling of misc.resume.
>> Signed-off-by: Shanjit Singh Jajmann , Anubhav Aggarwal 
>> 
>> ---
>> src/jarabe/journal/misc.py |   29 +---
>> src/jarabe/journal/versionalert.py |  121 
>> 
>> src/jarabe/model/bundleregistry.py |9 ++-
>> 3 files changed, 145 insertions(+), 14 deletions(-)
>> create mode 100644 src/jarabe/journal/versionalert.py
>> 
>> diff --git a/src/jarabe/journal/misc.py b/src/jarabe/journal/misc.py
>> index 32a2847..99ea2d4 100644
>> --- a/src/jarabe/journal/misc.py
>> +++ b/src/jarabe/journal/misc.py
>> @@ -30,6 +30,7 @@ from sugar.graphics.xocolor import XoColor
>> from sugar import mime
>> from sugar.bundle.activitybundle import ActivityBundle
>> from sugar.bundle.contentbundle import ContentBundle
>> +from sugar.bundle.bundle import AlreadyInstalledException
>> from sugar import util
>> 
>> from jarabe.view import launcher
>> @@ -150,6 +151,7 @@ def get_activities(metadata):
>> 
>> def resume(metadata, bundle_id=None):
>> registry = bundleregistry.get_registry()
>> +version_downgrade = False
>> 
>> if is_activity_bundle(metadata) and bundle_id is None:
>> 
>> @@ -159,20 +161,25 @@ def resume(metadata, bundle_id=None):
>> bundle = ActivityBundle(file_path)
>> if not registry.is_installed(bundle):
>> logging.debug('Installing activity bundle')
>> -registry.install(bundle)
>> +try:
>> +registry.install(bundle)
>> +except AlreadyInstalledException:
>> +v_alert = VersionAlert()
>> +v_alert.give_bundle(bundle)
>> +version_downgrade= True
>> else:
>> logging.debug('Upgrading activity bundle')
>> registry.upgrade(bundle)
>> -
>> -logging.debug('activityfactory.creating bundle with id %r',
>> -bundle.get_bundle_id())
>> -installed_bundle = registry.get_bundle(bundle.get_bundle_id())
>> -if installed_bundle:
>> -launch(installed_bundle)
>> -else:
>> -logging.error('Bundle %r is not installed.',
>> -  bundle.get_bundle_id())
>> -
>> +if not version_downgrade:
>> +logging.debug('activityfactory.creating bundle with id %r',
>> +bundle.get_bundle_id())
>> +installed_bundle = registry.get_bundle(bundle.get_bundle_id())
>> +if installed_bundle:
>> +launch(installed_bundle)
>> +else:
>> +logging.error('Bundle %r is not installed.',
>> +  bundle.get_bundle_id())
>> + 
>> elif is_content_bundle(metadata) and bundle_id is None:
>> 
>> logging.debug('Creating content bundle')
>> diff --git a/src/jarabe/journal/versionalert.py 
>> b/src/jarabe/journal/versionalert.py
>> new file mode 100644
>> index 000..2f27a2f
>> --- /dev/null
>> +++ b/src/jarabe/journal/versionalert.py
>> @@ -0,0 +1,121 @@
>> +
>> +# Copyright (C) 2008 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
>> +# the Free Software Foundation; either version 2 of the License, or
>> +# (at your option) any later version.
>> +#
>> +# This program is distributed in the hope that it will be useful,
>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> +# GNU General Public License for more details.
>> +#
>> +# 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
>> +
>> +import gtk
>> +from gettext import gettext as _
>> +
>> +from sugar.graphics import style
>> +from jarabe.model import bundleregistry
>> +from sugar.activity import activityfactory
>> +
>> +cl

Re: [Sugar-devel] ticket 2170 Specify bundle id for read activity

2010-10-16 Thread Ishan Bansal
Hi Sacha

I had submitted the patch for the http://bugs.sugarlabs.org/ticket/2170

You can check the patch at
http://lists.sugarlabs.org/archive/sugar-devel/2010-September/026963.html

Wish if you could review it and provide me feedback on any improvement
required.

Regards

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


Re: [Sugar-devel] ticket #2318 display free journal space in volume toolbar

2010-10-16 Thread Aleksey Lim
On Sun, Oct 17, 2010 at 12:58:27AM +0530, Ishan Bansal wrote:
> Hi Aleksey
> 
> I had submitted the patch for the http://bugs.sugarlabs.org/ticket/2318
> 
> You can check the patch at
> http://www.mail-archive.com/sugar-devel@lists.sugarlabs.org/msg16721.html
> 
> Wish if you could review it and provide me feedback on any improvement
> required.

You need to check your patch (only your patch, the rest of code does not
conform all checks) w/ pylint/pep8 (eg using sugar-lint[1]).

> +label = 'Journal'
string needs to be kept gettextized ie _('Journal')

[1] http://wiki.sugarlabs.org/go/Activity_Team/Sugar_Lint

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


Re: [Sugar-devel] [Dextrose] ticket 2170 Specify bundle id for read activity

2010-10-16 Thread Bernie Innocenti
On Sun, 2010-10-17 at 01:06 +0530, Ishan Bansal wrote:
> Hi Sacha
> 
> I had submitted the patch for the
> http://bugs.sugarlabs.org/ticket/2170
> 
> You can check the patch at
> http://lists.sugarlabs.org/archive/sugar-devel/2010-September/026963.html
> 
> Wish if you could review it and provide me feedback on any improvement
> required.

The current maintainer of Read is Lucian. Before it was Morgan Collet.

Sascha is welcome to review, but he has no commit access and no
authority to approve the patch.

-- 
   // 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] [PATCH v4 sugar] Downgrading activities not allowed. (#2164)

2010-10-16 Thread anubhav
Downgrading an activity is now made possible. When a .xo file of a version older
than the currently installed version is clicked, a downgrading option is made
available, by popping up of a confirmation alert. Depending upton the choice
selected you can downgrade the activity.

v1 -> v2. Named according to the nomenclature suggested,inline function 
used,signal emission condition revised,global variables removed.

v2 -> v3. Taking care of all calling of misc.resume.

v3 -> v4. Changes in the copyright of the new file

Signed-off-by: Anubhav Aggarwal  , Shanjit Singh Jajmann 


---
 src/jarabe/journal/misc.py |   29 ++---
 src/jarabe/journal/versionalert.py |  122 
 src/jarabe/model/bundleregistry.py |9 ++-
 3 files changed, 148 insertions(+), 12 deletions(-)
 create mode 100644 src/jarabe/journal/versionalert.py

diff --git a/src/jarabe/journal/misc.py b/src/jarabe/journal/misc.py
index 32a2847..f060bb2 100644
--- a/src/jarabe/journal/misc.py
+++ b/src/jarabe/journal/misc.py
@@ -30,12 +30,14 @@ from sugar.graphics.xocolor import XoColor
 from sugar import mime
 from sugar.bundle.activitybundle import ActivityBundle
 from sugar.bundle.contentbundle import ContentBundle
+from sugar.bundle.bundle import AlreadyInstalledException
 from sugar import util
 
 from jarabe.view import launcher
 from jarabe.model import bundleregistry, shell
 from jarabe.journal.journalentrybundle import JournalEntryBundle
 from jarabe.journal import model
+from jarabe.journal.versionalert import VersionAlert
 
 def _get_icon_for_mime(mime_type):
 generic_types = mime.get_all_generic_types()
@@ -150,6 +152,7 @@ def get_activities(metadata):
 
 def resume(metadata, bundle_id=None):
 registry = bundleregistry.get_registry()
+version_downgrade = False
 
 if is_activity_bundle(metadata) and bundle_id is None:
 
@@ -159,19 +162,27 @@ def resume(metadata, bundle_id=None):
 bundle = ActivityBundle(file_path)
 if not registry.is_installed(bundle):
 logging.debug('Installing activity bundle')
-registry.install(bundle)
+try:
+registry.install(bundle)
+except AlreadyInstalledException:
+v_alert = VersionAlert()
+v_alert.give_bundle(bundle)
+version_downgrade= True
+logging.debug('done')
+
 else:
 logging.debug('Upgrading activity bundle')
 registry.upgrade(bundle)
 
-logging.debug('activityfactory.creating bundle with id %r',
-bundle.get_bundle_id())
-installed_bundle = registry.get_bundle(bundle.get_bundle_id())
-if installed_bundle:
-launch(installed_bundle)
-else:
-logging.error('Bundle %r is not installed.',
-  bundle.get_bundle_id())
+if not version_downgrade:
+logging.debug('activityfactory.creating bundle with id %r',
+bundle.get_bundle_id())
+installed_bundle = registry.get_bundle(bundle.get_bundle_id())
+if installed_bundle:
+launch(installed_bundle)
+else:
+logging.error('Bundle %r is not installed.',
+  bundle.get_bundle_id())
 
 elif is_content_bundle(metadata) and bundle_id is None:
 
diff --git a/src/jarabe/journal/versionalert.py 
b/src/jarabe/journal/versionalert.py
new file mode 100644
index 000..b0e30b0
--- /dev/null
+++ b/src/jarabe/journal/versionalert.py
@@ -0,0 +1,122 @@
+#Copyright (C) 2010 Software for Education, Entertainment and Training 
Activities
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# 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
+
+import gtk
+from gettext import gettext as _
+
+from sugar.graphics import style
+from jarabe.model import bundleregistry
+from sugar.activity import activityfactory
+import logging
+
+class VersionAlert(gtk.Window):
+
+def __init__(self):
+gtk.Window.__init__(self)
+
+self.set_border_width(style.LINE_WIDTH)
+offset = style.GRID_CELL_SIZE
+width = gtk.gdk.screen_width() - offset * 3
+height = gtk.gdk.screen_height() - offset * 8.5
+self.set_size_request(width, height)
+self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
+

Re: [Sugar-devel] ticket #2318 display free journal space in volume toolbar

2010-10-16 Thread Ishan Bansal
Hi Aleksey

I had submitted the patch for the http://bugs.sugarlabs.org/ticket/2318

You can check the patch at
http://www.mail-archive.com/sugar-devel@lists.sugarlabs.org/msg16721.html

Wish if you could review it and provide me feedback on any improvement
required.

Regards

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


Re: [Sugar-devel] [PATCH v4 sugar] Downgrading activities not allowed. (#2164)

2010-10-16 Thread Sascha Silbe
Excerpts from anubhav's message of Sat Oct 16 22:25:00 +0200 2010:

[src/jarabe/journal/versionalert.py: 147 lines skipped]

If we really need that much code just for asking the user for
confirmation then we're doing something wrong.

Sascha

--
http://sascha.silbe.org/
http://www.infra-silbe.de/


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


Re: [Sugar-devel] [DESIGN] Downgrading activities not allowed. (SL#2164)

2010-10-16 Thread Sascha Silbe
Excerpts from Gary Martin's message of Sat Oct 16 17:05:20 +0200 2010:

> FWIW, I'd vote for use of the regular Sugar alert strip that appears below 
> the toolbar. Using floating window dialogues goes against the fullscreen 
> Sugar design.

+1
Dialogs are evil (especially, but not only if they're modal). I am barely
resisting (*) the temptation to rip out the WEP/WPA passphrase dialog.
Not only did I come across it during the cleanup series I'm preparing for
sugar, but it also caused Sugar to become unresponsive on my XO yet again:
Somehow this modal dialog was activated, but not raised to the top (and
with no way for the user to raise it).

Sascha

(*) The only reason I'm resisting is that I want to finish other stuff
first. ;)
--
http://sascha.silbe.org/
http://www.infra-silbe.de/


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


Re: [Sugar-devel] [Dextrose] [PATCH v4 sugar] Downgrading activities not allowed. (#2164)

2010-10-16 Thread Bernie Innocenti
On Sun, 2010-10-17 at 01:55 +0530, anub...@seeta.in wrote:
> +def __install_cancel_cb(self, button):
> +'''The opener will listen on the destroy signal
> +'''
> +logging.debug('1')

This...

> +self.destroy()
> + 
> +def __install_ok_cb(self, button):
> +logging.debug('2')

...and this, are probably leftovers from your debugging sessions.
Please, remember to remove them before committing the patch.

> -def install(self, bundle, uid=None):
> +def install(self, bundle, uid=None,force_downgrade=False):

There should be a space after the comma.

>  elif bundle.get_bundle_id() == installed_bundle.get_bundle_id():
>  self.uninstall(installed_bundle, force=True)
> -
> +
>  install_dir = env.get_user_activities_path()

Here you're adding a bunch of invisible spaces. Perhaps you could
configure your text editor to display spacing errors.

(This is not intended to be a full review, just a few things I've
spotted while scrolling through the patch. Please wait for a maintainer
to comment on the rest of the patch).

-- 
   // 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] ticket 2170 Specify bundle id for read activity

2010-10-16 Thread Sascha Silbe
Excerpts from Ishan Bansal's message of Sat Oct 16 21:36:56 +0200 2010:

> You can check the patch at
> http://lists.sugarlabs.org/archive/sugar-devel/2010-September/026963.html
> 
> Wish if you could review it and provide me feedback on any improvement
> required.

If you'd like to remind everyone (or the maintainer, which isn't me in
this case) that your patch wasn't reviewed (or acknowledged) yet, please
just reply to the patch itself instead of writing a new mail.

By replying to the mail with the patch you cause the entire thread to
be shown again (at least in the MUAs I used so far), so the reviewer
can look at the patch right away instead of having to dig it up.

Sascha

--
http://sascha.silbe.org/
http://www.infra-silbe.de/


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


[Sugar-devel] [PATCH Paint Activity] Added Invert Color Effect to Paint Activity (OLPC #2495)

2010-10-16 Thread Ayush Goyal

Signed-off-by: Ayush Goyal 
---
 Area.py |   40 +
 icons/invert-colors.svg |  387 +++
 toolbox.py  |   22 ++-
 3 files changed, 441 insertions(+), 8 deletions(-)
 create mode 100644 icons/invert-colors.svg

diff --git a/Area.py b/Area.py
index 2dca7da..7c7f4c5 100644
--- a/Area.py
+++ b/Area.py
@@ -70,6 +70,7 @@ import pango
 from fill import *
 from Desenho import Desenho
 from urlparse import urlparse
+import numpy
 
 ##Tools and events manipulation are handle with this class.
 
@@ -833,6 +834,45 @@ class Area(gtk.DrawingArea):
 self.queue_draw()
 if not self.selmove:
 self.enableUndo(widget)
+
+def invert_colors(self,widget):
+"""Apply invert color effect.
+
+@param  self -- the Area object (GtkDrawingArea)
+@param  widget -- the Area object (GtkDrawingArea)
+
+"""
+
+width, height = self.window.get_size()
+ 
+if self.selmove:
+size = self.pixmap_sel.get_size()
+pix = 
gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,size[0],size[1])
+
pix.get_from_drawable(self.pixmap_sel,gtk.gdk.colormap_get_system(),0,0,0,0,size[0],size[1])
+else:
+pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,width,height)
+
pix.get_from_drawable(self.pixmap,gtk.gdk.colormap_get_system(),0,0,0,0,width,height)
+
+pix_manip2=pix.get_pixels_array()
+pix_manip=numpy.ones(pix_manip2.shape,dtype=numpy.uint8)*255
+pix_manip2=pix_manip-pix_manip2
+pix=gtk.gdk.pixbuf_new_from_array(pix_manip2,gtk.gdk.COLORSPACE_RGB,8) 
   
+
+
+if self.selmove:
+
self.pixmap_sel.draw_pixbuf(self.gc,pix,0,0,0,0,size[0],size[1],dither=gtk.gdk.RGB_DITHER_NORMAL,x_dither=0,y_dither=0)
+
+
self.pixmap_temp.draw_drawable(self.gc,self.pixmap,0,0,0,0,width,height)
+
self.pixmap_temp.draw_drawable(self.gc,self.pixmap_sel,0,0,self.orig_x,self.orig_y,size[0],size[1])
+
self.pixmap_temp.draw_rectangle(self.gc_selection,False,self.orig_x,self.orig_y,size[0],size[1])
+
self.pixmap_temp.draw_rectangle(self.gc_selection1,False,self.orig_x-1,self.orig_y-1,size[0]+2,size[1]+2)
+
+else:
+
self.pixmap.draw_pixbuf(self.gc,pix,0,0,0,0,width,height,dither=gtk.gdk.RGB_DITHER_NORMAL,x_dither=0,y_dither=0)
+
+self.queue_draw()
+if not self.selmove:
+self.enableUndo(widget)
 
 def _pixbuf2Image(self, pb):
 """change a pixbuf to RGB image
diff --git a/icons/invert-colors.svg b/icons/invert-colors.svg
new file mode 100644
index 000..373ca70
--- /dev/null
+++ b/icons/invert-colors.svg
@@ -0,0 +1,387 @@
+
+http://www.openswatchbook.org/uri/2009/osb";
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:xlink="http://www.w3.org/1999/xlink";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   enable-background="new 0 0 55 55"
+   height="55px"
+   version="1.1"
+   viewBox="0 0 55 55"
+   width="55px"
+   x="0px"
+   xml:space="preserve"
+   y="0px"
+   id="svg2"
+   inkscape:version="0.48.0 r9654"
+   sodipodi:docname="invert-colors.svg">image/svg+xmlhttp://purl.org/dc/dcmitype/StillImage"; 
/>
\ No newline at end of file
diff --git a/toolbox.py b/toolbox.py
index 299181b..0c3105c 100644
--- a/toolbox.py
+++ b/toolbox.py
@@ -1230,6 +1230,8 @@ class ImageToolbar(gtk.Toolbar):
 class EffectsToolbar(gtk.Toolbar):
 
 _EFFECT_GRAYSCALE = 'grayscale'
+_INVERT_COLOR = 'invert-colors'
+
 # Rainbow acts as a tool in Area, and it has to be described as a dict
 _EFFECT_RAINBOW = {
 'name'  : 'rainbow',
@@ -1256,10 +1258,16 @@ class EffectsToolbar(gtk.Toolbar):
 self._effect_rainbow = 
DrawToolButton('effect-rainbow',activity.tool_group,_('Rainbow'))
 self.insert(self._effect_rainbow, -1)
 self._configure_palette(self._effect_rainbow, self._EFFECT_RAINBOW)
-
+
+
 separator = gtk.SeparatorToolItem()
 self.insert(separator, -1)
 
+self._invert_colors = ToolButton('invert-colors')
+self.insert(self._invert_colors, -1)
+self._invert_colors.show()
+self._invert_colors.set_tooltip(_('Invert Colors'))
+
 """
 #FIXME: Must be implemented
 self._black_and_white = ToolButton('black_and_white')
@@ -1267,16 +1275,11 @@ class EffectsToolbar(gtk.Toolbar):
 self._black_and_white.show()
 self._black_and_white.connect('clicked', test_connect, activity, 
'effect-black-and-white')
 self._black_and_whi

[Sugar-devel] [PATCH sugar 05/21] PEP8 cleanup: fix inline comment spacing

2010-10-16 Thread Sascha Silbe
Signed-off-by: Sascha Silbe 

diff --git a/extensions/cpsection/keyboard/model.py 
b/extensions/cpsection/keyboard/model.py
index b7186e2..82456d3 100644
--- a/extensions/cpsection/keyboard/model.py
+++ b/extensions/cpsection/keyboard/model.py
@@ -20,7 +20,7 @@ import xklavier
 import gconf
 
 
-_GROUP_NAME = 'grp' # The XKB name for group switch options
+_GROUP_NAME = 'grp'  # The XKB name for group switch options
 
 _LAYOUTS_KEY = '/desktop/sugar/peripherals/keyboard/layouts'
 _OPTIONS_KEY = '/desktop/sugar/peripherals/keyboard/options'
diff --git a/extensions/cpsection/updater/model.py 
b/extensions/cpsection/updater/model.py
index 7db49fe..1e1dd92 100755
--- a/extensions/cpsection/updater/model.py
+++ b/extensions/cpsection/updater/model.py
@@ -227,7 +227,7 @@ class BundleUpdate(object):
 
 
 class _Downloader(gobject.GObject):
-_CHUNK_SIZE = 10240 # 10K
+_CHUNK_SIZE = 10240  # 10K
 __gsignals__ = {
 'progress': (gobject.SIGNAL_RUN_FIRST,
  gobject.TYPE_NONE,
diff --git a/src/jarabe/desktop/favoriteslayout.py 
b/src/jarabe/desktop/favoriteslayout.py
index 99299fd..430790e 100644
--- a/src/jarabe/desktop/favoriteslayout.py
+++ b/src/jarabe/desktop/favoriteslayout.py
@@ -447,7 +447,8 @@ class SunflowerLayout(RingLayout):
 if y < 0 or y > (height - icon_size) or \
x < 0 or x > (width - icon_size):
 self.skipped_indices.append(index)
-continue # try again
+# try again
+continue
 
 return x, y
 
@@ -484,7 +485,8 @@ class BoxLayout(RingLayout):
 return (90 - d) / 45.
 if d < 225:
 return -1
-return cos_d(360 - d) # mirror around 180
+# mirror around 180
+return cos_d(360 - d)
 
 cos = lambda r: cos_d(math.degrees(r))
 sin = lambda r: cos_d(math.degrees(r) - 90)
@@ -530,7 +532,8 @@ class TriangleLayout(RingLayout):
 return (d + 90) / 120.
 if d <= 90:
 return (90 - d) / 60.
-return -cos_d(180 - d) # mirror around 90
+# mirror around 90
+return -cos_d(180 - d)
 
 sqrt_3 = math.sqrt(3)
 
@@ -541,7 +544,8 @@ class TriangleLayout(RingLayout):
 return ((d + 90) / 120.) * sqrt_3 - 1
 if d <= 90:
 return sqrt_3 - 1
-return sin_d(180 - d) # mirror around 90
+# mirror around 90
+return sin_d(180 - d)
 
 cos = lambda r: cos_d(math.degrees(r))
 sin = lambda r: sin_d(math.degrees(r))
diff --git a/src/jarabe/desktop/homebox.py b/src/jarabe/desktop/homebox.py
index a5d9311..9833873 100644
--- a/src/jarabe/desktop/homebox.py
+++ b/src/jarabe/desktop/homebox.py
@@ -127,7 +127,7 @@ class HomeBox(gtk.VBox):
 else:
 raise ValueError('Invalid view: %r' % view)
 
-_REDRAW_TIMEOUT = 5 * 60 * 1000 # 5 minutes
+_REDRAW_TIMEOUT = 5 * 60 * 1000  # 5 minutes
 
 def resume(self):
 pass
diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py
index 6a84ebf..7b1b539 100644
--- a/src/jarabe/desktop/meshbox.py
+++ b/src/jarabe/desktop/meshbox.py
@@ -552,13 +552,15 @@ class MeshBox(gtk.VBox):
 if self._adhoc_manager is not None and \
 network.is_sugar_adhoc_network(ap.name) and \
 ap.mode == network.NM_802_11_MODE_ADHOC:
-if old_hash is None: # new Ad-hoc network finished initializing
+if old_hash is None:
+# new Ad-hoc network finished initializing
 self._adhoc_manager.add_access_point(ap)
 # we are called as well in other cases but we do not need to
 # act here as we don't display signal strength for Ad-hoc networks
 return
 
-if old_hash is None: # new AP finished initializing
+if old_hash is None:
+# new AP finished initializing
 self._add_ap_to_network(ap)
 return
 
diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
index c8aab18..e2fc020 100644
--- a/src/jarabe/journal/model.py
+++ b/src/jarabe/journal/model.py
@@ -265,7 +265,8 @@ class InplaceResultSet(BaseResultSet):
 if self._sort[1:] == 'filesize':
 keygetter = itemgetter(3)
 else:
-keygetter = itemgetter(2) # timestamp
+# timestamp
+keygetter = itemgetter(2)
 self._file_list.sort(lambda a, b: b - a,
  key=keygetter,
  reverse=(self._sort[0] == '-'))
diff --git a/src/jarabe/model/filetransfer.py b/src/jarabe/model/filetransfer.py
index 45c1bc4..f842345 100644
--- a/src/jarabe/model/filetransfer.py
+++ b/src/jarabe/model/filetransfer.py
@@ -58,7 +58,7 @@ new_file_transfer = dispatch.Signal()
 
 # TODO Move to use splice_async() in Sugar 0.88
 class StreamSp

[Sugar-devel] [PATCH sugar 00/21] style cleanup series

2010-10-16 Thread Sascha Silbe
This is the sugar part of the style cleanups I've wanted to land at
least two releases ago, but kept missing the window.

I have done some basic testing, but naturally cannot test all code
paths I've touched (some even appear to be unused). This is why I'd like
to land this right after we branched off sucrose-0.90: to ensure it gets
enough testing before the next release.

There are a couple of pylint complaints remaining. Some of them are
pylint bugs, but a fair number are things that should be looked at more
closely. One even shows the cause of SL#1748.

Sascha Silbe (21):
  fix EOL spaces
  style cleanup: move globals before class and method definitions
  pep8 cleanup: fix number of blank lines
  PEP8 cleanup: fix spaces around operators and parentheses
  PEP8 cleanup: fix inline comment spacing
  PEP8 cleanup: ensure lines are shorter than 80 characters
  PEP8 cleanup: don't use has_key()
  style cleanup: use """ everywhere
  style cleanup: prefer ' for strings
  pylint cleanup: replace disable-msg with disable
  pylint cleanup: remove unused imports
  use logging.exception() instead of
logging.error(traceback.format_exc())
  pylint cleanup: mark some variables as unused
  pylint cleanup: pass format parameters to log functions instead of
using %
  CurrentActivityPalette: remove dead code
  ignore incorrect pylint error E1101
  pylint cleanup: don't override built-in objects
  pylint cleanup: fix indentation
  jarabe.desktop.schoolserver: mark helper functions and classes as
private
  pylint cleanup: don't override variables from outer scope
  pylint cleanup: disable warnings for reasonable catch-all exception
handlers

 docs/release_howto.txt |   22 +-
 extensions/cpsection/aboutcomputer/__init__.py |1 -
 extensions/cpsection/aboutcomputer/model.py|   31 ++-
 extensions/cpsection/aboutcomputer/view.py |   31 ++--
 extensions/cpsection/aboutme/__init__.py   |2 -
 extensions/cpsection/aboutme/model.py  |   64 +++--
 extensions/cpsection/aboutme/view.py   |   29 +--
 extensions/cpsection/datetime/model.py |   26 ++-
 extensions/cpsection/datetime/view.py  |   42 ++--
 extensions/cpsection/frame/model.py|   28 ++-
 extensions/cpsection/frame/view.py |   76 +++---
 extensions/cpsection/keyboard/__init__.py  |1 -
 extensions/cpsection/keyboard/model.py |   20 +-
 extensions/cpsection/keyboard/view.py  |   65 +++---
 extensions/cpsection/language/__init__.py  |1 -
 extensions/cpsection/language/model.py |   41 ++--
 extensions/cpsection/language/view.py  |   47 ++--
 .../cpsection/modemconfiguration/__init__.py   |1 -
 extensions/cpsection/modemconfiguration/model.py   |   13 +-
 extensions/cpsection/modemconfiguration/view.py|   30 ++-
 extensions/cpsection/network/__init__.py   |3 -
 extensions/cpsection/network/model.py  |   25 ++-
 extensions/cpsection/network/view.py   |   60 +++---
 extensions/cpsection/power/__init__.py |1 -
 extensions/cpsection/power/model.py|   26 ++-
 extensions/cpsection/power/view.py |1 +
 extensions/cpsection/updater/backends/aslo.py  |   14 +-
 extensions/cpsection/updater/model.py  |   18 +-
 extensions/cpsection/updater/view.py   |   16 +-
 extensions/deviceicon/battery.py   |   28 ++-
 extensions/deviceicon/network.py   |   78 ---
 extensions/deviceicon/speaker.py   |   21 +-
 extensions/deviceicon/touchpad.py  |   12 +-
 extensions/deviceicon/volume.py|   11 +-
 extensions/globalkey/screenshot.py |7 +-
 extensions/globalkey/viewsource.py |2 +
 src/jarabe/__init__.py |1 -
 src/jarabe/config.py.in|2 +-
 src/jarabe/controlpanel/__init__.py|1 -
 src/jarabe/controlpanel/cmd.py |   39 ++--
 src/jarabe/controlpanel/gui.py |   37 ++--
 src/jarabe/controlpanel/inlinealert.py |   10 +-
 src/jarabe/controlpanel/sectionview.py |   13 +-
 src/jarabe/controlpanel/toolbar.py |9 +-
 src/jarabe/desktop/__init__.py |1 -
 src/jarabe/desktop/activitieslist.py   |   28 ++-
 src/jarabe/desktop/favoriteslayout.py  |   55 +++--
 src/jarabe/desktop/favoritesview.py|   39 ++--
 src/jarabe/desktop/friendview.py   |2 +-
 src/jarabe/desktop/grid.py |   11 +-
 src/jarabe/desktop/groupbox.py |6 +-
 src/jarabe/desktop/homebox.py  |   23 +-
 src/jarabe/desktop/homewindow.py   |   14 +-
 src/jarabe

[Sugar-devel] [PATCH sugar 14/21] pylint cleanup: pass format parameters to log functions instead of using %

2010-10-16 Thread Sascha Silbe
This avoids the overhead from the string formatting on production systems.

Signed-off-by: Sascha Silbe 

diff --git a/src/jarabe/desktop/favoritesview.py 
b/src/jarabe/desktop/favoritesview.py
index b06f672..e6c2c44 100644
--- a/src/jarabe/desktop/favoritesview.py
+++ b/src/jarabe/desktop/favoritesview.py
@@ -277,7 +277,7 @@ class FavoritesView(hippo.Canvas):
 
 def _set_layout(self, layout):
 if layout not in LAYOUT_MAP:
-logging.warn('Unknown favorites layout: %r' % layout)
+logging.warn('Unknown favorites layout: %r', layout)
 layout = favoriteslayout.RingLayout.key
 assert layout in LAYOUT_MAP
 
diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py
index 8dcd60f..0efce21 100644
--- a/src/jarabe/desktop/meshbox.py
+++ b/src/jarabe/desktop/meshbox.py
@@ -336,8 +336,8 @@ class NetworkManagerObserver(object):
 settings = kwargs['connection'].get_settings()
 net.create_keydialog(settings, kwargs['response'])
 if not found:
-logging.error('Could not determine AP for'
-  ' specific object %s' % conn_o)
+logging.error('Could not determine AP for specific object'
+' %s', conn_o)
 
 def __get_devices_reply_cb(self, devices_o):
 for dev_o in devices_o:
@@ -602,7 +602,7 @@ class MeshBox(gtk.VBox):
 
 # it's not an error if the AP isn't found, since we might have ignored
 # it (e.g. olpc-mesh adhoc network)
-logging.debug('Can not remove access point %s' % ap_o)
+logging.debug('Can not remove access point %s', ap_o)
 
 def add_adhoc_networks(self, device):
 if self._adhoc_manager is None:
diff --git a/src/jarabe/view/keyhandler.py b/src/jarabe/view/keyhandler.py
index cdea52c..d79bfe6 100644
--- a/src/jarabe/view/keyhandler.py
+++ b/src/jarabe/view/keyhandler.py
@@ -223,7 +223,7 @@ class KeyHandler(object):
 return False
 
 def _key_released_cb(self, grabber, keycode, state, event_time):
-logging.debug('_key_released_cb: %i %i' % (keycode, state))
+logging.debug('_key_released_cb: %i %i', keycode, state)
 if self._tabbing_handler.is_tabbing():
 # We stop tabbing and switch to the new window as soon as the
 # modifier key is raised again.
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar 02/21] style cleanup: move globals before class and method definitions

2010-10-16 Thread Sascha Silbe
This only touches the globals that were flagged by pep8 due to white space
issues.

I've also left the sunflower layout variables alone. AFAICT this layout is
currently unused and should be removed instead (or factored out like the snow
flake layout and reenabled).

Signed-off-by: Sascha Silbe 

diff --git a/src/jarabe/desktop/favoritesview.py 
b/src/jarabe/desktop/favoritesview.py
index ada55e0..d582433 100644
--- a/src/jarabe/desktop/favoritesview.py
+++ b/src/jarabe/desktop/favoritesview.py
@@ -61,6 +61,9 @@ LAYOUT_MAP = {favoriteslayout.RingLayout.key: 
favoriteslayout.RingLayout,
 `FavoritesLayout` which implement the layouts.  Additional information
 about the layout can be accessed with fields of the class."""
 
+_favorites_settings = None
+
+
 class FavoritesView(hippo.Canvas):
 __gtype_name__ = 'SugarFavoritesView'
 
@@ -659,7 +662,6 @@ class FavoritesSetting(object):
 
 layout = property(get_layout, set_layout)
 
-_favorites_settings = None
 
 def get_settings():
 global _favorites_settings
diff --git a/src/jarabe/desktop/homewindow.py b/src/jarabe/desktop/homewindow.py
index fec4289..ae970be 100644
--- a/src/jarabe/desktop/homewindow.py
+++ b/src/jarabe/desktop/homewindow.py
@@ -33,6 +33,9 @@ _GROUP_PAGE  = 1
 _MESH_PAGE   = 2
 _TRANSITION_PAGE = 3
 
+_instance = None
+
+
 class HomeWindow(gtk.Window):
 def __init__(self):
 logging.debug('STARTUP: Loading the desktop window')
@@ -183,7 +186,6 @@ class HomeWindow(gtk.Window):
 def get_home_box(self):
 return self._home_box
 
-_instance = None
 
 def get_instance():
 global _instance
diff --git a/src/jarabe/desktop/keydialog.py b/src/jarabe/desktop/keydialog.py
index 1e6d17a..a83f77b 100644
--- a/src/jarabe/desktop/keydialog.py
+++ b/src/jarabe/desktop/keydialog.py
@@ -27,6 +27,11 @@ from jarabe.model.network import Secrets
 IW_AUTH_ALG_OPEN_SYSTEM = 'open'
 IW_AUTH_ALG_SHARED_KEY  = 'shared'
 
+WEP_PASSPHRASE = 1
+WEP_HEX = 2
+WEP_ASCII = 3
+
+
 def string_is_hex(key):
 is_hex = True
 for c in key:
@@ -108,9 +113,6 @@ class KeyDialog(gtk.Dialog):
 def get_response_object(self):
 return self._response
 
-WEP_PASSPHRASE = 1
-WEP_HEX = 2
-WEP_ASCII = 3
 
 class WEPKeyDialog(KeyDialog):
 def __init__(self, ssid, flags, wpa_flags, rsn_flags, dev_caps, settings,
diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py
index 036f00a..18e3b1c 100644
--- a/src/jarabe/desktop/meshbox.py
+++ b/src/jarabe/desktop/meshbox.py
@@ -59,6 +59,9 @@ _NM_ACTIVE_CONN_IFACE = 
'org.freedesktop.NetworkManager.Connection.Active'
 _AP_ICON_NAME = 'network-wireless'
 _OLPC_MESH_ICON_NAME = 'network-mesh'
 
+_AUTOSEARCH_TIMEOUT = 1000
+
+
 class ActivityView(hippo.CanvasBox):
 def __init__(self, model):
 hippo.CanvasBox.__init__(self)
@@ -148,8 +151,6 @@ class ActivityView(hippo.CanvasBox):
 if hasattr(icon, 'set_filter'):
 icon.set_filter(query)
 
-_AUTOSEARCH_TIMEOUT = 1000
-
 
 class MeshToolbar(gtk.Toolbar):
 __gtype_name__ = 'MeshToolbar'
diff --git a/src/jarabe/frame/clipboard.py b/src/jarabe/frame/clipboard.py
index 3b9f745..8e237dd 100644
--- a/src/jarabe/frame/clipboard.py
+++ b/src/jarabe/frame/clipboard.py
@@ -26,6 +26,10 @@ from sugar import mime
 
 from jarabe.frame.clipboardobject import ClipboardObject, Format
 
+
+_instance = None
+
+
 class Clipboard(gobject.GObject):
 
 __gsignals__ = {
@@ -140,7 +144,6 @@ class Clipboard(gobject.GObject):
 
 return 'file://' + new_file_path
 
-_instance = None
 
 def get_instance():
 global _instance
diff --git a/src/jarabe/journal/journalactivity.py 
b/src/jarabe/journal/journalactivity.py
index 44cc018..c0d792d 100644
--- a/src/jarabe/journal/journalactivity.py
+++ b/src/jarabe/journal/journalactivity.py
@@ -52,6 +52,9 @@ J_DBUS_PATH = '/org/laptop/Journal'
 _SPACE_TRESHOLD = 52428800
 _BUNDLE_ID = 'org.laptop.JournalActivity'
 
+_journal = None
+
+
 class JournalActivityDBusService(dbus.service.Object):
 def __init__(self, parent):
 self._parent = parent
@@ -358,7 +361,6 @@ class JournalActivity(Window):
 self.show_main_view()
 self.search_grab_focus()
 
-_journal = None
 
 def get_journal():
 global _journal
diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
index 81ca7d4..bbc3778 100644
--- a/src/jarabe/journal/model.py
+++ b/src/jarabe/journal/model.py
@@ -44,6 +44,12 @@ PROPERTIES = ['uid', 'title', 'mtime', 'timestamp', 
'creation_time', 'filesize',
 MIN_PAGES_TO_CACHE = 3
 MAX_PAGES_TO_CACHE = 5
 
+_datastore = None
+created = dispatch.Signal()
+updated = dispatch.Signal()
+deleted = dispatch.Signal()
+
+
 class _Cache(object):
 
 __gtype_name__ = 'model_Cache'
@@ -356,7 +362,7 @@ def _get_file_metadata(path, stat):
 'icon-color': client.get_string('/desktop/sugar/user/color'),
 'description': path}
 
-_datastore = None
+
 def _get_datastore():
 global _datastore
 if _datastore i

[Sugar-devel] [PATCH sugar 01/21] fix EOL spaces

2010-10-16 Thread Sascha Silbe
Signed-off-by: Sascha Silbe 

diff --git a/extensions/cpsection/aboutcomputer/model.py 
b/extensions/cpsection/aboutcomputer/model.py
index 898d79c..77d3b86 100644
--- a/extensions/cpsection/aboutcomputer/model.py
+++ b/extensions/cpsection/aboutcomputer/model.py
@@ -40,7 +40,7 @@ def get_serial_number():
 if serial_no is None:
 serial_no = _not_available
 return serial_no
-
+
 def print_serial_number():
 serial_no = get_serial_number()
 if serial_no is None:
@@ -71,7 +71,7 @@ def get_build_number():
 def print_build_number():
 print get_build_number()
 
-def get_firmware_number():
+def get_firmware_number():
 firmware_no = _read_file('/ofw/openprom/model')
 if firmware_no is None:
 firmware_no = _not_available
@@ -79,9 +79,9 @@ def get_firmware_number():
 firmware_no = re.split(" +", firmware_no)
 if len(firmware_no) == 3:
 firmware_no = firmware_no[1]
-return firmware_no
+return firmware_no
 
-def print_firmware_number():
+def print_firmware_number():
 print get_firmware_number()
 
 def get_wireless_firmware():
diff --git a/extensions/cpsection/aboutcomputer/view.py 
b/extensions/cpsection/aboutcomputer/view.py
index b6ff43f..39bacfb 100644
--- a/extensions/cpsection/aboutcomputer/view.py
+++ b/extensions/cpsection/aboutcomputer/view.py
@@ -68,7 +68,7 @@ class AboutComputer(SectionView):
 box_identity = gtk.HBox(spacing=style.DEFAULT_SPACING)
 label_serial = gtk.Label(_('Serial Number:'))
 label_serial.set_alignment(1, 0)
-label_serial.modify_fg(gtk.STATE_NORMAL, 
+label_serial.modify_fg(gtk.STATE_NORMAL,
style.COLOR_SELECTION_GREY.get_gdk_color())
 box_identity.pack_start(label_serial, expand=False)
 self._group.add_widget(label_serial)
@@ -83,7 +83,7 @@ class AboutComputer(SectionView):
 self._vbox.pack_start(vbox_identity, expand=False)
 vbox_identity.show()
 
-def _setup_software(self):   
+def _setup_software(self):
 separator_software = gtk.HSeparator()
 self._vbox.pack_start(separator_software, expand=False)
 separator_software.show()
@@ -99,7 +99,7 @@ class AboutComputer(SectionView):
 box_build = gtk.HBox(spacing=style.DEFAULT_SPACING)
 label_build = gtk.Label(_('Build:'))
 label_build.set_alignment(1, 0)
-label_build.modify_fg(gtk.STATE_NORMAL, 
+label_build.modify_fg(gtk.STATE_NORMAL,
   style.COLOR_SELECTION_GREY.get_gdk_color())
 box_build.pack_start(label_build, expand=False)
 self._group.add_widget(label_build)
@@ -130,7 +130,7 @@ class AboutComputer(SectionView):
 box_firmware = gtk.HBox(spacing=style.DEFAULT_SPACING)
 label_firmware = gtk.Label(_('Firmware:'))
 label_firmware.set_alignment(1, 0)
-label_firmware.modify_fg(gtk.STATE_NORMAL, 
+label_firmware.modify_fg(gtk.STATE_NORMAL,
   style.COLOR_SELECTION_GREY.get_gdk_color())
 box_firmware.pack_start(label_firmware, expand=False)
 self._group.add_widget(label_firmware)
diff --git a/extensions/cpsection/aboutme/model.py 
b/extensions/cpsection/aboutme/model.py
index 8500799..078fff4 100644
--- a/extensions/cpsection/aboutme/model.py
+++ b/extensions/cpsection/aboutme/model.py
@@ -27,14 +27,14 @@ _COLORS = {'red': {'dark':'#b20008', 'medium':'#e6000a', 
'light':'#ffadce'},
}
 
 _MODIFIERS = ('dark', 'medium', 'light')
-
+
 def get_nick():
 client = gconf.client_get_default()
 return client.get_string("/desktop/sugar/user/nick")
 
 def print_nick():
 print get_nick()
-
+
 def set_nick(nick):
 """Set the nickname.
 nick : e.g. 'walter'
@@ -64,16 +64,16 @@ def print_color():
 if _COLORS[color][hue] == tmp[1]:
 fill_tuple = (color, hue)
 
-if stroke_tuple is not None:
-print _('stroke:   color=%s hue=%s') % (stroke_tuple[0], 
+if stroke_tuple is not None:
+print _('stroke:   color=%s hue=%s') % (stroke_tuple[0],
 stroke_tuple[1])
 else:
-print _('stroke:   %s') % (tmp[0])
-if fill_tuple is not None:
+print _('stroke:   %s') % (tmp[0])
+if fill_tuple is not None:
 print _('fill: color=%s hue=%s') % (fill_tuple[0], fill_tuple[1])
 else:
 print _('fill: %s') % (tmp[1])
-
+
 def set_color(stroke, fill, stroke_modifier='medium', fill_modifier='medium'):
 """Set the system color by setting a fill and stroke color.
 fill : [red, orange, yellow, blue, green, purple]
@@ -81,20 +81,20 @@ def set_color(stroke, fill, stroke_modifier='medium', 
fill_modifier='medium'):
 hue stroke : [dark, medium, light] (optional)
 hue fill : [dark, medium, light] (optional)
 """
-
+
  

[Sugar-devel] [PATCH sugar 20/21] pylint cleanup: don't override variables from outer scope

2010-10-16 Thread Sascha Silbe
If two different entities have the same name, things get messy.

Signed-off-by: Sascha Silbe 

diff --git a/src/jarabe/desktop/schoolserver.py 
b/src/jarabe/desktop/schoolserver.py
index 720fc40..aea2357 100644
--- a/src/jarabe/desktop/schoolserver.py
+++ b/src/jarabe/desktop/schoolserver.py
@@ -50,7 +50,7 @@ def _generate_serial_number():
 return serial
 
 
-def _store_identifiers(serial_number, uuid, backup_url):
+def _store_identifiers(serial_number, uuid_, backup_url):
 """  Stores the serial number, uuid and backup_url
 in the identifier folder inside the profile directory
 so that these identifiers can be used for backup. """
@@ -68,7 +68,7 @@ def _store_identifiers(serial_number, uuid, backup_url):
 if os.path.exists(os.path.join(identifier_path, 'uuid')):
 os.remove(os.path.join(identifier_path, 'uuid'))
 uuid_file = open(os.path.join(identifier_path, 'uuid'), 'w')
-uuid_file.write(uuid)
+uuid_file.write(uuid_)
 uuid_file.close()
 
 if os.path.exists(os.path.join(identifier_path, 'backup_url')):
diff --git a/src/jarabe/model/filetransfer.py b/src/jarabe/model/filetransfer.py
index f842345..710c3a4 100644
--- a/src/jarabe/model/filetransfer.py
+++ b/src/jarabe/model/filetransfer.py
@@ -356,11 +356,12 @@ def file_transfer_available():
 if __name__ == '__main__':
 import tempfile
 
-input_stream = gio.File('/home/tomeu/isos/Soas2-200904031934.iso').read()
-output_stream = gio.File(tempfile.mkstemp()[1]).append_to()
+test_file_name = '/home/tomeu/isos/Soas2-200904031934.iso'
+test_input_stream = gio.File(test_file_name).read()
+test_output_stream = gio.File(tempfile.mkstemp()[1]).append_to()
 
 # TODO: Use splice_async when it gets implemented
-splicer = StreamSplicer(input_stream, output_stream)
+splicer = StreamSplicer(test_input_stream, test_output_stream)
 splicer.start()
 
 loop = gobject.MainLoop()
diff --git a/src/jarabe/model/friends.py b/src/jarabe/model/friends.py
index c85bdb7..8f13da8 100644
--- a/src/jarabe/model/friends.py
+++ b/src/jarabe/model/friends.py
@@ -49,7 +49,7 @@ class FriendBuddyModel(BuddyModel):
 if buddy is not None:
 self._set_online_buddy(buddy)
 
-def __buddy_added_cb(self, neighborhood, buddy):
+def __buddy_added_cb(self, model_, buddy):
 if buddy.key != self.key:
 return
 self._set_online_buddy(buddy)
@@ -60,7 +60,7 @@ class FriendBuddyModel(BuddyModel):
 self.notify('color')
 self.notify('present')
 
-def __buddy_removed_cb(self, neighborhood, buddy):
+def __buddy_removed_cb(self, model_, buddy):
 if buddy.key != self.key:
 return
 self._online_buddy = None
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar 21/21] pylint cleanup: disable warnings for reasonable catch-all exception handlers

2010-10-16 Thread Sascha Silbe
Signed-off-by: Sascha Silbe 

diff --git a/src/jarabe/model/bundleregistry.py 
b/src/jarabe/model/bundleregistry.py
index 1edee8f..931c59b 100644
--- a/src/jarabe/model/bundleregistry.py
+++ b/src/jarabe/model/bundleregistry.py
@@ -216,6 +216,7 @@ class BundleRegistry(gobject.GObject):
 try:
 self._add_bundle(folder)
 except:
+# pylint: disable=W0702
 logging.exception('Error while processing installed activity'
 ' bundle %s:', folder)
 
diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
index 4ae7ea8..6590ed1 100644
--- a/src/jarabe/model/network.py
+++ b/src/jarabe/model/network.py
@@ -569,6 +569,7 @@ class NMSettingsConnection(dbus.service.Object):
 res_init = getattr(libc, '__res_init')
 res_init(None)
 except:
+# pylint: disable=W0702
 logging.exception('Error calling libc.__res_init')
 
 def set_secrets(self, secrets):
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar 06/21] PEP8 cleanup: ensure lines are shorter than 80 characters

2010-10-16 Thread Sascha Silbe
This is important for Sugar because the XO has a small screen where long lines
would make the code hard to understand (because you need to constantly scroll 
horizontally).

Signed-off-by: Sascha Silbe 

diff --git a/extensions/cpsection/datetime/view.py 
b/extensions/cpsection/datetime/view.py
index 72fdad1..9c70e9f 100644
--- a/extensions/cpsection/datetime/view.py
+++ b/extensions/cpsection/datetime/view.py
@@ -51,7 +51,8 @@ class TimeZone(SectionView):
 self._entry.show()
 
 self._scrolled_window = gtk.ScrolledWindow()
-self._scrolled_window.set_policy(gtk.POLICY_NEVER, 
gtk.POLICY_AUTOMATIC)
+self._scrolled_window.set_policy(gtk.POLICY_NEVER,
+gtk.POLICY_AUTOMATIC)
 self._scrolled_window.set_shadow_type(gtk.SHADOW_IN)
 
 self._store = gtk.ListStore(gobject.TYPE_STRING)
diff --git a/extensions/cpsection/frame/view.py 
b/extensions/cpsection/frame/view.py
index 5c9d473..8b4ab83 100644
--- a/extensions/cpsection/frame/view.py
+++ b/extensions/cpsection/frame/view.py
@@ -149,9 +149,9 @@ class Frame(SectionView):
 self._corner_delay_is_valid = True
 self._edge_delay_is_valid = True
 self.needs_restart = False
-self._corner_delay_change_handler = self._corner_delay_slider.connect( 
\
+self._corner_delay_change_handler = self._corner_delay_slider.connect(
 'value-changed', self.__corner_delay_changed_cb)
-self._edge_delay_change_handler = self._edge_delay_slider.connect( \
+self._edge_delay_change_handler = self._edge_delay_slider.connect(
 'value-changed', self.__edge_delay_changed_cb)
 
 def undo(self):
diff --git a/extensions/cpsection/keyboard/model.py 
b/extensions/cpsection/keyboard/model.py
index 82456d3..4f44aff 100644
--- a/extensions/cpsection/keyboard/model.py
+++ b/extensions/cpsection/keyboard/model.py
@@ -77,8 +77,8 @@ class KeyboardManager(object):
 def get_options_group(self):
 """Return list of supported options for switching keyboard group"""
 options = []
-self._configregistry.foreach_option(_GROUP_NAME, self._populate_one, \
-
options)
+self._configregistry.foreach_option(_GROUP_NAME, self._populate_one,
+options)
 options.sort()
 return options
 
diff --git a/extensions/cpsection/keyboard/view.py 
b/extensions/cpsection/keyboard/view.py
index dacc092..d1d9af2 100644
--- a/extensions/cpsection/keyboard/view.py
+++ b/extensions/cpsection/keyboard/view.py
@@ -241,7 +241,8 @@ class Keyboard(SectionView):
 return False
 
 def _setup_group_switch_option(self):
-"""Adds the controls for changing the group switch option of 
keyboard"""
+"""Adds the controls for changing the group switch option of keyboard
+"""
 separator_group_option = gtk.HSeparator()
 self._vbox.pack_start(separator_group_option, expand=False)
 separator_group_option.show_all()
diff --git a/extensions/cpsection/language/view.py 
b/extensions/cpsection/language/view.py
index 1bd77f8..c56ffee 100644
--- a/extensions/cpsection/language/view.py
+++ b/extensions/cpsection/language/view.py
@@ -54,9 +54,9 @@ class Language(SectionView):
 self.set_border_width(style.DEFAULT_SPACING * 2)
 self.set_spacing(style.DEFAULT_SPACING)
 
-explanation = gettext.gettext("Add languages in the order you prefer." 
\
-  " If a translation is not 
available,"\
-  " the next in the list will be 
used.")
+explanation = gettext.gettext('Add languages in the order you prefer.'
+' If a translation is not available, the next in the list will be'
+' used.')
 self._text = gtk.Label(explanation)
 self._text.set_width_chars(100)
 self._text.set_line_wrap(True)
diff --git a/extensions/cpsection/network/view.py 
b/extensions/cpsection/network/view.py
index 447a51d..fc3c993 100644
--- a/extensions/cpsection/network/view.py
+++ b/extensions/cpsection/network/view.py
@@ -228,7 +228,7 @@ class Network(SectionView):
 if self._jabber_sid:
 gobject.source_remove(self._jabber_sid)
 self._jabber_sid = gobject.timeout_add(_APPLY_TIMEOUT,
-   self.__jabber_timeout_cb, 
widget)
+self.__jabber_timeout_cb, widget)
 
 def __jabber_timeout_cb(self, widget):
 self._jabber_sid = 0
diff --git a/extensions/cpsection/updater/model.py 
b/extensions/cpsection/updater/model.py
index 1e1dd92..21b0b65 100755
--- a/extensions/cpsection/updater/model.py
+++ b/extensions/cpsection/updater/model.py
@@ -196,14 +196,17 @@ class UpdateModel(gobject.GObject):
 logging.debug('UpdateModel._cancel_checking')
 total = len(bundleregistry.get_registry())
 current = total - len(self._bu

[Sugar-devel] [PATCH sugar 18/21] pylint cleanup: fix indentation

2010-10-16 Thread Sascha Silbe
Signed-off-by: Sascha Silbe 

diff --git a/src/jarabe/desktop/activitieslist.py 
b/src/jarabe/desktop/activitieslist.py
index e97d5b0..6c9c764 100644
--- a/src/jarabe/desktop/activitieslist.py
+++ b/src/jarabe/desktop/activitieslist.py
@@ -420,8 +420,8 @@ class ActivityListPalette(ActivityPalette):
 menu_item.show()
 
 if not os.access(activity_info.get_path(), os.W_OK) or \
-registry.is_activity_protected(self._bundle_id):
-menu_item.props.sensitive = False
+registry.is_activity_protected(self._bundle_id):
+menu_item.props.sensitive = False
 
 def __destroy_cb(self, palette):
 self.disconnect(self._activity_changed_sid)
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar 12/21] use logging.exception() instead of logging.error(traceback.format_exc())

2010-10-16 Thread Sascha Silbe
logging.exception() handles exceptions nicely for us, no need to explicitly
use traceback.

Signed-off-by: Sascha Silbe 

diff --git a/extensions/cpsection/updater/backends/aslo.py 
b/extensions/cpsection/updater/backends/aslo.py
index 016e5e8..eec54b0 100644
--- a/extensions/cpsection/updater/backends/aslo.py
+++ b/extensions/cpsection/updater/backends/aslo.py
@@ -129,7 +129,7 @@ class _UpdateFetcher(object):
 try:
 version = int(document.find(_FIND_VERSION).text)
 except ValueError:
-logging.error(traceback.format_exc())
+logging.exception('Exception occured while parsing version')
 version = 0
 
 link = document.find(_FIND_LINK).text
@@ -137,7 +137,7 @@ class _UpdateFetcher(object):
 try:
 size = long(document.find(_FIND_SIZE).text) * 1024
 except ValueError:
-logging.error(traceback.format_exc())
+logging.exception('Exception occured while parsing size')
 size = 0
 
 global _fetcher
diff --git a/src/jarabe/controlpanel/cmd.py b/src/jarabe/controlpanel/cmd.py
index 56fff5c..531f132 100644
--- a/src/jarabe/controlpanel/cmd.py
+++ b/src/jarabe/controlpanel/cmd.py
@@ -18,7 +18,6 @@ import sys
 import getopt
 import os
 from gettext import gettext as _
-import traceback
 import logging
 
 from jarabe import config
@@ -69,8 +68,7 @@ def load_modules():
 module = __import__('.'.join(('cpsection', item, 'model')),
 globals(), locals(), ['model'])
 except Exception:
-logging.error('Exception while loading extension:\n' + \
-''.join(traceback.format_exception(*sys.exc_info(
+logging.exception('Exception while loading extension:')
 else:
 modules.append(module)
 
diff --git a/src/jarabe/frame/devicestray.py b/src/jarabe/frame/devicestray.py
index c26cc6c..91135f6 100644
--- a/src/jarabe/frame/devicestray.py
+++ b/src/jarabe/frame/devicestray.py
@@ -15,8 +15,6 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 import os
-import sys
-import traceback
 import logging
 
 from sugar.graphics import tray
@@ -36,8 +34,7 @@ class DevicesTray(tray.HTray):
  locals(), [module_name])
 mod.setup(self)
 except Exception:
-logging.error('Exception while loading extension:\n' + \
-''.join(traceback.format_exception(*sys.exc_info(
+logging.exception('Exception while loading extension:')
 
 def add_device(self, view):
 index = 0
diff --git a/src/jarabe/journal/journalactivity.py 
b/src/jarabe/journal/journalactivity.py
index 3de3bf1..c5772b1 100644
--- a/src/jarabe/journal/journalactivity.py
+++ b/src/jarabe/journal/journalactivity.py
@@ -17,8 +17,6 @@
 
 import logging
 from gettext import gettext as _
-import sys
-import traceback
 import uuid
 
 import gtk
@@ -229,8 +227,7 @@ class JournalActivity(Window):
 try:
 self._detail_toolbox.entry_toolbar.set_metadata(metadata)
 except Exception:
-logging.error('Exception while displaying entry:\n' + \
-''.join(traceback.format_exception(*sys.exc_info(
+logging.exception('Exception while displaying entry:')
 
 self.set_toolbar_box(self._detail_toolbox)
 self._detail_toolbox.show()
@@ -238,8 +235,7 @@ class JournalActivity(Window):
 try:
 self._detail_view.props.metadata = metadata
 except Exception:
-logging.error('Exception while displaying entry:\n' + \
-''.join(traceback.format_exception(*sys.exc_info(
+logging.exception('Exception while displaying entry:')
 
 self.set_canvas(self._secondary_view)
 self._secondary_view.show()
diff --git a/src/jarabe/model/bundleregistry.py 
b/src/jarabe/model/bundleregistry.py
index 5ae95dd..1edee8f 100644
--- a/src/jarabe/model/bundleregistry.py
+++ b/src/jarabe/model/bundleregistry.py
@@ -17,7 +17,6 @@
 
 import os
 import logging
-import traceback
 
 import gconf
 import gobject
@@ -208,19 +207,17 @@ class BundleRegistry(gobject.GObject):
 if os.path.isdir(bundle_dir):
 bundles[bundle_dir] = os.stat(bundle_dir).st_mtime
 except Exception:
-logging.error('Error while processing installed activity ' \
-  'bundle %s:\n%s' % \
-(bundle_dir, traceback.format_exc()))
+logging.exception('Error while processing installed activity'
+' bundle %s:', bundle_dir)
 
 bundle_dirs = bundles.keys()
 bundle_dirs.sort(lambda d1, d2: cmp(bundles[d1], bundles[d2]))
 for folder in bundle_dir

[Sugar-devel] [PATCH sugar 19/21] jarabe.desktop.schoolserver: mark helper functions and classes as private

2010-10-16 Thread Sascha Silbe
Only register_laptop and RegisterError are meant to be public API. Proper
marking of private / public makes it easier to see which code changes break
API (or not).

Signed-off-by: Sascha Silbe 

diff --git a/src/jarabe/desktop/schoolserver.py 
b/src/jarabe/desktop/schoolserver.py
index 1a10b16..720fc40 100644
--- a/src/jarabe/desktop/schoolserver.py
+++ b/src/jarabe/desktop/schoolserver.py
@@ -30,11 +30,11 @@ import gconf
 from sugar import env
 from sugar.profile import get_profile
 
-REGISTER_URL = 'http://schoolserver:8080/'
-REGISTER_TIMEOUT = 8
+_REGISTER_URL = 'http://schoolserver:8080/'
+_REGISTER_TIMEOUT = 8
 
 
-def generate_serial_number():
+def _generate_serial_number():
 """  Generates a serial number based on 3 random uppercase letters
 and the last 8 digits of the current unix seconds. """
 
@@ -50,7 +50,7 @@ def generate_serial_number():
 return serial
 
 
-def store_identifiers(serial_number, uuid, backup_url):
+def _store_identifiers(serial_number, uuid, backup_url):
 """  Stores the serial number, uuid and backup_url
 in the identifier folder inside the profile directory
 so that these identifiers can be used for backup. """
@@ -82,7 +82,7 @@ class RegisterError(Exception):
 pass
 
 
-class TimeoutHTTP(httplib.HTTP):
+class _TimeoutHTTP(httplib.HTTP):
 
 def __init__(self, host='', port=None, strict=None, timeout=None):
 if port == 0:
@@ -90,40 +90,40 @@ class TimeoutHTTP(httplib.HTTP):
 # FIXME: Depending on undocumented internals that can break between
 # Python releases. Please have a look at SL #2350
 self._setup(self._connection_class(host,
- port, strict, timeout=REGISTER_TIMEOUT))
+ port, strict, timeout=_REGISTER_TIMEOUT))
 
 
-class TimeoutTransport(xmlrpclib.Transport):
+class _TimeoutTransport(xmlrpclib.Transport):
 
 def make_connection(self, host):
 host, extra_headers, x509_ = self.get_host_info(host)
-return _TimeoutHTTP(host, timeout=REGISTER_TIMEOUT)
+return _TimeoutHTTP(host, timeout=_REGISTER_TIMEOUT)
 
 
-def register_laptop(url=REGISTER_URL):
+def register_laptop(url=_REGISTER_URL):
 
 profile = get_profile()
 client = gconf.client_get_default()
 
-if have_ofw_tree():
-sn = read_ofw('mfg-data/SN')
-uuid_ = read_ofw('mfg-data/U#')
+if _have_ofw_tree():
+sn = _read_ofw('mfg-data/SN')
+uuid_ = _read_ofw('mfg-data/U#')
 sn = sn or 'SHF'
 uuid_ = uuid_ or '----'
 else:
-sn = generate_serial_number()
+sn = _generate_serial_number()
 uuid_ = str(uuid.uuid1())
 
 setting_name = '/desktop/sugar/collaboration/jabber_server'
 jabber_server = client.get_string(setting_name)
-store_identifiers(sn, uuid_, jabber_server)
+_store_identifiers(sn, uuid_, jabber_server)
 
 if jabber_server:
 url = 'http://' + jabber_server + ':8080/'
 
 nick = client.get_string('/desktop/sugar/user/nick')
 
-server = xmlrpclib.ServerProxy(url, TimeoutTransport())
+server = xmlrpclib.ServerProxy(url, _TimeoutTransport())
 try:
 data = server.register(sn, nick, uuid_, profile.pubkey)
 except (xmlrpclib.Error, TypeError, socket.error):
@@ -142,11 +142,11 @@ def register_laptop(url=REGISTER_URL):
 return True
 
 
-def have_ofw_tree():
+def _have_ofw_tree():
 return os.path.exists('/ofw')
 
 
-def read_ofw(path):
+def _read_ofw(path):
 path = os.path.join('/ofw', path)
 if not os.path.exists(path):
 return None
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar 07/21] PEP8 cleanup: don't use has_key()

2010-10-16 Thread Sascha Silbe
has_key() has been deprecated for quite some time now.

Signed-off-by: Sascha Silbe 

diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py
index 99734a2..1b3ccda 100644
--- a/src/jarabe/desktop/meshbox.py
+++ b/src/jarabe/desktop/meshbox.py
@@ -119,7 +119,7 @@ class ActivityView(hippo.CanvasBox):
 return p
 
 def has_buddy_icon(self, key):
-return self._icons.has_key(key)
+return key in self._icons
 
 def __buddy_added_cb(self, activity, buddy):
 self._add_buddy(buddy)
diff --git a/src/jarabe/frame/friendstray.py b/src/jarabe/frame/friendstray.py
index b387e06..31a9809 100644
--- a/src/jarabe/frame/friendstray.py
+++ b/src/jarabe/frame/friendstray.py
@@ -50,7 +50,7 @@ class FriendsTray(VTray):
  self.__neighborhood_activity_added_cb)
 
 def add_buddy(self, buddy):
-if self._buddies.has_key(buddy.props.key):
+if buddy.props.key in self._buddies:
 return
 
 icon = FriendIcon(buddy)
@@ -60,7 +60,7 @@ class FriendsTray(VTray):
 self._buddies[buddy.props.key] = icon
 
 def remove_buddy(self, buddy):
-if not self._buddies.has_key(buddy.props.key):
+if buddy.props.key not in self._buddies:
 return
 
 self.remove_item(self._buddies[buddy.props.key])
diff --git a/src/jarabe/journal/expandedentry.py 
b/src/jarabe/journal/expandedentry.py
index 9271313..0c60600 100644
--- a/src/jarabe/journal/expandedentry.py
+++ b/src/jarabe/journal/expandedentry.py
@@ -212,9 +212,7 @@ class ExpandedEntry(hippo.CanvasBox):
 height = style.zoom(240)
 box = hippo.CanvasBox()
 
-if self._metadata.has_key('preview') and \
-len(self._metadata['preview']) > 4:
-
+if len(self._metadata.get('preview', '')) > 4:
 if self._metadata['preview'][1:4] == 'PNG':
 preview_data = self._metadata['preview']
 else:
@@ -304,8 +302,7 @@ class ExpandedEntry(hippo.CanvasBox):
 
 vbox.append(text)
 
-if self._metadata.has_key('buddies') and \
-self._metadata['buddies']:
+if self._metadata.get('buddies'):
 buddies = simplejson.loads(self._metadata['buddies']).values()
 vbox.append(BuddyList(buddies))
 return vbox
diff --git a/src/jarabe/journal/journalentrybundle.py 
b/src/jarabe/journal/journalentrybundle.py
index 9ce676e..c220c09 100644
--- a/src/jarabe/journal/journalentrybundle.py
+++ b/src/jarabe/journal/journalentrybundle.py
@@ -42,7 +42,7 @@ class JournalEntryBundle(Bundle):
 Bundle.__init__(self, path)
 
 def install(self, uid=''):
-if os.environ.has_key('SUGAR_ACTIVITY_ROOT'):
+if 'SUGAR_ACTIVITY_ROOT' in os.environ:
 install_dir = os.path.join(os.environ['SUGAR_ACTIVITY_ROOT'],
'data')
 else:
diff --git a/src/jarabe/journal/misc.py b/src/jarabe/journal/misc.py
index 31f14b2..b65e20e 100644
--- a/src/jarabe/journal/misc.py
+++ b/src/jarabe/journal/misc.py
@@ -86,14 +86,15 @@ def get_icon_name(metadata):
 
 def get_date(metadata):
 """ Convert from a string in iso format to a more human-like format. """
-if metadata.has_key('timestamp'):
+if 'timestamp' in metadata:
 timestamp = float(metadata['timestamp'])
 return util.timestamp_to_elapsed_string(timestamp)
-elif metadata.has_key('mtime'):
+
+if 'mtime' in metadata:
 ti = time.strptime(metadata['mtime'], "%Y-%m-%dT%H:%M:%S")
 return util.timestamp_to_elapsed_string(time.mktime(ti))
-else:
-return _('No date')
+
+return _('No date')
 
 
 def get_bundle(metadata):
diff --git a/src/jarabe/journal/palettes.py b/src/jarabe/journal/palettes.py
index 71f133d..429a244 100644
--- a/src/jarabe/journal/palettes.py
+++ b/src/jarabe/journal/palettes.py
@@ -54,7 +54,7 @@ class ObjectPalette(Palette):
 activity_icon.props.file = misc.get_icon_name(metadata)
 activity_icon.props.xo_color = misc.get_icon_color(metadata)
 
-if metadata.has_key('title'):
+if 'title' in metadata:
 title = gobject.markup_escape_text(metadata['title'])
 else:
 title = _('Untitled')
diff --git a/src/jarabe/model/bundleregistry.py 
b/src/jarabe/model/bundleregistry.py
index 0eda7be..5ae95dd 100644
--- a/src/jarabe/model/bundleregistry.py
+++ b/src/jarabe/model/bundleregistry.py
@@ -289,10 +289,7 @@ class BundleRegistry(gobject.GObject):
 return result
 
 def get_default_for_type(self, mime_type):
-if self._mime_defaults.has_key(mime_type):
-return self._mime_defaults[mime_type]
-else:
-return None
+return self._mime_defaults.get(mime_type)
 
 def _find_bundle(self, bundle_id, version):
 for bundle in self._bundles:
diff --git a/src/jarabe/model/friends.py b/src/jarabe/model/friends.py
index 4d34b65..5a3778

[Sugar-devel] [PATCH sugar 10/21] pylint cleanup: replace disable-msg with disable

2010-10-16 Thread Sascha Silbe
Adapt to upstream format change.

Signed-off-by: Sascha Silbe 

diff --git a/src/jarabe/config.py.in b/src/jarabe/config.py.in
index 6c418e9..d22ee9a 100644
--- a/src/jarabe/config.py.in
+++ b/src/jarabe/config.py.in
@@ -14,7 +14,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-# pylint: disable-msg=C0301
+# pylint: disable=C0301
 
 prefix = '@prefix@'
 data_path = '@prefix@/share/sugar/data'
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar 17/21] pylint cleanup: don't override built-in objects

2010-10-16 Thread Sascha Silbe
Signed-off-by: Sascha Silbe 

diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
index a3a003f..ffec677 100644
--- a/extensions/deviceicon/network.py
+++ b/extensions/deviceicon/network.py
@@ -697,8 +697,8 @@ class OlpcMeshDeviceView(ToolButton):
 try:
 obj = self._bus.get_object(_NM_IFACE, ap_op)
 props = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')
-type = props.Get(_NM_DEVICE_IFACE, 'DeviceType')
-if type == network.DEVICE_TYPE_802_11_OLPC_MESH:
+device_type = props.Get(_NM_DEVICE_IFACE, 'DeviceType')
+if device_type == network.DEVICE_TYPE_802_11_OLPC_MESH:
 netmgr.DeactivateConnection(conn_o)
 break
 except dbus.exceptions.DBusException:
diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py
index 0efce21..09b5e20 100644
--- a/src/jarabe/desktop/meshbox.py
+++ b/src/jarabe/desktop/meshbox.py
@@ -523,25 +523,25 @@ class MeshBox(gtk.VBox):
 # add AP to its corresponding network icon on the desktop,
 # creating one if it doesn't already exist
 def _add_ap_to_network(self, ap):
-hash = ap.network_hash()
-if hash in self.wireless_networks:
-self.wireless_networks[hash].add_ap(ap)
+hash_value = ap.network_hash()
+if hash_value in self.wireless_networks:
+self.wireless_networks[hash_value].add_ap(ap)
 else:
 # this is a new network
 icon = WirelessNetworkView(ap)
-self.wireless_networks[hash] = icon
+self.wireless_networks[hash_value] = icon
 self._layout.add(icon)
 if hasattr(icon, 'set_filter'):
 icon.set_filter(self._query)
 
-def _remove_net_if_empty(self, net, hash):
+def _remove_net_if_empty(self, net, hash_value):
 # remove a network if it has no APs left
 if net.num_aps() == 0:
 net.disconnect()
 self._layout.remove(net)
-del self.wireless_networks[hash]
+del self.wireless_networks[hash_value]
 
-def _ap_props_changed_cb(self, ap, old_hash):
+def _ap_props_changed_cb(self, ap, old_hash_value):
 # if we have mesh hardware, ignore OLPC mesh networks that appear as
 # normal wifi networks
 if len(self._mesh) > 0 and ap.mode == network.NM_802_11_MODE_ADHOC \
@@ -553,28 +553,29 @@ class MeshBox(gtk.VBox):
 if self._adhoc_manager is not None and \
 network.is_sugar_adhoc_network(ap.name) and \
 ap.mode == network.NM_802_11_MODE_ADHOC:
-if old_hash is None:
+if old_hash_value is None:
 # new Ad-hoc network finished initializing
 self._adhoc_manager.add_access_point(ap)
 # we are called as well in other cases but we do not need to
 # act here as we don't display signal strength for Ad-hoc networks
 return
 
-if old_hash is None:
+if old_hash_value is None:
 # new AP finished initializing
 self._add_ap_to_network(ap)
 return
 
-hash = ap.network_hash()
-if old_hash == hash:
+hash_value = ap.network_hash()
+if old_hash_value == hash_value:
 # no change in network identity, so just update signal strengths
-self.wireless_networks[hash].update_strength()
+self.wireless_networks[hash_value].update_strength()
 return
 
 # properties change includes a change of the identity of the network
 # that it is on. so create this as a new network.
-self.wireless_networks[old_hash].remove_ap(ap)
-self._remove_net_if_empty(self.wireless_networks[old_hash], old_hash)
+self.wireless_networks[old_hash_value].remove_ap(ap)
+self._remove_net_if_empty(self.wireless_networks[old_hash_value],
+old_hash_value)
 self._add_ap_to_network(ap)
 
 def add_access_point(self, device, ap_o):
@@ -636,7 +637,7 @@ class MeshBox(gtk.VBox):
 
 # the OLPC mesh can be recognised as a "normal" wifi network. remove
 # any such normal networks if they have been created
-for hash, net in self.wireless_networks.iteritems():
+for hash_value, net in self.wireless_networks.iteritems():
 if not net.is_olpc_mesh():
 continue
 
@@ -644,7 +645,7 @@ class MeshBox(gtk.VBox):
 net.remove_all_aps()
 net.disconnect()
 self._layout.remove(net)
-del self.wireless_networks[hash]
+del self.wireless_networks[hash_value]
 
 def disable_olpc_mesh(self, mesh_device):
 for icon in self._mesh:
-- 
1.7.1

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

[Sugar-devel] [PATCH sugar 15/21] CurrentActivityPalette: remove dead code

2010-10-16 Thread Sascha Silbe
__active_window_changed_cb() is not referenced anywhere and contains broken
code.

Signed-off-by: Sascha Silbe 

diff --git a/src/jarabe/view/palettes.py b/src/jarabe/view/palettes.py
index cb30ed8..d9c1f6b 100644
--- a/src/jarabe/view/palettes.py
+++ b/src/jarabe/view/palettes.py
@@ -108,10 +108,6 @@ class CurrentActivityPalette(BasePalette):
 self._home_activity.get_window().activate( \
 gtk.get_current_event_time())
 
-def __active_window_changed_cb(self, screen, previous_window=None):
-setup_view_source()
-self._screen.disconnect(self._active_window_changed_sid)
-
 def __stop_activate_cb(self, menu_item):
 self._home_activity.get_window().close(1)
 
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar 11/21] pylint cleanup: remove unused imports

2010-10-16 Thread Sascha Silbe
Signed-off-by: Sascha Silbe 

diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
index 8c86fca..a3a003f 100644
--- a/extensions/deviceicon/network.py
+++ b/extensions/deviceicon/network.py
@@ -23,7 +23,6 @@ import logging
 import hashlib
 import socket
 import struct
-import re
 import datetime
 import time
 import gtk
@@ -40,12 +39,9 @@ from sugar.graphics.tray import TrayIcon
 from sugar.graphics.menuitem import MenuItem
 from sugar.graphics.icon import Icon
 from sugar.graphics import xocolor
-from sugar.util import unique_id
 from sugar import profile
 
 from jarabe.model import network
-from jarabe.model.network import Settings
-from jarabe.model.network import IP4Config
 from jarabe.frame.frameinvoker import FrameWidgetInvoker
 from jarabe.view.pulsingicon import PulsingIcon
 
diff --git a/extensions/globalkey/screenshot.py 
b/extensions/globalkey/screenshot.py
index b9408d4..0afe964 100644
--- a/extensions/globalkey/screenshot.py
+++ b/extensions/globalkey/screenshot.py
@@ -17,7 +17,6 @@
 
 import os
 import tempfile
-import time
 from gettext import gettext as _
 
 import gtk
diff --git a/src/jarabe/controlpanel/gui.py b/src/jarabe/controlpanel/gui.py
index 0d87e28..bb9fa28 100644
--- a/src/jarabe/controlpanel/gui.py
+++ b/src/jarabe/controlpanel/gui.py
@@ -17,8 +17,6 @@
 import os
 import logging
 from gettext import gettext as _
-import sys
-import traceback
 
 import gobject
 import gtk
diff --git a/src/jarabe/desktop/activitieslist.py 
b/src/jarabe/desktop/activitieslist.py
index 8a7b8f3..e97d5b0 100644
--- a/src/jarabe/desktop/activitieslist.py
+++ b/src/jarabe/desktop/activitieslist.py
@@ -30,12 +30,9 @@ from sugar.graphics.icon import Icon, CellRendererIcon
 from sugar.graphics.xocolor import XoColor
 from sugar.graphics.menuitem import MenuItem
 from sugar.graphics.alert import Alert
-from sugar.activity import activityfactory
-from sugar.activity.activityhandle import ActivityHandle
 
 from jarabe.model import bundleregistry
 from jarabe.view.palettes import ActivityPalette
-from jarabe.view import launcher
 from jarabe.journal import misc
 
 
diff --git a/src/jarabe/desktop/favoritesview.py 
b/src/jarabe/desktop/favoritesview.py
index e3fd671..b06f672 100644
--- a/src/jarabe/desktop/favoritesview.py
+++ b/src/jarabe/desktop/favoritesview.py
@@ -30,7 +30,6 @@ from sugar.graphics.menuitem import MenuItem
 from sugar.graphics.alert import Alert
 from sugar.graphics.xocolor import XoColor
 from sugar.activity import activityfactory
-from sugar.activity.activityhandle import ActivityHandle
 from sugar import dispatch
 from sugar.datastore import datastore
 
@@ -38,7 +37,6 @@ from jarabe.view.palettes import JournalPalette
 from jarabe.view.palettes import CurrentActivityPalette, ActivityPalette
 from jarabe.view.buddyicon import BuddyIcon
 from jarabe.view.buddymenu import BuddyMenu
-from jarabe.view import launcher
 from jarabe.model.buddy import get_owner_instance
 from jarabe.model import shell
 from jarabe.model import bundleregistry
diff --git a/src/jarabe/journal/listmodel.py b/src/jarabe/journal/listmodel.py
index fb34c6a..55f83f4 100644
--- a/src/jarabe/journal/listmodel.py
+++ b/src/jarabe/journal/listmodel.py
@@ -19,7 +19,6 @@ import logging
 import simplejson
 import gobject
 import gtk
-import time
 from gettext import gettext as _
 
 from sugar.graphics.xocolor import XoColor
diff --git a/src/jarabe/journal/palettes.py b/src/jarabe/journal/palettes.py
index 429a244..f3be519 100644
--- a/src/jarabe/journal/palettes.py
+++ b/src/jarabe/journal/palettes.py
@@ -28,7 +28,6 @@ from sugar.graphics.icon import Icon
 from sugar.graphics.xocolor import XoColor
 from sugar import mime
 
-from jarabe.model import bundleregistry
 from jarabe.model import friends
 from jarabe.model import filetransfer
 from jarabe.model import mimeregistry
diff --git a/src/jarabe/view/palettes.py b/src/jarabe/view/palettes.py
index db86465..cb30ed8 100644
--- a/src/jarabe/view/palettes.py
+++ b/src/jarabe/view/palettes.py
@@ -28,8 +28,6 @@ from sugar.graphics.menuitem import MenuItem
 from sugar.graphics.icon import Icon
 from sugar.graphics import style
 from sugar.graphics.xocolor import XoColor
-from sugar.activity import activityfactory
-from sugar.activity.activityhandle import ActivityHandle
 
 from jarabe.model import shell
 from jarabe.view.viewsource import setup_view_source
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar 16/21] ignore incorrect pylint error E1101

2010-10-16 Thread Sascha Silbe
pylint isn't smart enough to figure out the contents of ParseResult and
gtk.Invisible, so squelch the warning.

Signed-off-by: Sascha Silbe 

diff --git a/src/jarabe/frame/clipboard.py b/src/jarabe/frame/clipboard.py
index 65872ef..be2b902 100644
--- a/src/jarabe/frame/clipboard.py
+++ b/src/jarabe/frame/clipboard.py
@@ -130,16 +130,17 @@ class Clipboard(gobject.GObject):
 
 def _copy_file(self, original_uri):
 uri = urlparse.urlparse(original_uri)
-path_, file_name = os.path.split(uri.path)
+path = uri.path  # pylint: disable=E1101
+directory_, file_name = os.path.split(path)
 
 root, ext = os.path.splitext(file_name)
 if not ext or ext == '.':
-mime_type = mime.get_for_file(uri.path)
+mime_type = mime.get_for_file(path)
 ext = '.' + mime.get_primary_extension(mime_type)
 
 f_, new_file_path = tempfile.mkstemp(ext, root)
 del f_
-shutil.copyfile(uri.path, new_file_path)
+shutil.copyfile(path, new_file_path)
 os.chmod(new_file_path, 0644)
 
 return 'file://' + new_file_path
diff --git a/src/jarabe/frame/clipboardmenu.py 
b/src/jarabe/frame/clipboardmenu.py
index 03c953b..d11538d 100644
--- a/src/jarabe/frame/clipboardmenu.py
+++ b/src/jarabe/frame/clipboardmenu.py
@@ -213,7 +213,8 @@ class ClipboardMenu(Palette):
 if most_significant_mime_type == 'text/uri-list':
 uris = mime.split_uri_list(format_.get_data())
 if len(uris) == 1 and uris[0].startswith('file://'):
-file_path = urlparse.urlparse(uris[0]).path
+parsed_url = urlparse.urlparse(uris[0])
+file_path = parsed_url.path  # pylint: disable=E1101
 transfer_ownership = False
 mime_type = mime.get_for_file(file_path)
 else:
@@ -222,7 +223,8 @@ class ClipboardMenu(Palette):
 mime_type = 'text/uri-list'
 else:
 if format_.is_on_disk():
-file_path = urlparse.urlparse(format_.get_data()).path
+parsed_url = urlparse.urlparse(format_.get_data())
+file_path = parsed_url.path  # pylint: disable=E1101
 transfer_ownership = False
 mime_type = mime.get_for_file(file_path)
 else:
diff --git a/src/jarabe/frame/clipboardobject.py 
b/src/jarabe/frame/clipboardobject.py
index 90f64e7..407af2f 100644
--- a/src/jarabe/frame/clipboardobject.py
+++ b/src/jarabe/frame/clipboardobject.py
@@ -106,11 +106,13 @@ class ClipboardObject(object):
 if format_ == 'text/uri-list':
 data = self._formats['text/uri-list'].get_data()
 uri = urlparse.urlparse(mime.split_uri_list(data)[0], 'file')
-if uri.scheme == 'file':
-if os.path.exists(uri.path):
-format_ = mime.get_for_file(uri.path)
+scheme = uri.scheme  # pylint: disable=E1101
+if scheme == 'file':
+path = uri.path  # pylint: disable=E1101
+if os.path.exists(path):
+format_ = mime.get_for_file(path)
 else:
-format_ = mime.get_from_file_name(uri.path)
+format_ = mime.get_from_file_name(path)
 logging.debug('Chose %r!', format_)
 
 return format_
@@ -128,8 +130,9 @@ class Format(object):
 def destroy(self):
 if self._on_disk:
 uri = urlparse.urlparse(self._data)
-if os.path.isfile(uri.path):
-os.remove(uri.path)
+path = uri.path  # pylint: disable=E1101
+if os.path.isfile(path):
+os.remove(path)
 
 def get_type(self):
 return self._type
diff --git a/src/jarabe/frame/eventarea.py b/src/jarabe/frame/eventarea.py
index 1b06d74..b505829 100644
--- a/src/jarabe/frame/eventarea.py
+++ b/src/jarabe/frame/eventarea.py
@@ -95,9 +95,9 @@ class EventArea(gobject.GObject):
 invisible.connect('drag_leave', self._drag_leave_cb)
 
 invisible.realize()
+# pylint: disable=E1101
 invisible.window.set_events(gtk.gdk.POINTER_MOTION_MASK |
-gtk.gdk.ENTER_NOTIFY_MASK |
-gtk.gdk.LEAVE_NOTIFY_MASK)
+gtk.gdk.ENTER_NOTIFY_MASK | gtk.gdk.LEAVE_NOTIFY_MASK)
 invisible.window.move_resize(x, y, width, height)
 
 return invisible
-- 
1.7.1

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


[Sugar-devel] [PATCH sugar 08/21] style cleanup: use """ everywhere

2010-10-16 Thread Sascha Silbe
Most of the code uses """, so adjust the few deviations.

Signed-off-by: Sascha Silbe 

diff --git a/docs/release_howto.txt b/docs/release_howto.txt
index db877e0..841809a 100644
--- a/docs/release_howto.txt
+++ b/docs/release_howto.txt
@@ -1,7 +1,7 @@
-''' This is the release process of the sugar tarballs sugar(shell), 
+""" This is the release process of the sugar tarballs sugar(shell),
 sugar-toolkit and sugar-base described in a pytish way and
 instructions for sugar packagers
-'''
+"""
 
 # Release sugar tarballs
 
@@ -10,9 +10,9 @@ for package in [sugar, sugar-toolkit, sugar-base, 
sugar-artwork]:
 Pull the latest sources.
 Increase the version number in configure.ac
 # this will create you a tarball and does a check if it builds fine
-# e.g. it will check if all the files containing translations are 
+# e.g. it will check if all the files containing translations are
 # in po/POTFILES.in
-make distcheck 
+make distcheck
 
 if that succeed:
 # commit the change, log it as "Release [version_number]" (e.g. 0.79.1)
@@ -26,7 +26,7 @@ for package in [sugar, sugar-toolkit, sugar-base, 
sugar-artwork]:
 break
 
 # Upload the package
-Upload the tarball to 
+Upload the tarball to
 
shell.sugarlabs.org:/pub/sugarlabs/sources/sucrose/glucose/$name/$name-$version
 
 # Verify the upload of the package
@@ -34,16 +34,16 @@ for package in [sugar, sugar-toolkit, sugar-base, 
sugar-artwork]:
 
http://download.sugarlabs.org/sources/sucrose/glucose/$name/$name-$version
 
 # Package sugar for Fedora
-# - For announcements of the Sucrose release subscribe at the sugar-devel 
+# - For announcements of the Sucrose release subscribe at the sugar-devel
 #   mailing list; you can filter for the [ANNOUNCE] tag
-# - Uploaded tarballs can be found at: 
+# - Uploaded tarballs can be found at:
 #   glucose: 
http://download.sugarlabs.org/sources/sucrose/glucose/$name/$name-$version
 #   fructose: 
http://download.sugarlabs.org/sources/sucrose/fructose/$name/$name-$version
 #   more about the taxonomy: http://sugarlabs.org/go/Taxonomy
-   
-# more info on fedora packaging: 
+
+# more info on fedora packaging:
 # http://fedoraproject.org/wiki/PackageMaintainers/UpdatingPackageHowTo
-# request permissions to contribute to the fedora package: 
+# request permissions to contribute to the fedora package:
 # https://admin.fedoraproject.org/pkgdb/packages/name/[package]
 
 if not cvs_package:
@@ -70,4 +70,4 @@ cvs commit -F clog
 make tag
 make build
 
-# Do the same for the other branches e.g. devel 
+# Do the same for the other branches e.g. devel
diff --git a/extensions/cpsection/datetime/model.py 
b/extensions/cpsection/datetime/model.py
index 0a68fd7..dc17168 100644
--- a/extensions/cpsection/datetime/model.py
+++ b/extensions/cpsection/datetime/model.py
@@ -28,7 +28,7 @@ _zone_tab = '/usr/share/zoneinfo/zone.tab'
 
 
 def _initialize():
-'''Initialize the docstring of the set function'''
+"""Initialize the docstring of the set function"""
 if set_timezone.__doc__ is None:
 # when running under 'python -OO', all __doc__ fields are None,
 # so += would fail -- and this function would be unnecessary anyway.
diff --git a/extensions/cpsection/keyboard/view.py 
b/extensions/cpsection/keyboard/view.py
index d1d9af2..b020d50 100644
--- a/extensions/cpsection/keyboard/view.py
+++ b/extensions/cpsection/keyboard/view.py
@@ -360,7 +360,7 @@ class Keyboard(SectionView):
 i += 1
 
 def __create_add_remove_box(self):
-'''Creates gtk.Hbox with add/remove buttons'''
+"""Creates gtk.Hbox with add/remove buttons"""
 add_icon = Icon(icon_name='list-add')
 
 add_button = gtk.Button()
diff --git a/extensions/cpsection/language/view.py 
b/extensions/cpsection/language/view.py
index c56ffee..1b9ed93 100644
--- a/extensions/cpsection/language/view.py
+++ b/extensions/cpsection/language/view.py
@@ -87,7 +87,7 @@ class Language(SectionView):
 self.setup()
 
 def _add_row(self, locale_code=None):
-'''Adds a row to the table'''
+"""Adds a row to the table"""
 
 self._selected_lang_count += 1
 
@@ -149,7 +149,7 @@ class Language(SectionView):
 ypadding=padding)
 
 def _delete_last_row(self):
-'''Deletes the last row of the table'''
+"""Deletes the last row of the table"""
 
 self._selected_lang_count -= 1
 
@@ -180,7 +180,7 @@ class Language(SectionView):
 self._lang_alert.hide()
 
 def _create_add_remove_box(self):
-'''Creates gtk.Hbox with add/remove buttons'''
+"""Creates gtk.Hbox with add/remove buttons"""
 add_icon = Icon(icon_name='list-add')
 
 add_button = gtk.Button()
diff --git a/extensions/cpsection/updater/backends/aslo.py 
b/extensions/cpsection/updater/backends/aslo.py
index cf2994f..016e5e8 100644
--- a/extensions/cpsection/updater/backends/aslo.py
+++ b/ex

[Sugar-devel] [PATCH sugar 13/21] pylint cleanup: mark some variables as unused

2010-10-16 Thread Sascha Silbe
Follow the convention of marking known-unused (but required for
de-marshalling purposes) variables by postfixing them with an underscore.

Signed-off-by: Sascha Silbe 

diff --git a/src/jarabe/desktop/favoriteslayout.py 
b/src/jarabe/desktop/favoriteslayout.py
index 8f15861..a0323bb 100644
--- a/src/jarabe/desktop/favoriteslayout.py
+++ b/src/jarabe/desktop/favoriteslayout.py
@@ -257,13 +257,13 @@ class RingLayout(FavoritesLayout):
 
 self._spiral_mode = True
 icon_size = style.STANDARD_ICON_SIZE
-angle, radius = self._calculate_angle_and_radius(children_count,
-   icon_size)
+angle_, radius = self._calculate_angle_and_radius(children_count,
+icon_size)
 while radius > _MAXIMUM_RADIUS:
 i = _ICON_SIZES.index(icon_size)
 if i < len(_ICON_SIZES) - 1:
 icon_size = _ICON_SIZES[i + 1]
-angle, radius = self._calculate_angle_and_radius(
+angle_, radius = self._calculate_angle_and_radius(
 children_count, icon_size)
 else:
 break
@@ -304,7 +304,7 @@ class RingLayout(FavoritesLayout):
 _ICON_SPACING_FACTORS[_ICON_SIZES.index(icon_size)]
 angle = _INITIAL_ANGLE
 radius = _MINIMUM_RADIUS - (icon_size * _MIMIMUM_RADIUS_ENCROACHMENT)
-for i in range(icon_count):
+for i_ in range(icon_count):
 circumference = radius * 2 * math.pi
 n = circumference / icon_spacing
 angle += (2 * math.pi / n)
diff --git a/src/jarabe/desktop/schoolserver.py 
b/src/jarabe/desktop/schoolserver.py
index 5388466..1a10b16 100644
--- a/src/jarabe/desktop/schoolserver.py
+++ b/src/jarabe/desktop/schoolserver.py
@@ -96,8 +96,8 @@ class TimeoutHTTP(httplib.HTTP):
 class TimeoutTransport(xmlrpclib.Transport):
 
 def make_connection(self, host):
-host, extra_headers, x509 = self.get_host_info(host)
-return TimeoutHTTP(host, timeout=REGISTER_TIMEOUT)
+host, extra_headers, x509_ = self.get_host_info(host)
+return _TimeoutHTTP(host, timeout=REGISTER_TIMEOUT)
 
 
 def register_laptop(url=REGISTER_URL):
-- 
1.7.1

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


Re: [Sugar-devel] Weekly test request reminders? (was Re: Priorities for testing)

2010-10-16 Thread Tom Parker
On Wed, 2010-10-13 at 16:10 +0200, Simon Schampijer wrote:

> I am doing XO builds containing the latest Sugar (0.90) for the XO [2].
> 
> So given from your information, that should be a good way for you to 
> test 0.90.

Indeed, we are testing these builds. Thanks for preparing them.



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