Merge "Fix strings with positional arguments"

This commit is contained in:
Jenkins 2016-04-05 18:39:17 +00:00 committed by Gerrit Code Review
commit 645002b956
9 changed files with 74 additions and 47 deletions

View File

@ -145,7 +145,8 @@ class AccountAuditor(Daemon):
self.logger.increment('failures')
self.account_failures += 1
self.logger.error(
_('Audit Failed for %s: %s'), path, str(e))
_('Audit Failed for %(path)s: %(err)s'),
{'path': path, 'err': str(e)})
except (Exception, Timeout):
self.logger.increment('failures')
self.account_failures += 1

View File

@ -313,8 +313,9 @@ class AccountReaper(Daemon):
delete_timestamp = Timestamp(info['delete_timestamp'])
if self.stats_containers_remaining and \
begin - float(delete_timestamp) >= self.reap_not_done_after:
self.logger.warning(_('Account %s has not been reaped since %s') %
(account, delete_timestamp.isoformat))
self.logger.warning(
_('Account %(account)s has not been reaped since %(time)s') %
{'account': account, 'time': delete_timestamp.isoformat})
return True
def reap_container(self, account, account_partition, account_nodes,

View File

@ -350,8 +350,10 @@ class DatabaseBroker(object):
raise
quar_path = "%s-%s" % (quar_path, uuid4().hex)
renamer(self.db_dir, quar_path, fsync=False)
detail = _('Quarantined %s to %s due to %s database') % \
(self.db_dir, quar_path, exc_hint)
detail = _('Quarantined %(db_dir)s to %(quar_path)s due to '
'%(exc_hint)s database') % {'db_dir': self.db_dir,
'quar_path': quar_path,
'exc_hint': exc_hint}
self.logger.error(detail)
raise sqlite3.DatabaseError(detail)

View File

@ -288,7 +288,8 @@ class Manager(object):
for server, killed_pid in watch_server_pids(server_pids,
interval=kill_wait,
**kwargs):
print(_("%s (%s) appears to have stopped") % (server, killed_pid))
print(_("%(server)s (%(pid)s) appears to have stopped") %
{'server': server, 'pid': killed_pid})
killed_pids.add(killed_pid)
if not killed_pids.symmetric_difference(signaled_pids):
# all processes have been stopped
@ -300,12 +301,15 @@ class Manager(object):
if not killed_pids.issuperset(pids):
# some pids of this server were not killed
if kill_after_timeout:
print(_('Waited %s seconds for %s to die; killing') % (
kill_wait, server))
print(_('Waited %(kill_wait)s seconds for %(server)s '
'to die; killing') %
{'kill_wait': kill_wait, 'server': server})
# Send SIGKILL to all remaining pids
for pid in set(pids.keys()) - killed_pids:
print(_('Signal %s pid: %s signal: %s') % (
server, pid, signal.SIGKILL))
print(_('Signal %(server)s pid: %(pid)s signal: '
'%(signal)s') % {'server': server,
'pid': pid,
'signal': signal.SIGKILL})
# Send SIGKILL to process group
try:
kill_group(pid, signal.SIGKILL)
@ -314,8 +318,9 @@ class Manager(object):
if e.errno != errno.ESRCH:
raise e
else:
print(_('Waited %s seconds for %s to die; giving up') % (
kill_wait, server))
print(_('Waited %(kill_wait)s seconds for %(server)s '
'to die; giving up') %
{'kill_wait': kill_wait, 'server': server})
return 1
@command
@ -498,8 +503,9 @@ class Server(object):
# maybe there's a config file(s) out there, but I couldn't find it!
if not kwargs.get('quiet'):
if number:
print(_('Unable to locate config number %s for %s')
% (number, self.server))
print(_('Unable to locate config number %(number)s for'
' %(server)s') %
{'number': number, 'server': self.server})
else:
print(_('Unable to locate config for %s') % self.server)
if kwargs.get('verbose') and not kwargs.get('quiet'):
@ -556,8 +562,9 @@ class Server(object):
continue
try:
if sig != signal.SIG_DFL:
print(_('Signal %s pid: %s signal: %s') % (self.server,
pid, sig))
print(_('Signal %(server)s pid: %(pid)s signal: '
'%(signal)s') %
{'server': self.server, 'pid': pid, 'signal': sig})
safe_kill(pid, sig, 'swift-%s' % self.server)
except InvalidPidFileException as e:
if kwargs.get('verbose'):
@ -616,14 +623,16 @@ class Server(object):
kwargs['quiet'] = True
conf_files = self.conf_files(**kwargs)
if conf_files:
print(_("%s #%d not running (%s)") % (self.server, number,
conf_files[0]))
print(_("%(server)s #%(number)d not running (%(conf)s)") %
{'server': self.server, 'number': number,
'conf': conf_files[0]})
else:
print(_("No %s running") % self.server)
return 1
for pid, pid_file in pids.items():
conf_file = self.get_conf_file_name(pid_file)
print(_("%s running (%s - %s)") % (self.server, pid, conf_file))
print(_("%(server)s running (%(pid)s - %(conf)s)") %
{'server': self.server, 'pid': pid, 'conf': conf_file})
return 0
def spawn(self, conf_file, once=False, wait=True, daemon=True, **kwargs):
@ -716,11 +725,13 @@ class Server(object):
# any unstarted instances
if conf_file in conf_files:
already_started = True
print(_("%s running (%s - %s)") %
(self.server, pid, conf_file))
print(_("%(server)s running (%(pid)s - %(conf)s)") %
{'server': self.server, 'pid': pid, 'conf': conf_file})
elif not kwargs.get('number', 0):
already_started = True
print(_("%s running (%s - %s)") % (self.server, pid, pid_file))
print(_("%(server)s running (%(pid)s - %(pid_file)s)") %
{'server': self.server, 'pid': pid,
'pid_file': pid_file})
if already_started:
print(_("%s already started...") % self.server)

View File

@ -672,8 +672,9 @@ def fsync_dir(dirpath):
if err.errno == errno.ENOTDIR:
# Raise error if someone calls fsync_dir on a non-directory
raise
logging.warning(_("Unable to perform fsync() on directory %s: %s"),
dirpath, os.strerror(err.errno))
logging.warning(_('Unable to perform fsync() on directory %(dir)s:'
' %(err)s'),
{'dir': dirpath, 'err': os.strerror(err.errno)})
finally:
if dirfd:
os.close(dirfd)
@ -1243,10 +1244,13 @@ class LoggerFileObject(object):
self.logger.error(
_('%s: Connection reset by peer'), self.log_type)
else:
self.logger.error(_('%s: %s'), self.log_type, value)
self.logger.error(_('%(type)s: %(value)s'),
{'type': self.log_type, 'value': value})
def writelines(self, values):
self.logger.error(_('%s: %s'), self.log_type, '#012'.join(values))
self.logger.error(_('%(type)s: %(value)s'),
{'type': self.log_type,
'value': '#012'.join(values)})
def close(self):
pass
@ -2214,8 +2218,8 @@ def readconf(conf_path, section_name=None, log_name=None, defaults=None,
if c.has_section(section_name):
conf = dict(c.items(section_name))
else:
print(_("Unable to find %s config section in %s") %
(section_name, conf_path))
print(_("Unable to find %(section)s config section in %(conf)s") %
{'section': section_name, 'conf': conf_path})
sys.exit(1)
if "log_name" not in conf:
if log_name is not None:

View File

@ -104,8 +104,10 @@ class AuditorWorker(object):
description = _(' - parallel, %s') % device_dir_str
else:
description = _(' - %s') % device_dir_str
self.logger.info(_('Begin object audit "%s" mode (%s%s)') %
(mode, self.auditor_type, description))
self.logger.info(_('Begin object audit "%(mode)s" mode (%(audi_type)s'
'%(description)s)') %
{'mode': mode, 'audi_type': self.auditor_type,
'description': description})
begin = reported = time.time()
self.total_bytes_processed = 0
self.total_files_processed = 0

View File

@ -367,7 +367,8 @@ def object_audit_location_generator(devices, mount_check=True, logger=None,
except OSError as e:
if logger:
logger.debug(
_('Skipping %s: %s') % (device_dir, e.strerror))
_('Skipping %(dir)s: %(err)s') % {'dir': device_dir,
'err': e.strerror})
continue
for dir_ in dirs:
if not dir_.startswith(DATADIR_BASE):
@ -418,13 +419,15 @@ def get_auditor_status(datadir_path, logger, auditor_type):
status = statusfile.read()
except (OSError, IOError) as e:
if e.errno != errno.ENOENT and logger:
logger.warning(_('Cannot read %s (%s)') % (auditor_status, e))
logger.warning(_('Cannot read %(auditor_status)s (%(err)s)') %
{'auditor_status': auditor_status, 'err': e})
return listdir(datadir_path)
try:
status = json.loads(status)
except ValueError as e:
logger.warning(_('Loading JSON from %s failed (%s)') % (
auditor_status, e))
logger.warning(_('Loading JSON from %(auditor_status)s failed'
' (%(err)s)') %
{'auditor_status': auditor_status, 'err': e})
return listdir(datadir_path)
return status['partitions']
@ -438,7 +441,8 @@ def update_auditor_status(datadir_path, logger, partitions, auditor_type):
statusfile.write(status)
except (OSError, IOError) as e:
if logger:
logger.warning(_('Cannot write %s (%s)') % (auditor_status, e))
logger.warning(_('Cannot write %(auditor_status)s (%(err)s)') %
{'auditor_status': auditor_status, 'err': e})
def clear_auditor_status(devices, auditor_type="ALL"):
@ -2529,8 +2533,8 @@ class ECDiskFileWriter(BaseDiskFileWriter):
if err.errno not in (errno.ENOSPC, errno.EDQUOT):
# re-raise to catch all handler
raise
msg = (_('No space left on device for %s (%s)') %
(durable_file_path, err))
msg = (_('No space left on device for %(file)s (%(err)s)') %
{'file': durable_file_path, 'err': err})
self.manager.logger.error(msg)
exc = DiskFileNoSpace(str(err))
else:
@ -2538,11 +2542,11 @@ class ECDiskFileWriter(BaseDiskFileWriter):
self.manager.cleanup_ondisk_files(self._datadir)['files']
except OSError as os_err:
self.manager.logger.exception(
_('Problem cleaning up %s (%s)') %
(self._datadir, os_err))
_('Problem cleaning up %(datadir)s (%(err)s)') %
{'datadir': self._datadir, 'err': os_err})
except Exception as err:
msg = (_('Problem writing durable state file %s (%s)') %
(durable_file_path, err))
msg = (_('Problem writing durable state file %(file)s (%(err)s)') %
{'file': durable_file_path, 'err': err})
self.manager.logger.exception(msg)
exc = DiskFileError(msg)
if exc:

View File

@ -194,8 +194,9 @@ class ObjectExpirer(Daemon):
acceptable_statuses=(2, HTTP_NOT_FOUND, HTTP_CONFLICT))
except (Exception, Timeout) as err:
self.logger.exception(
_('Exception while deleting container %s %s') %
(container, str(err)))
_('Exception while deleting container %(container)s '
'%(err)s') % {'container': container,
'err': str(err)})
self.logger.debug('Run end')
self.report(final=True)
except (Exception, Timeout):
@ -266,8 +267,9 @@ class ObjectExpirer(Daemon):
except (Exception, Timeout) as err:
self.logger.increment('errors')
self.logger.exception(
_('Exception while deleting object %s %s %s') %
(container, obj, str(err)))
_('Exception while deleting object %(container)s %(obj)s'
' %(err)s') % {'container': container,
'obj': obj, 'err': str(err)})
self.logger.timing_since('timing', start_time)
self.report()

View File

@ -2403,8 +2403,8 @@ class ECObjectController(BaseObjectController):
status_type = 'commit'
self.app.exception_occurred(
conn.node, _('Object'),
_('Trying to get %s status of PUT to %s') % (
status_type, req.path))
_('Trying to get %(status_type)s status of PUT to %(path)s') %
{'status_type': status_type, 'path': req.path})
return (conn, resp)
def _get_put_responses(self, req, putters, num_nodes, final_phase,