let the logger do the formatting

This commit is contained in:
Sascha Silbe 2009-08-24 12:54:02 +02:00
parent bdd760d92a
commit 496090fe62
15 changed files with 58 additions and 58 deletions

View File

@ -305,8 +305,8 @@ class Activity(Window, gtk.Container):
else: else:
self.__joined_cb(self.shared_activity, True, None) self.__joined_cb(self.shared_activity, True, None)
elif share_scope != SCOPE_PRIVATE: elif share_scope != SCOPE_PRIVATE:
logging.debug("*** Act %s no existing mesh instance, but used to " \ logging.debug('*** Act %s no existing mesh instance, but used to '
"be shared, will share" % self._activity_id) 'be shared, will share', self._activity_id)
# no existing mesh instance, but activity used to be shared, so # no existing mesh instance, but activity used to be shared, so
# restart the share # restart the share
if share_scope == SCOPE_INVITE_ONLY: if share_scope == SCOPE_INVITE_ONLY:
@ -314,7 +314,7 @@ class Activity(Window, gtk.Container):
elif share_scope == SCOPE_NEIGHBORHOOD: elif share_scope == SCOPE_NEIGHBORHOOD:
self.share(private=False) self.share(private=False)
else: 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: if handle.object_id is None and create_jobject:
logging.debug('Creating a jobject.') logging.debug('Creating a jobject.')
@ -409,7 +409,7 @@ class Activity(Window, gtk.Container):
pass pass
def __jobject_error_cb(self, err): 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): def get_activity_root(self):
""" FIXME: Deprecated. This part of the API has been moved """ FIXME: Deprecated. This part of the API has been moved
@ -486,13 +486,13 @@ class Activity(Window, gtk.Container):
if self._closing: if self._closing:
self._show_keep_failed_dialog() self._show_keep_failed_dialog()
self._closing = False 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): def _cleanup_jobject(self):
if self._jobject: if self._jobject:
if self._owns_file and os.path.isfile(self._jobject.file_path): if self._owns_file and os.path.isfile(self._jobject.file_path):
logging.debug('_cleanup_jobject: removing %r' % logging.debug('_cleanup_jobject: removing %r',
self._jobject.file_path) self._jobject.file_path)
os.remove(self._jobject.file_path) os.remove(self._jobject.file_path)
self._owns_file = False self._owns_file = False
self._jobject.destroy() self._jobject.destroy()
@ -550,7 +550,7 @@ class Activity(Window, gtk.Container):
logging.debug('Cannot save, no journal object.') logging.debug('Cannot save, no journal object.')
return return
logging.debug('Activity.save: %r' % self._jobject.object_id) logging.debug('Activity.save: %r', self._jobject.object_id)
if self._updating_jobject: if self._updating_jobject:
logging.info('Activity.save: still processing a previous request.') 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 Activities should not override this method. Instead, like save() do any
copy work that needs to be done in write_file() 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.save()
self._jobject.object_id = None self._jobject.object_id = None
@ -609,7 +609,7 @@ class Activity(Window, gtk.Container):
self.shared_activity.disconnect(self._join_id) self.shared_activity.disconnect(self._join_id)
self._join_id = None self._join_id = None
if not success: if not success:
logging.debug("Failed to join activity: %s" % err) logging.debug('Failed to join activity: %s', err)
return return
self.present() self.present()
@ -633,8 +633,8 @@ class Activity(Window, gtk.Container):
self._pservice.disconnect(self._share_id) self._pservice.disconnect(self._share_id)
self._share_id = None self._share_id = None
if not success: if not success:
logging.debug('Share of activity %s failed: %s.' % logging.debug('Share of activity %s failed: %s.',
(self._activity_id, err)) self._activity_id, err)
return return
logging.debug('Share of activity %s successful, PS activity is %r.', 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): def _invite_response_cb(self, error):
if error: if error:
logging.error('Invite failed: %s' % error) logging.error('Invite failed: %s', error)
def _send_invites(self): def _send_invites(self):
while self._invites_queue: while self._invites_queue:
@ -662,7 +662,7 @@ class Activity(Window, gtk.Container):
self.shared_activity.invite( self.shared_activity.invite(
buddy, '', self._invite_response_cb) buddy, '', self._invite_response_cb)
else: 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): def invite(self, buddy_key):
"""Invite a buddy to join this Activity. """Invite a buddy to join this Activity.
@ -692,8 +692,8 @@ class Activity(Window, gtk.Container):
raise RuntimeError("Activity %s already shared." % raise RuntimeError("Activity %s already shared." %
self._activity_id) self._activity_id)
verb = private and 'private' or 'public' verb = private and 'private' or 'public'
logging.debug('Requesting %s share of activity %s.' % logging.debug('Requesting %s share of activity %s.', verb,
(verb, self._activity_id)) self._activity_id)
self._share_id = self._pservice.connect("activity-shared", self._share_id = self._pservice.connect("activity-shared",
self.__share_cb) self.__share_cb)
self._pservice.share_activity(self, private=private) self._pservice.share_activity(self, private=private)

View File

@ -143,7 +143,7 @@ def get_command(activity, activity_id=None, object_id=None, uri=None):
if os.path.exists(absolute_path): if os.path.exists(absolute_path):
command[0] = absolute_path command[0] = absolute_path
logging.debug('launching: %r' % command) logging.debug('launching: %r', command)
return command return command
@ -300,25 +300,25 @@ class ActivityCreationHandler(gobject.GObject):
pass pass
def _notify_launch_failure_error_handler(self, err): 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): 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): def _activate_reply_handler(self, activated):
if not activated: if not activated:
self._create_activity() self._create_activity()
def _activate_error_handler(self, err): 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): def _create_reply_handler(self):
logging.debug("Activity created %s (%s)." % logging.debug('Activity created %s (%s).',
(self._handle.activity_id, self._service_name)) self._handle.activity_id, self._service_name)
def _create_error_handler(self, err): def _create_error_handler(self, err):
logging.error("Couldn't create activity %s (%s): %s" % logging.error("Couldn't create activity %s (%s): %s",
(self._handle.activity_id, self._service_name, err)) self._handle.activity_id, self._service_name, err)
self._shell.NotifyLaunchFailure( self._shell.NotifyLaunchFailure(
self._handle.activity_id, reply_handler=self._no_reply_handler, self._handle.activity_id, reply_handler=self._no_reply_handler,
error_handler=self._notify_launch_failure_error_handler) error_handler=self._notify_launch_failure_error_handler)
@ -331,7 +331,7 @@ class ActivityCreationHandler(gobject.GObject):
self._launch_activity() self._launch_activity()
def _find_object_error_handler(self, err): def _find_object_error_handler(self, err):
logging.error("Datastore find failed %s" % err) logging.error('Datastore find failed %s', err)
self._launch_activity() self._launch_activity()
def create(bundle, activity_handle=None): def create(bundle, activity_handle=None):

View File

@ -61,7 +61,7 @@ class ActivityService(dbus.service.Object):
@dbus.service.method(_ACTIVITY_INTERFACE) @dbus.service.method(_ACTIVITY_INTERFACE)
def SetActive(self, active): def SetActive(self, active):
logging.debug('ActivityService.set_active: %s.' % active) logging.debug('ActivityService.set_active: %s.', active)
self._activity.props.active = active self._activity.props.active = active
@dbus.service.method(_ACTIVITY_INTERFACE) @dbus.service.method(_ACTIVITY_INTERFACE)

View File

@ -110,21 +110,21 @@ class ActivityBundle(Bundle):
# Remove duplicates # Remove duplicates
if line in lines[0:num]: if line in lines[0:num]:
lines[num] = "" lines[num] = ""
logging.warning("Bundle %s: duplicate entry in MANIFEST: %s" logging.warning('Bundle %s: duplicate entry in MANIFEST: %s',
% (self._name,line)) self._name, line)
continue continue
# Remove MANIFEST # Remove MANIFEST
if line == "MANIFEST": if line == "MANIFEST":
lines[num] = "" lines[num] = ""
logging.warning("Bundle %s: MANIFEST includes itself: %s" logging.warning('Bundle %s: MANIFEST includes itself: %s',
% (self._name,line)) self._name, line)
# Remove invalid files # Remove invalid files
if not self.is_file(line): if not self.is_file(line):
lines[num] = "" lines[num] = ""
logging.warning("Bundle %s: invalid entry in MANIFEST: %s" logging.warning('Bundle %s: invalid entry in MANIFEST: %s',
% (self._name,line)) self._name, line)
return lines return lines
@ -311,8 +311,8 @@ class ActivityBundle(Bundle):
if path in manifestfiles: if path in manifestfiles:
manifestfiles.remove(path) manifestfiles.remove(path)
elif path != "MANIFEST": elif path != "MANIFEST":
logging.warning("Bundle %s: %s not in MANIFEST"% logging.warning('Bundle %s: %s not in MANIFEST', self._name,
(self._name,path)) path)
if strict_manifest: if strict_manifest:
os.remove(os.path.join(install_path, path)) os.remove(os.path.join(install_path, path))

View File

@ -121,7 +121,7 @@ class Bundle(object):
data = self._zip_file.read(path) data = self._zip_file.read(path)
f = StringIO.StringIO(data) f = StringIO.StringIO(data)
except KeyError: except KeyError:
logging.debug('%s not found.' % filename) logging.debug('%s not found.', filename)
return f return f

View File

@ -183,7 +183,7 @@ def write(ds_object, update_mtime=True, transfer_ownership=False,
transfer_ownership) transfer_ownership)
ds_object.metadata['uid'] = ds_object.object_id ds_object.metadata['uid'] = ds_object.object_id
# TODO: register the object for updates # 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): def delete(object_id):
logging.debug('datastore.delete') logging.debug('datastore.delete')

View File

@ -52,8 +52,8 @@ def update(uid, properties, filename, transfer_ownership=False,
debug_props = properties.copy() debug_props = properties.copy()
if debug_props.has_key("preview"): if debug_props.has_key("preview"):
debug_props["preview"] = "<omitted>" debug_props["preview"] = "<omitted>"
logging.debug('dbus_helpers.update: %s, %s, %s, %s' % logging.debug('dbus_helpers.update: %s, %s, %s, %s', uid, filename,
(uid, filename, debug_props, transfer_ownership)) debug_props, transfer_ownership)
if reply_handler and error_handler: if reply_handler and error_handler:
_get_data_store().update(uid, dbus.Dictionary(properties), filename, _get_data_store().update(uid, dbus.Dictionary(properties), filename,
transfer_ownership, transfer_ownership,
@ -65,20 +65,20 @@ def update(uid, properties, filename, transfer_ownership=False,
filename, transfer_ownership) filename, transfer_ownership)
def delete(uid): def delete(uid):
logging.debug('dbus_helpers.delete: %r' % uid) logging.debug('dbus_helpers.delete: %r', uid)
_get_data_store().delete(uid) _get_data_store().delete(uid)
def get_properties(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) return _get_data_store().get_properties(uid, byte_arrays=True)
def get_filename(uid): def get_filename(uid):
filename = _get_data_store().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 return filename
def find(query, properties, reply_handler, error_handler): 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: if reply_handler and error_handler:
return _get_data_store().find(query, properties, return _get_data_store().find(query, properties,
reply_handler=reply_handler, error_handler=error_handler, reply_handler=reply_handler, error_handler=error_handler,

View File

@ -143,8 +143,8 @@ class _IconBuffer(object):
del info del info
else: else:
logging.warning('No icon with the name %s ' logging.warning('No icon with the name %s was found in the '
'was found in the theme.' % self.icon_name) 'theme.', self.icon_name)
return icon_info return icon_info

View File

@ -110,7 +110,7 @@ class ObjectChooser(object):
def __chooser_response_cb(self, chooser_id, object_id): def __chooser_response_cb(self, chooser_id, object_id):
if chooser_id != self._chooser_id: if chooser_id != self._chooser_id:
return 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._response_code = gtk.RESPONSE_ACCEPT
self._object_id = object_id self._object_id = object_id
self._cleanup() self._cleanup()
@ -118,7 +118,7 @@ class ObjectChooser(object):
def __chooser_cancelled_cb(self, chooser_id): def __chooser_cancelled_cb(self, chooser_id):
if chooser_id != self._chooser_id: if chooser_id != self._chooser_id:
return 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._response_code = gtk.RESPONSE_CANCEL
self._cleanup() self._cleanup()

View File

@ -179,7 +179,7 @@ class Palette(PaletteWindow):
return self._full_request return self._full_request
def popup(self, immediate=False, state=None): 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: if self._invoker is not None:
self._update_full_request() self._update_full_request()

View File

@ -325,7 +325,7 @@ class PaletteWindow(gtk.Window):
self.show() self.show()
def popdown(self, immediate=False): def popdown(self, immediate=False):
logging.debug('PaletteWindow.popdown immediate %r' % immediate) logging.debug('PaletteWindow.popdown immediate %r', immediate)
self._popup_anim.stop() self._popup_anim.stop()
self._mouse_detector.stop() self._mouse_detector.stop()

View File

@ -205,7 +205,7 @@ class _ToolbarPalette(PaletteWindow):
def _handle_focus(self, delta): def _handle_focus(self, delta):
self._focus += delta self._focus += delta
if self._focus not in (0, 1): 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: if self._focus == 0:
group = palettegroup.get_group('default') group = palettegroup.get_group('default')

View File

@ -473,8 +473,8 @@ class PresenceService(gobject.GObject):
def _share_activity_error_cb(self, activity, err): def _share_activity_error_cb(self, activity, err):
"""Notify with GObject event of unsuccessful sharing of activity""" """Notify with GObject event of unsuccessful sharing of activity"""
_logger.debug("Error sharing activity %s: %s" % _logger.debug('Error sharing activity %s: %s', activity.get_id(),
(activity.get_id(), err)) err)
self.emit("activity-shared", False, None, err) self.emit("activity-shared", False, None, err)
def share_activity(self, activity, properties=None, private=True): def share_activity(self, activity, properties=None, private=True):

View File

@ -66,8 +66,8 @@ class Profile(object):
f = open(key_path, "r") f = open(key_path, "r")
lines = f.readlines() lines = f.readlines()
f.close() f.close()
except IOError, e: except IOError:
logging.error("Error reading public key: %s" % e) logging.exception('Error reading public key')
return None return None
magic = "ssh-dss " magic = "ssh-dss "
@ -92,8 +92,8 @@ class Profile(object):
f = open(key_path, "r") f = open(key_path, "r")
lines = f.readlines() lines = f.readlines()
f.close() f.close()
except IOError, e: except IOError:
logging.error("Error reading private key: %s" % e) logging.exception('Error reading private key')
return None return None
key = "" key = ""

View File

@ -272,7 +272,7 @@ class TempFilePath(str):
if path is None: if path is None:
fd, path = tempfile.mkstemp() fd, path = tempfile.mkstemp()
os.close(fd) os.close(fd)
logging.debug('TempFilePath created %r' % path) logging.debug('TempFilePath created %r', path)
if path in _tracked_paths: if path in _tracked_paths:
_tracked_paths[path] += 1 _tracked_paths[path] += 1
@ -287,9 +287,9 @@ class TempFilePath(str):
if os.path.exists(self): if os.path.exists(self):
os.unlink(self) os.unlink(self)
logging.debug('TempFilePath deleted %r' % self) logging.debug('TempFilePath deleted %r', self)
else: else:
logging.warning('TempFilePath already deleted %r' % self) logging.warning('TempFilePath already deleted %r', self)
else: else:
_tracked_paths[self] -= 1 _tracked_paths[self] -= 1