Do not use locals() for string formatting
Fix all occurrences of H501 of Hacking 0.7.x so that the check can be enabled later for gating. Change-Id: Ib193e4923349fd7d8e6015989642c3fbc4ae345e
This commit is contained in:
parent
1a8c62acb9
commit
b71ca1334b
|
@ -63,7 +63,8 @@ class TenantBasedAuth(object):
|
|||
if (match_for_tenant and
|
||||
tenant_id == match_for_tenant.group('tenant_id')):
|
||||
LOG.debug(_("Authorized tenant '%(tenant_id)s' request: "
|
||||
"%(request)s") % locals())
|
||||
"%(request)s") %
|
||||
{'tenant_id': tenant_id, 'request': request})
|
||||
return True
|
||||
msg = _("User with tenant id %s cannot access this resource")
|
||||
LOG.debug(msg % tenant_id)
|
||||
|
|
|
@ -270,9 +270,10 @@ def execute_with_timeout(*args, **kwargs):
|
|||
time = kwargs.get('timeout', 30)
|
||||
|
||||
def cb_timeout():
|
||||
msg = _("Time out after waiting"
|
||||
" %(time)s seconds when running proc: %(args)s"
|
||||
" %(kwargs)s") % locals()
|
||||
msg = (_("Time out after waiting"
|
||||
" %(time)s seconds when running proc: %(args)s"
|
||||
" %(kwargs)s") % {'time': time, 'args': args,
|
||||
'kwargs': kwargs})
|
||||
LOG.error(msg)
|
||||
raise exception.ProcessExecutionError(msg)
|
||||
|
||||
|
@ -284,9 +285,10 @@ def execute_with_timeout(*args, **kwargs):
|
|||
LOG.error("Timeout reached but not from our timeout. This is bad!")
|
||||
raise
|
||||
else:
|
||||
msg = _("Time out after waiting "
|
||||
"%(time)s seconds when running proc: %(args)s"
|
||||
" %(kwargs)s") % locals()
|
||||
msg = (_("Time out after waiting "
|
||||
"%(time)s seconds when running proc: %(args)s"
|
||||
" %(kwargs)s") % {'time': time, 'args': args,
|
||||
'kwargs': kwargs})
|
||||
LOG.error(msg)
|
||||
raise exception.ProcessExecutionError(msg)
|
||||
finally:
|
||||
|
|
|
@ -50,13 +50,13 @@ Float = lambda: sqlalchemy.types.Float()
|
|||
|
||||
def create_tables(tables):
|
||||
for table in tables:
|
||||
logger.info("creating table %(table)s" % locals())
|
||||
logger.info("creating table %(table)s" % {'table': table})
|
||||
table.create()
|
||||
|
||||
|
||||
def drop_tables(tables):
|
||||
for table in tables:
|
||||
logger.info("dropping table %(table)s" % locals())
|
||||
logger.info("dropping table %(table)s" % {'table': table})
|
||||
table.drop()
|
||||
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ def db_version(options, repo_path=None):
|
|||
return versioning_api.db_version(sql_connection, repo_path)
|
||||
except versioning_exceptions.DatabaseNotControlledError:
|
||||
msg = ("database '%(sql_connection)s' is not under migration control"
|
||||
% locals())
|
||||
% {'sql_connection': sql_connection})
|
||||
raise exception.DatabaseMigrationError(msg)
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ def upgrade(options, version=None, repo_path=None):
|
|||
sql_connection = options['sql_connection']
|
||||
version_str = version or 'latest'
|
||||
logger.info("Upgrading %(sql_connection)s to version %(version_str)s" %
|
||||
locals())
|
||||
{'sql_connection': sql_connection, 'version_str': version_str})
|
||||
return versioning_api.upgrade(sql_connection, repo_path, version)
|
||||
|
||||
|
||||
|
@ -78,7 +78,7 @@ def downgrade(options, version, repo_path=None):
|
|||
repo_path = get_migrate_repo_path(repo_path)
|
||||
sql_connection = options['sql_connection']
|
||||
logger.info("Downgrading %(sql_connection)s to version %(version)s" %
|
||||
locals())
|
||||
{'sql_connection': sql_connection, 'version': version})
|
||||
return versioning_api.downgrade(sql_connection, repo_path, version)
|
||||
|
||||
|
||||
|
@ -93,7 +93,7 @@ def version_control(options, repo_path=None):
|
|||
_version_control(options)
|
||||
except versioning_exceptions.DatabaseAlreadyControlledError:
|
||||
msg = ("database '%(sql_connection)s' is already under migration "
|
||||
"control" % locals())
|
||||
"control" % {'sql_connection': sql_connection})
|
||||
raise exception.DatabaseMigrationError(msg)
|
||||
|
||||
|
||||
|
|
|
@ -703,8 +703,7 @@ class MySqlApp(object):
|
|||
LOG.info("Enabling mysql on boot.")
|
||||
conf = "/etc/init/mysql.conf"
|
||||
if os.path.isfile(conf):
|
||||
command = "sudo sed -i '/^manual$/d' %(conf)s"
|
||||
command = command % locals()
|
||||
command = "sudo sed -i '/^manual$/d' %(conf)s" % {'conf': conf}
|
||||
else:
|
||||
command = system.MYSQL_CMD_ENABLE
|
||||
utils.execute_with_timeout(command, shell=True)
|
||||
|
@ -721,8 +720,7 @@ class MySqlApp(object):
|
|||
LOG.info("Disabling mysql on boot.")
|
||||
conf = "/etc/init/mysql.conf"
|
||||
if os.path.isfile(conf):
|
||||
command = '''sudo sh -c "echo manual >> %(conf)s"'''
|
||||
command = command % locals()
|
||||
command = "sudo sh -c 'echo manual >> %(conf)s'" % {'conf': conf}
|
||||
else:
|
||||
command = system.MYSQL_CMD_DISABLE
|
||||
utils.execute_with_timeout(command, shell=True)
|
||||
|
|
|
@ -272,7 +272,8 @@ class QuotaEngine(object):
|
|||
|
||||
reservations = self._driver.reserve(tenant_id, self._resources, deltas)
|
||||
|
||||
LOG.debug(_("Created reservations %(reservations)s") % locals())
|
||||
LOG.debug(_("Created reservations %(reservations)s") %
|
||||
{'reservations': reservations})
|
||||
|
||||
return reservations
|
||||
|
||||
|
@ -287,7 +288,7 @@ class QuotaEngine(object):
|
|||
self._driver.commit(reservations)
|
||||
except Exception:
|
||||
LOG.exception(_("Failed to commit reservations "
|
||||
"%(reservations)s") % locals())
|
||||
"%(reservations)s") % {'reservations': reservations})
|
||||
|
||||
def rollback(self, reservations):
|
||||
"""Roll back reservations.
|
||||
|
@ -300,7 +301,7 @@ class QuotaEngine(object):
|
|||
self._driver.rollback(reservations)
|
||||
except Exception:
|
||||
LOG.exception(_("Failed to roll back reservations "
|
||||
"%(reservations)s") % locals())
|
||||
"%(reservations)s") % {'reservations': reservations})
|
||||
|
||||
@property
|
||||
def resources(self):
|
||||
|
|
Loading…
Reference in New Issue