From 496090fe62191da435044a3102378ab4dbadbda1 Mon Sep 17 00:00:00 2001 From: Sascha Silbe Date: Mon, 24 Aug 2009 12:54:02 +0200 Subject: [PATCH] let the logger do the formatting --- src/sugar/activity/activity.py | 32 +++++++++++++-------------- src/sugar/activity/activityfactory.py | 18 +++++++-------- src/sugar/activity/activityservice.py | 2 +- src/sugar/bundle/activitybundle.py | 16 +++++++------- src/sugar/bundle/bundle.py | 2 +- src/sugar/datastore/datastore.py | 2 +- src/sugar/datastore/dbus_helpers.py | 12 +++++----- src/sugar/graphics/icon.py | 4 ++-- src/sugar/graphics/objectchooser.py | 4 ++-- src/sugar/graphics/palette.py | 2 +- src/sugar/graphics/palettewindow.py | 2 +- src/sugar/graphics/toolbarbox.py | 2 +- src/sugar/presence/presenceservice.py | 4 ++-- src/sugar/profile.py | 8 +++---- src/sugar/util.py | 6 ++--- 15 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/sugar/activity/activity.py b/src/sugar/activity/activity.py index f20d402b..05c5b001 100644 --- a/src/sugar/activity/activity.py +++ b/src/sugar/activity/activity.py @@ -305,8 +305,8 @@ class Activity(Window, gtk.Container): else: self.__joined_cb(self.shared_activity, True, None) elif share_scope != SCOPE_PRIVATE: - logging.debug("*** Act %s no existing mesh instance, but used to " \ - "be shared, will share" % self._activity_id) + logging.debug('*** Act %s no existing mesh instance, but used to ' + 'be shared, will share', self._activity_id) # no existing mesh instance, but activity used to be shared, so # restart the share if share_scope == SCOPE_INVITE_ONLY: @@ -314,7 +314,7 @@ class Activity(Window, gtk.Container): elif share_scope == SCOPE_NEIGHBORHOOD: self.share(private=False) else: - logging.debug("Unknown share scope %r" % share_scope) + logging.debug('Unknown share scope %r', share_scope) if handle.object_id is None and create_jobject: logging.debug('Creating a jobject.') @@ -409,7 +409,7 @@ class Activity(Window, gtk.Container): pass def __jobject_error_cb(self, err): - logging.debug("Error creating activity datastore object: %s" % err) + logging.debug('Error creating activity datastore object: %s', err) def get_activity_root(self): """ FIXME: Deprecated. This part of the API has been moved @@ -486,13 +486,13 @@ class Activity(Window, gtk.Container): if self._closing: self._show_keep_failed_dialog() self._closing = False - logging.debug("Error saving activity object to datastore: %s" % err) + logging.debug('Error saving activity object to datastore: %s', err) def _cleanup_jobject(self): if self._jobject: if self._owns_file and os.path.isfile(self._jobject.file_path): - logging.debug('_cleanup_jobject: removing %r' % - self._jobject.file_path) + logging.debug('_cleanup_jobject: removing %r', + self._jobject.file_path) os.remove(self._jobject.file_path) self._owns_file = False self._jobject.destroy() @@ -550,7 +550,7 @@ class Activity(Window, gtk.Container): logging.debug('Cannot save, no journal object.') return - logging.debug('Activity.save: %r' % self._jobject.object_id) + logging.debug('Activity.save: %r', self._jobject.object_id) if self._updating_jobject: logging.info('Activity.save: still processing a previous request.') @@ -594,7 +594,7 @@ class Activity(Window, gtk.Container): Activities should not override this method. Instead, like save() do any copy work that needs to be done in write_file() """ - logging.debug('Activity.copy: %r' % self._jobject.object_id) + logging.debug('Activity.copy: %r', self._jobject.object_id) self.save() self._jobject.object_id = None @@ -609,7 +609,7 @@ class Activity(Window, gtk.Container): self.shared_activity.disconnect(self._join_id) self._join_id = None if not success: - logging.debug("Failed to join activity: %s" % err) + logging.debug('Failed to join activity: %s', err) return self.present() @@ -633,8 +633,8 @@ class Activity(Window, gtk.Container): self._pservice.disconnect(self._share_id) self._share_id = None if not success: - logging.debug('Share of activity %s failed: %s.' % - (self._activity_id, err)) + logging.debug('Share of activity %s failed: %s.', + self._activity_id, err) return logging.debug('Share of activity %s successful, PS activity is %r.', @@ -652,7 +652,7 @@ class Activity(Window, gtk.Container): def _invite_response_cb(self, error): if error: - logging.error('Invite failed: %s' % error) + logging.error('Invite failed: %s', error) def _send_invites(self): while self._invites_queue: @@ -662,7 +662,7 @@ class Activity(Window, gtk.Container): self.shared_activity.invite( buddy, '', self._invite_response_cb) else: - logging.error('Cannot invite %s, no such buddy.' % buddy_key) + logging.error('Cannot invite %s, no such buddy.', buddy_key) def invite(self, buddy_key): """Invite a buddy to join this Activity. @@ -692,8 +692,8 @@ class Activity(Window, gtk.Container): raise RuntimeError("Activity %s already shared." % self._activity_id) verb = private and 'private' or 'public' - logging.debug('Requesting %s share of activity %s.' % - (verb, self._activity_id)) + logging.debug('Requesting %s share of activity %s.', verb, + self._activity_id) self._share_id = self._pservice.connect("activity-shared", self.__share_cb) self._pservice.share_activity(self, private=private) diff --git a/src/sugar/activity/activityfactory.py b/src/sugar/activity/activityfactory.py index dcd840ff..d731c3ad 100644 --- a/src/sugar/activity/activityfactory.py +++ b/src/sugar/activity/activityfactory.py @@ -143,7 +143,7 @@ def get_command(activity, activity_id=None, object_id=None, uri=None): if os.path.exists(absolute_path): command[0] = absolute_path - logging.debug('launching: %r' % command) + logging.debug('launching: %r', command) return command @@ -300,25 +300,25 @@ class ActivityCreationHandler(gobject.GObject): pass def _notify_launch_failure_error_handler(self, err): - logging.error('Notify launch failure failed %s' % err) + logging.error('Notify launch failure failed %s', err) def _notify_launch_error_handler(self, err): - logging.debug('Notify launch failed %s' % err) + logging.debug('Notify launch failed %s', err) def _activate_reply_handler(self, activated): if not activated: self._create_activity() def _activate_error_handler(self, err): - logging.error("Activity activation request failed %s" % err) + logging.error('Activity activation request failed %s', err) def _create_reply_handler(self): - logging.debug("Activity created %s (%s)." % - (self._handle.activity_id, self._service_name)) + logging.debug('Activity created %s (%s).', + self._handle.activity_id, self._service_name) def _create_error_handler(self, err): - logging.error("Couldn't create activity %s (%s): %s" % - (self._handle.activity_id, self._service_name, err)) + logging.error("Couldn't create activity %s (%s): %s", + self._handle.activity_id, self._service_name, err) self._shell.NotifyLaunchFailure( self._handle.activity_id, reply_handler=self._no_reply_handler, error_handler=self._notify_launch_failure_error_handler) @@ -331,7 +331,7 @@ class ActivityCreationHandler(gobject.GObject): self._launch_activity() def _find_object_error_handler(self, err): - logging.error("Datastore find failed %s" % err) + logging.error('Datastore find failed %s', err) self._launch_activity() def create(bundle, activity_handle=None): diff --git a/src/sugar/activity/activityservice.py b/src/sugar/activity/activityservice.py index ff806f33..20cf7fef 100644 --- a/src/sugar/activity/activityservice.py +++ b/src/sugar/activity/activityservice.py @@ -61,7 +61,7 @@ class ActivityService(dbus.service.Object): @dbus.service.method(_ACTIVITY_INTERFACE) def SetActive(self, active): - logging.debug('ActivityService.set_active: %s.' % active) + logging.debug('ActivityService.set_active: %s.', active) self._activity.props.active = active @dbus.service.method(_ACTIVITY_INTERFACE) diff --git a/src/sugar/bundle/activitybundle.py b/src/sugar/bundle/activitybundle.py index 7877229b..6f4f5789 100644 --- a/src/sugar/bundle/activitybundle.py +++ b/src/sugar/bundle/activitybundle.py @@ -110,21 +110,21 @@ class ActivityBundle(Bundle): # Remove duplicates if line in lines[0:num]: lines[num] = "" - logging.warning("Bundle %s: duplicate entry in MANIFEST: %s" - % (self._name,line)) + logging.warning('Bundle %s: duplicate entry in MANIFEST: %s', + self._name, line) continue # Remove MANIFEST if line == "MANIFEST": lines[num] = "" - logging.warning("Bundle %s: MANIFEST includes itself: %s" - % (self._name,line)) + logging.warning('Bundle %s: MANIFEST includes itself: %s', + self._name, line) # Remove invalid files if not self.is_file(line): lines[num] = "" - logging.warning("Bundle %s: invalid entry in MANIFEST: %s" - % (self._name,line)) + logging.warning('Bundle %s: invalid entry in MANIFEST: %s', + self._name, line) return lines @@ -311,8 +311,8 @@ class ActivityBundle(Bundle): if path in manifestfiles: manifestfiles.remove(path) elif path != "MANIFEST": - logging.warning("Bundle %s: %s not in MANIFEST"% - (self._name,path)) + logging.warning('Bundle %s: %s not in MANIFEST', self._name, + path) if strict_manifest: os.remove(os.path.join(install_path, path)) diff --git a/src/sugar/bundle/bundle.py b/src/sugar/bundle/bundle.py index a1b26864..5979d5b4 100644 --- a/src/sugar/bundle/bundle.py +++ b/src/sugar/bundle/bundle.py @@ -121,7 +121,7 @@ class Bundle(object): data = self._zip_file.read(path) f = StringIO.StringIO(data) except KeyError: - logging.debug('%s not found.' % filename) + logging.debug('%s not found.', filename) return f diff --git a/src/sugar/datastore/datastore.py b/src/sugar/datastore/datastore.py index 80d5936b..1217c6ae 100644 --- a/src/sugar/datastore/datastore.py +++ b/src/sugar/datastore/datastore.py @@ -183,7 +183,7 @@ def write(ds_object, update_mtime=True, transfer_ownership=False, transfer_ownership) ds_object.metadata['uid'] = ds_object.object_id # TODO: register the object for updates - logging.debug('Written object %s to the datastore.' % ds_object.object_id) + logging.debug('Written object %s to the datastore.', ds_object.object_id) def delete(object_id): logging.debug('datastore.delete') diff --git a/src/sugar/datastore/dbus_helpers.py b/src/sugar/datastore/dbus_helpers.py index 9115382d..94bf68a5 100644 --- a/src/sugar/datastore/dbus_helpers.py +++ b/src/sugar/datastore/dbus_helpers.py @@ -52,8 +52,8 @@ def update(uid, properties, filename, transfer_ownership=False, debug_props = properties.copy() if debug_props.has_key("preview"): debug_props["preview"] = "" - logging.debug('dbus_helpers.update: %s, %s, %s, %s' % - (uid, filename, debug_props, transfer_ownership)) + logging.debug('dbus_helpers.update: %s, %s, %s, %s', uid, filename, + debug_props, transfer_ownership) if reply_handler and error_handler: _get_data_store().update(uid, dbus.Dictionary(properties), filename, transfer_ownership, @@ -65,20 +65,20 @@ def update(uid, properties, filename, transfer_ownership=False, filename, transfer_ownership) def delete(uid): - logging.debug('dbus_helpers.delete: %r' % uid) + logging.debug('dbus_helpers.delete: %r', uid) _get_data_store().delete(uid) def get_properties(uid): - logging.debug('dbus_helpers.get_properties: %s' % uid) + logging.debug('dbus_helpers.get_properties: %s', uid) return _get_data_store().get_properties(uid, byte_arrays=True) def get_filename(uid): filename = _get_data_store().get_filename(uid) - logging.debug('dbus_helpers.get_filename: %s, %s' % (uid, filename)) + logging.debug('dbus_helpers.get_filename: %s, %s', uid, filename) return filename def find(query, properties, reply_handler, error_handler): - logging.debug('dbus_helpers.find: %r %r' % (query, properties)) + logging.debug('dbus_helpers.find: %r %r', query, properties) if reply_handler and error_handler: return _get_data_store().find(query, properties, reply_handler=reply_handler, error_handler=error_handler, diff --git a/src/sugar/graphics/icon.py b/src/sugar/graphics/icon.py index 27907751..51bb584a 100644 --- a/src/sugar/graphics/icon.py +++ b/src/sugar/graphics/icon.py @@ -143,8 +143,8 @@ class _IconBuffer(object): del info else: - logging.warning('No icon with the name %s ' - 'was found in the theme.' % self.icon_name) + logging.warning('No icon with the name %s was found in the ' + 'theme.', self.icon_name) return icon_info diff --git a/src/sugar/graphics/objectchooser.py b/src/sugar/graphics/objectchooser.py index fb3703de..aa46738b 100644 --- a/src/sugar/graphics/objectchooser.py +++ b/src/sugar/graphics/objectchooser.py @@ -110,7 +110,7 @@ class ObjectChooser(object): def __chooser_response_cb(self, chooser_id, object_id): if chooser_id != self._chooser_id: return - logging.debug('ObjectChooser.__chooser_response_cb: %r' % object_id) + logging.debug('ObjectChooser.__chooser_response_cb: %r', object_id) self._response_code = gtk.RESPONSE_ACCEPT self._object_id = object_id self._cleanup() @@ -118,7 +118,7 @@ class ObjectChooser(object): def __chooser_cancelled_cb(self, chooser_id): if chooser_id != self._chooser_id: return - logging.debug('ObjectChooser.__chooser_cancelled_cb: %r' % chooser_id) + logging.debug('ObjectChooser.__chooser_cancelled_cb: %r', chooser_id) self._response_code = gtk.RESPONSE_CANCEL self._cleanup() diff --git a/src/sugar/graphics/palette.py b/src/sugar/graphics/palette.py index cd188401..6a6a5d82 100644 --- a/src/sugar/graphics/palette.py +++ b/src/sugar/graphics/palette.py @@ -179,7 +179,7 @@ class Palette(PaletteWindow): return self._full_request def popup(self, immediate=False, state=None): - logging.debug('Palette.popup immediate %r' % immediate) + logging.debug('Palette.popup immediate %r', immediate) if self._invoker is not None: self._update_full_request() diff --git a/src/sugar/graphics/palettewindow.py b/src/sugar/graphics/palettewindow.py index d72b588b..82c4bbab 100644 --- a/src/sugar/graphics/palettewindow.py +++ b/src/sugar/graphics/palettewindow.py @@ -325,7 +325,7 @@ class PaletteWindow(gtk.Window): self.show() def popdown(self, immediate=False): - logging.debug('PaletteWindow.popdown immediate %r' % immediate) + logging.debug('PaletteWindow.popdown immediate %r', immediate) self._popup_anim.stop() self._mouse_detector.stop() diff --git a/src/sugar/graphics/toolbarbox.py b/src/sugar/graphics/toolbarbox.py index f3d624d6..48b5e1ae 100644 --- a/src/sugar/graphics/toolbarbox.py +++ b/src/sugar/graphics/toolbarbox.py @@ -205,7 +205,7 @@ class _ToolbarPalette(PaletteWindow): def _handle_focus(self, delta): self._focus += delta if self._focus not in (0, 1): - logging.error('_Palette._focus=%s not in (0, 1)' % self._focus) + logging.error('_Palette._focus=%s not in (0, 1)', self._focus) if self._focus == 0: group = palettegroup.get_group('default') diff --git a/src/sugar/presence/presenceservice.py b/src/sugar/presence/presenceservice.py index a7fd1a4f..cc72800e 100644 --- a/src/sugar/presence/presenceservice.py +++ b/src/sugar/presence/presenceservice.py @@ -473,8 +473,8 @@ class PresenceService(gobject.GObject): def _share_activity_error_cb(self, activity, err): """Notify with GObject event of unsuccessful sharing of activity""" - _logger.debug("Error sharing activity %s: %s" % - (activity.get_id(), err)) + _logger.debug('Error sharing activity %s: %s', activity.get_id(), + err) self.emit("activity-shared", False, None, err) def share_activity(self, activity, properties=None, private=True): diff --git a/src/sugar/profile.py b/src/sugar/profile.py index d5012bdc..9d897baa 100644 --- a/src/sugar/profile.py +++ b/src/sugar/profile.py @@ -66,8 +66,8 @@ class Profile(object): f = open(key_path, "r") lines = f.readlines() f.close() - except IOError, e: - logging.error("Error reading public key: %s" % e) + except IOError: + logging.exception('Error reading public key') return None magic = "ssh-dss " @@ -92,8 +92,8 @@ class Profile(object): f = open(key_path, "r") lines = f.readlines() f.close() - except IOError, e: - logging.error("Error reading private key: %s" % e) + except IOError: + logging.exception('Error reading private key') return None key = "" diff --git a/src/sugar/util.py b/src/sugar/util.py index 26bbe837..034038bb 100644 --- a/src/sugar/util.py +++ b/src/sugar/util.py @@ -272,7 +272,7 @@ class TempFilePath(str): if path is None: fd, path = tempfile.mkstemp() os.close(fd) - logging.debug('TempFilePath created %r' % path) + logging.debug('TempFilePath created %r', path) if path in _tracked_paths: _tracked_paths[path] += 1 @@ -287,9 +287,9 @@ class TempFilePath(str): if os.path.exists(self): os.unlink(self) - logging.debug('TempFilePath deleted %r' % self) + logging.debug('TempFilePath deleted %r', self) else: - logging.warning('TempFilePath already deleted %r' % self) + logging.warning('TempFilePath already deleted %r', self) else: _tracked_paths[self] -= 1