Use proper formatting syntax, fixes #2170

This commit is contained in:
akskumarnot 2013-12-25 14:44:10 +05:30 committed by Daniel Narvaez
parent f43d5f8d24
commit 81b388c554
10 changed files with 81 additions and 80 deletions

View File

@ -404,12 +404,12 @@ class Activity(Window, Gtk.Container):
def _set_up_sharing(self, mesh_instance, share_scope):
# handle activity share/join
logging.debug('*** Act %s, mesh instance %r, scope %s',
self._activity_id, mesh_instance, share_scope)
logging.debug('*** Act %s, mesh instance %r, scope %s' %
(self._activity_id, mesh_instance, share_scope))
if mesh_instance is not None:
# There's already an instance on the mesh, join it
logging.debug('*** Act %s joining existing mesh instance %r',
self._activity_id, mesh_instance)
logging.debug('*** Act %s joining existing mesh instance %r' %
(self._activity_id, mesh_instance))
self.shared_activity = mesh_instance
self.shared_activity.connect('notify::private',
self.__privacy_changed_cb)
@ -421,7 +421,7 @@ class Activity(Window, Gtk.Container):
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)
'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:
@ -429,7 +429,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)
def __got_channel_cb(self, wait_loop, connection_path, channel_path,
handle_type):
@ -544,7 +544,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
@ -622,13 +622,13 @@ class Activity(Window, Gtk.Container):
if self._closing:
self._show_keep_failed_dialog()
self._closing = False
raise RuntimeError('Error saving activity object to datastore: %s',
raise RuntimeError('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',
logging.debug('_cleanup_jobject: removing %r' %
self._jobject.file_path)
os.remove(self._jobject.file_path)
self._owns_file = False
@ -715,7 +715,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.')
@ -762,12 +762,13 @@ 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
def __privacy_changed_cb(self, shared_activity, param_spec):
logging.debug('__privacy_changed_cb %r', shared_activity.props.private)
logging.debug('__privacy_changed_cb %r' %
shared_activity.props.private)
if shared_activity.props.private:
self._jobject.metadata['share-scope'] = SCOPE_INVITE_ONLY
else:
@ -775,11 +776,11 @@ class Activity(Window, Gtk.Container):
def __joined_cb(self, activity, success, err):
"""Callback when join has finished"""
logging.debug('Activity.__joined_cb %r', success)
logging.debug('Activity.__joined_cb %r' % success)
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.reveal()
@ -801,12 +802,12 @@ class Activity(Window, Gtk.Container):
def __share_cb(self, ps, success, activity, err):
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.',
self._activity_id, activity)
logging.debug('Share of activity %s successful, PS activity is %r.' %
(self._activity_id, activity))
activity.props.name = self._jobject.metadata['title']
@ -862,8 +863,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))
pservice = presenceservice.get_instance()
pservice.connect('activity-shared', self.__share_cb)
pservice.share_activity(self, private=private)
@ -1009,17 +1010,17 @@ class _ClientHandler(dbus.service.Object, DBusProperties):
CHANNEL + '.TargetHandleType': CONNECTION_HANDLE_TYPE_CONTACT,
}
filter_dict = dbus.Dictionary(filters, signature='sv')
logging.debug('__get_filters_cb %r', dbus.Array([filter_dict],
signature='a{sv}'))
logging.debug('__get_filters_cb %r' % dbus.Array([filter_dict],
signature='a{sv}'))
return dbus.Array([filter_dict], signature='a{sv}')
@dbus.service.method(dbus_interface=CLIENT_HANDLER,
in_signature='ooa(oa{sv})aota{sv}', out_signature='')
def HandleChannels(self, account, connection, channels, requests_satisfied,
user_action_time, handler_info):
logging.debug('HandleChannels\n\t%r\n\t%r\n\t%r\n\t%r\n\t%r\n\t%r',
account, connection, channels, requests_satisfied,
user_action_time, handler_info)
logging.debug('HandleChannels\n\t%r\n\t%r\n\t%r\n\t%r\n\t%r\n\t%r' %
(account, connection, channels, requests_satisfied,
user_action_time, handler_info))
try:
for object_path, properties in channels:
channel_type = properties[CHANNEL + '.ChannelType']

View File

@ -124,7 +124,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
@ -265,25 +265,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)
@ -296,7 +296,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()

View File

@ -348,8 +348,8 @@ class ActivityBundle(Bundle):
return
if not os.path.islink(dst) and os.path.exists(dst):
raise RuntimeError('Do not remove %s if it was not '
'installed by sugar', dst)
logging.debug('Link resource %s to %s', src, dst)
'installed by sugar' % dst)
logging.debug('Link resource %s to %s' % (src, dst))
if os.path.lexists(dst):
logging.debug('Relink %s', dst)
os.unlink(dst)

View File

@ -124,7 +124,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

View File

@ -228,7 +228,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.ResponseType.ACCEPT
self._object_id = object_id
self._cleanup()
@ -236,7 +236,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.ResponseType.CANCEL
self._cleanup()

View File

@ -61,7 +61,7 @@ def set_level(level):
try:
logging.getLogger('').setLevel(int(level))
except ValueError:
logging.warning('Invalid log level: %r', level)
logging.warning('Invalid log level: %r' % level)
# pylint: disable-msg=E1101,F0401
@ -235,7 +235,7 @@ def trace(logger=None, logger_name=None, skip_args=None, skip_kwargs=None,
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__,

View File

@ -138,17 +138,17 @@ class Activity(GObject.GObject):
dbus_interface=CONN_INTERFACE_ACTIVITY_PROPERTIES)
def __activity_properties_changed_cb(self, room_handle, properties):
_logger.debug('%r: Activity properties changed to %r', self,
properties)
_logger.debug('%r: Activity properties changed to %r' % (self,
properties))
self._update_properties(properties)
def __got_properties_cb(self, properties):
_logger.debug('__got_properties_cb %r', properties)
_logger.debug('__got_properties_cb %r' % properties)
self._get_properties_call = None
self._update_properties(properties)
def __error_handler_cb(self, error):
_logger.debug('__error_handler_cb %r', error)
_logger.debug('__error_handler_cb %r' % error)
def _update_properties(self, new_props):
val = new_props.get('name', self._name)
@ -188,7 +188,7 @@ class Activity(GObject.GObject):
if self._get_properties_call is not None:
_logger.debug('%r: Blocking on GetProperties() because someone '
'wants property %s', self, pspec.name)
'wants property %s' % (self, pspec.name))
self._get_properties_call.block()
if pspec.name == 'id':
@ -218,12 +218,12 @@ class Activity(GObject.GObject):
elif pspec.name == 'private':
self._private = val
else:
raise ValueError('Unknown property %r', pspec.name)
raise ValueError('Unknown property %r' % pspec.name)
self._publish_properties()
def set_private(self, val, reply_handler, error_handler):
_logger.debug('set_private %r', val)
_logger.debug('set_private %r' % val)
self._activity.SetProperties({'private': bool(val)},
reply_handler=reply_handler,
error_handler=error_handler)
@ -271,7 +271,7 @@ class Activity(GObject.GObject):
raise NotImplementedError()
def __joined_cb(self, join_command, error):
_logger.debug('%r: Join finished %r', self, error)
_logger.debug('%r: Join finished %r' % (self, error))
if error is not None:
self.emit('joined', error is None, str(error))
self.telepathy_text_chan = join_command.text_channel
@ -295,8 +295,8 @@ class Activity(GObject.GObject):
channel.connect_to_signal('Closed', self.__text_channel_closed_cb)
def __get_all_members_cb(self, members, local_pending, remote_pending):
_logger.debug('__get_all_members_cb %r %r', members,
self._text_channel_group_flags)
_logger.debug('__get_all_members_cb %r %r' % (members,
self._text_channel_group_flags))
if self._channel_self_handle in members:
members.remove(self._channel_self_handle)
@ -324,7 +324,7 @@ class Activity(GObject.GObject):
get_handle_owners_cb(input_handles)
def _add_initial_buddies(self, contact_ids):
_logger.debug('__add_initial_buddies %r', contact_ids)
_logger.debug('__add_initial_buddies %r' % contact_ids)
for contact_id in contact_ids:
self._buddies[contact_id] = self._get_buddy(contact_id)
self._joined_buddies[contact_id] = self._get_buddy(contact_id)
@ -335,7 +335,7 @@ class Activity(GObject.GObject):
def __text_channel_members_changed_cb(self, message, added, removed,
local_pending, remote_pending,
actor, reason):
_logger.debug('__text_channel_members_changed_cb %r',
_logger.debug('__text_channel_members_changed_cb %r' %
[added, message, added, removed, local_pending,
remote_pending, actor, reason])
if self._channel_self_handle in added:
@ -382,7 +382,7 @@ class Activity(GObject.GObject):
self.emit('joined', True, None)
return
_logger.debug('%r: joining', self)
_logger.debug('%r: joining' % self)
self._join_command = _JoinCommand(self.telepathy_conn,
self.room_handle)
@ -402,7 +402,7 @@ class Activity(GObject.GObject):
def __shared_cb(self, share_activity_cb, share_activity_error_cb,
share_command, error):
_logger.debug('%r: Share finished %r', self, error)
_logger.debug('%r: Share finished %r' % (self, error))
if error is None:
self._joined = True
self.room_handle = share_command.room_handle
@ -438,7 +438,7 @@ class Activity(GObject.GObject):
dbus_interface=CONN_INTERFACE_ACTIVITY_PROPERTIES)
def __share_error_cb(self, share_activity_error_cb, error):
logging.debug('%r: Share failed because: %s', self, error)
logging.debug('%r: Share failed because: %s' % (self, error))
share_activity_error_cb(self, error)
# GetChannels() wrapper
@ -459,8 +459,8 @@ class Activity(GObject.GObject):
channels = [self.telepathy_text_chan.object_path,
self.telepathy_tubes_chan.object_path]
_logger.debug('%r: bus name is %s, connection is %s, channels are %r',
self, bus_name, connection_path, channels)
_logger.debug('%r: bus name is %s, connection is %s, channels are %r' %
(self, bus_name, connection_path, channels))
return bus_name, connection_path, channels
# Leaving
@ -470,7 +470,7 @@ class Activity(GObject.GObject):
def leave(self):
"""Leave this shared activity"""
_logger.debug('%r: leaving', self)
_logger.debug('%r: leaving' % self)
self.telepathy_text_chan.Close()
@ -511,7 +511,7 @@ class _ShareCommand(_BaseCommand):
dbus_interface=CONNECTION)
def __got_handles_cb(self, handles):
logging.debug('__got_handles_cb %r', handles)
logging.debug('__got_handles_cb %r' % handles)
self.room_handle = handles[0]
self._join_command = _JoinCommand(self._connection, self.room_handle)
@ -519,7 +519,7 @@ class _ShareCommand(_BaseCommand):
self._join_command.run()
def __joined_cb(self, join_command, error):
_logger.debug('%r: Join finished %r', self, error)
_logger.debug('%r: Join finished %r' % (self, error))
if error is not None:
self._finished = True
self.emit('finished', error)
@ -597,12 +597,12 @@ class _JoinCommand(_BaseCommand):
self.emit('finished', error)
def __tubes_channel_ready_cb(self, channel):
_logger.debug('%r: Tubes channel %r is ready', self, channel)
_logger.debug('%r: Tubes channel %r is ready' % (self, channel))
self.tubes_channel = channel
self._tubes_ready()
def __text_channel_ready_cb(self, channel):
_logger.debug('%r: Text channel %r is ready', self, channel)
_logger.debug('%r: Text channel %r is ready' % (self, channel))
self.text_channel = channel
self._tubes_ready()
@ -611,13 +611,13 @@ class _JoinCommand(_BaseCommand):
self.tubes_channel is None:
return
_logger.debug('%r: finished setting up tubes', self)
_logger.debug('%r: finished setting up tubes' % self)
self._add_self_to_channel()
def __text_channel_group_flags_changed_cb(self, added, removed):
_logger.debug('__text_channel_group_flags_changed_cb %r %r', added,
removed)
_logger.debug('__text_channel_group_flags_changed_cb %r %r' % (added,
removed))
self.text_channel_group_flags |= added
self.text_channel_group_flags &= ~removed
@ -629,8 +629,8 @@ class _JoinCommand(_BaseCommand):
def got_all_members(members, local_pending, remote_pending):
_logger.debug('got_all_members members %r local_pending %r '
'remote_pending %r', members, local_pending,
remote_pending)
'remote_pending %r' % (members, local_pending,
remote_pending))
if self.text_channel_group_flags & \
CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES:
@ -639,7 +639,7 @@ class _JoinCommand(_BaseCommand):
self_handle = self._global_self_handle
if self_handle in local_pending:
_logger.debug('%r: We are in local pending - entering', self)
_logger.debug('%r: We are in local pending - entering' % self)
group.AddMembers([self_handle], '',
reply_handler=lambda: None,
error_handler=lambda e: self._join_failed_cb(
@ -675,8 +675,8 @@ class _JoinCommand(_BaseCommand):
actor, reason):
_logger.debug('__text_channel_members_changed_cb added %r removed %r '
'local_pending %r remote_pending %r channel_self_handle '
'%r', added, removed, local_pending, remote_pending,
self.channel_self_handle)
'%r' % (added, removed, local_pending, remote_pending,
self.channel_self_handle))
if self.text_channel_group_flags & \
CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES:

View File

@ -81,7 +81,7 @@ class PresenceService(GObject.GObject):
for account_path, connection in connections_per_account.items():
if not connection.connected:
continue
logging.debug('Calling GetActivity on %s', account_path)
logging.debug('Calling GetActivity on %s' % account_path)
try:
room_handle = connection.connection.GetActivity(
activity_id,
@ -90,7 +90,7 @@ class PresenceService(GObject.GObject):
name = 'org.freedesktop.Telepathy.Error.NotAvailable'
if e.get_dbus_name() == name:
logging.debug("There's no shared activity with the id "
"%s", activity_id)
"%s" % activity_id)
else:
raise
else:
@ -162,8 +162,8 @@ class PresenceService(GObject.GObject):
dbus_interface=CONNECTION)
return self.get_buddy(account_path, contact_ids[0])
raise ValueError('Unknown buddy in connection %s with handle %d',
tp_conn_path, handle)
raise ValueError('Unknown buddy in connection %s with handle %d' %
(tp_conn_path, handle))
def get_owner(self):
"""Retrieves the laptop Buddy object."""
@ -198,7 +198,7 @@ class PresenceService(GObject.GObject):
properties['private'] = private
if self._activity_cache is not None:
raise ValueError('Activity %s is already tracked',
raise ValueError('Activity %s is already tracked' %
activity.get_id())
connection_manager = get_connection_manager()

View File

@ -47,7 +47,7 @@ def _retry_find(func):
if e.code == Atspi.Error.IPC:
continue
logging.error("GError code %d", e.code)
logging.error("GError code %d" % e.code)
raise
expect_none = kwargs.get("expect_none", False)

View File

@ -307,7 +307,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
@ -322,9 +322,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