Turn on H703, so our translators don't punch us

Change-Id: I4ce3068f79563e4d4296c6e1078bc12f0cf84c96
Related-Bug: 1559431
This commit is contained in:
Tim Burke 2016-05-19 18:55:40 -07:00
parent 4a7731875b
commit 226557afc4
10 changed files with 45 additions and 33 deletions

View File

@ -57,7 +57,8 @@ class ContainerSyncRealms(object):
log_func = self.logger.debug log_func = self.logger.debug
else: else:
log_func = self.logger.error log_func = self.logger.error
log_func(_('Could not load %r: %s'), self.conf_path, err) log_func(_('Could not load %(conf)r: %(error)s') % {
'conf': self.conf_path, 'error': err})
else: else:
if mtime != self.conf_path_mtime: if mtime != self.conf_path_mtime:
self.conf_path_mtime = mtime self.conf_path_mtime = mtime
@ -66,7 +67,8 @@ class ContainerSyncRealms(object):
conf.read(self.conf_path) conf.read(self.conf_path)
except configparser.ParsingError as err: except configparser.ParsingError as err:
self.logger.error( self.logger.error(
_('Could not load %r: %s'), self.conf_path, err) _('Could not load %(conf)r: %(error)s')
% {'conf': self.conf_path, 'error': err})
else: else:
try: try:
self.mtime_check_interval = conf.getint( self.mtime_check_interval = conf.getint(
@ -79,8 +81,9 @@ class ContainerSyncRealms(object):
now + self.mtime_check_interval now + self.mtime_check_interval
except (configparser.ParsingError, ValueError) as err: except (configparser.ParsingError, ValueError) as err:
self.logger.error( self.logger.error(
_('Error in %r with mtime_check_interval: %s'), _('Error in %(conf)r with '
self.conf_path, err) 'mtime_check_interval: %(error)s')
% {'conf': self.conf_path, 'error': err})
realms = {} realms = {}
for section in conf.sections(): for section in conf.sections():
realm = {} realm = {}

View File

@ -2674,7 +2674,8 @@ def validate_sync_to(value, allowed_sync_hosts, realms_conf):
endpoint = realms_conf.endpoint(realm, cluster) endpoint = realms_conf.endpoint(realm, cluster)
if not endpoint: if not endpoint:
return ( return (
_('No cluster endpoint for %r %r') % (realm, cluster), _('No cluster endpoint for %(realm)r %(cluster)r')
% {'realm': realm, 'cluster': cluster},
None, None, None) None, None, None)
return ( return (
None, None,

View File

@ -196,9 +196,10 @@ def get_socket(conf):
raise raise
sleep(0.1) sleep(0.1)
if not sock: if not sock:
raise Exception(_('Could not bind to %s:%s ' raise Exception(_('Could not bind to %(addr)s:%(port)s '
'after trying for %s seconds') % ( 'after trying for %(timeout)s seconds') % {
bind_addr[0], bind_addr[1], bind_timeout)) 'addr': bind_addr[0], 'port': bind_addr[1],
'timeout': bind_timeout})
# in my experience, sockets can hang around forever without keepalive # in my experience, sockets can hang around forever without keepalive
sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)

View File

@ -183,11 +183,12 @@ class ContainerController(BaseStorageServer):
if len(account_hosts) != len(account_devices): if len(account_hosts) != len(account_devices):
# This shouldn't happen unless there's a bug in the proxy, # This shouldn't happen unless there's a bug in the proxy,
# but if there is, we want to know about it. # but if there is, we want to know about it.
self.logger.error(_('ERROR Account update failed: different ' self.logger.error(_(
'numbers of hosts and devices in request: ' 'ERROR Account update failed: different '
'"%s" vs "%s"') % 'numbers of hosts and devices in request: '
(req.headers.get('X-Account-Host', ''), '"%(hosts)s" vs "%(devices)s"') % {
req.headers.get('X-Account-Device', ''))) 'hosts': req.headers.get('X-Account-Host', ''),
'devices': req.headers.get('X-Account-Device', '')})
return HTTPBadRequest(req=req) return HTTPBadRequest(req=req)
if account_partition: if account_partition:

View File

@ -237,8 +237,9 @@ class ContainerSync(Daemon):
if err.errno != errno.ENOENT: if err.errno != errno.ENOENT:
raise raise
raise SystemExit( raise SystemExit(
_('Unable to load internal client from config: %r (%s)') % _('Unable to load internal client from config: '
(internal_client_conf_path, err)) '%(conf)r (%(error)s)')
% {'conf': internal_client_conf_path, 'error': err})
def run_forever(self, *args, **kwargs): def run_forever(self, *args, **kwargs):
""" """

View File

@ -378,8 +378,9 @@ def object_audit_location_generator(devices, mount_check=True, logger=None,
base, policy = split_policy_string(dir_) base, policy = split_policy_string(dir_)
except PolicyError as e: except PolicyError as e:
if logger: if logger:
logger.warning(_('Directory %r does not map ' logger.warning(_('Directory %(directory)r does not map '
'to a valid policy (%s)') % (dir_, e)) 'to a valid policy (%(error)s)') % {
'directory': dir_, 'error': e})
continue continue
datadir_path = os.path.join(devices, device, dir_) datadir_path = os.path.join(devices, device, dir_)

View File

@ -77,15 +77,17 @@ class ObjectExpirer(Daemon):
""" """
if final: if final:
elapsed = time() - self.report_first_time elapsed = time() - self.report_first_time
self.logger.info(_('Pass completed in %ds; %d objects expired') % self.logger.info(_('Pass completed in %(time)ds; '
(elapsed, self.report_objects)) '%(objects)d objects expired') % {
'time': elapsed, 'objects': self.report_objects})
dump_recon_cache({'object_expiration_pass': elapsed, dump_recon_cache({'object_expiration_pass': elapsed,
'expired_last_pass': self.report_objects}, 'expired_last_pass': self.report_objects},
self.rcache, self.logger) self.rcache, self.logger)
elif time() - self.report_last_time >= self.report_interval: elif time() - self.report_last_time >= self.report_interval:
elapsed = time() - self.report_first_time elapsed = time() - self.report_first_time
self.logger.info(_('Pass so far %ds; %d objects expired') % self.logger.info(_('Pass so far %(time)ds; '
(elapsed, self.report_objects)) '%(objects)d objects expired') % {
'time': elapsed, 'objects': self.report_objects})
self.report_last_time = time() self.report_last_time = time()
def iter_cont_objs_to_expire(self): def iter_cont_objs_to_expire(self):
@ -168,8 +170,10 @@ class ObjectExpirer(Daemon):
self.logger.debug('Run begin') self.logger.debug('Run begin')
containers, objects = \ containers, objects = \
self.swift.get_account_info(self.expiring_objects_account) self.swift.get_account_info(self.expiring_objects_account)
self.logger.info(_('Pass beginning; %s possible containers; %s ' self.logger.info(_('Pass beginning; '
'possible objects') % (containers, objects)) '%(containers)s possible containers; '
'%(objects)s possible objects') % {
'containers': containers, 'objects': objects})
for container, obj in self.iter_cont_objs_to_expire(): for container, obj in self.iter_cont_objs_to_expire():
containers_to_delete.add(container) containers_to_delete.add(container)

View File

@ -281,11 +281,12 @@ class ObjectController(BaseStorageServer):
if len(conthosts) != len(contdevices): if len(conthosts) != len(contdevices):
# This shouldn't happen unless there's a bug in the proxy, # This shouldn't happen unless there's a bug in the proxy,
# but if there is, we want to know about it. # but if there is, we want to know about it.
self.logger.error(_('ERROR Container update failed: different ' self.logger.error(_(
'numbers of hosts and devices in request: ' 'ERROR Container update failed: different '
'"%s" vs "%s"') % 'numbers of hosts and devices in request: '
(headers_in.get('X-Container-Host', ''), '"%(hosts)s" vs "%(devices)s"') % {
headers_in.get('X-Container-Device', ''))) 'hosts': headers_in.get('X-Container-Host', ''),
'devices': headers_in.get('X-Container-Device', '')})
return return
if contpartition: if contpartition:

View File

@ -160,9 +160,9 @@ class ObjectUpdater(Daemon):
try: try:
base, policy = split_policy_string(asyncdir) base, policy = split_policy_string(asyncdir)
except PolicyError as e: except PolicyError as e:
self.logger.warning(_('Directory %r does not map ' self.logger.warning(_('Directory %(directory)r does not map '
'to a valid policy (%s)') % 'to a valid policy (%(error)s)') % {
(asyncdir, e)) 'directory': asyncdir, 'error': e})
continue continue
for prefix in self._listdir(async_pending): for prefix in self._listdir(async_pending):
prefix_path = os.path.join(async_pending, prefix) prefix_path = os.path.join(async_pending, prefix)

View File

@ -76,8 +76,7 @@ commands = bandit -c bandit.yaml -r swift bin -n 5 -p gate
# H404: multi line docstring should start without a leading new line # H404: multi line docstring should start without a leading new line
# H405: multi line docstring summary not separated with an empty line # H405: multi line docstring summary not separated with an empty line
# H501: Do not use self.__dict__ for string formatting # H501: Do not use self.__dict__ for string formatting
# H703: Multiple positional placeholders ignore = F812,H101,H202,H233,H301,H306,H401,H403,H404,H405,H501
ignore = F812,H101,H202,H233,H301,H306,H401,H403,H404,H405,H501,H703
exclude = .venv,.tox,dist,*egg exclude = .venv,.tox,dist,*egg
show-source = True show-source = True