Fix and enable gating on H703 - string localisation

Avoid using multi positional strings for localisation,
as those are hard to translate to various languages.
Also enable gating on H231 (which does not trigger).

Change-Id: Ie22cf781bcd5ce7562a5e61cf08fde816e7af86a
This commit is contained in:
Dirk Mueller 2013-09-07 10:46:42 +02:00
parent 1a8c62acb9
commit e1d46b3770
10 changed files with 39 additions and 31 deletions

View File

@ -33,7 +33,7 @@ commands = {posargs}
[flake8]
show-source = True
ignore = E125,F401,F403,F811,F821,F841,H102,H103,H201,H23,H301,H306,H401,H402,H403,H404,H702,H703
ignore = E125,F401,F403,F811,F821,F841,H102,H103,H201,H233,H301,H306,H401,H402,H403,H404,H702
builtins = _
exclude=.venv,.tox,dist,doc,openstack,*egg,rsdns,tools,etc
filename=*.py,trove-*
filename=*.py,trove-*

View File

@ -55,14 +55,14 @@ class DatabaseModelBase(models.ModelBase):
if not self.is_valid():
raise exception.InvalidModelError(errors=self.errors)
self['updated'] = utils.utcnow()
LOG.debug(_("Saving %s: %s") %
(self.__class__.__name__, self.__dict__))
LOG.debug(_("Saving %(name)s: %(dict)s") %
{'name': self.__class__.__name__, 'dict': self.__dict__})
return self.db_api.save(self)
def delete(self):
self['updated'] = utils.utcnow()
LOG.debug(_("Deleting %s: %s") %
(self.__class__.__name__, self.__dict__))
LOG.debug(_("Deleting %(name)s: %(dict)s") %
{'name': self.__class__.__name__, 'dict': self.__dict__})
if self.preserve_on_delete:
self['deleted_at'] = utils.utcnow()

View File

@ -54,13 +54,13 @@ class DnsRecord(ModelBase):
def save(self):
if not self.is_valid():
raise exception.InvalidModelError(errors=self.errors)
LOG.debug(_("Saving %s: %s") %
(self.__class__.__name__, self.__dict__))
LOG.debug(_("Saving %(name)s: %(dict)s") %
{'name': self.__class__.__name__, 'dict': self.__dict__})
return get_db_api().save(self)
def delete(self):
LOG.debug(_("Deleting %s: %s") %
(self.__class__.__name__, self.__dict__))
LOG.debug(_("Deleting %(name)s: %(dict)s") %
{'name': self.__class__.__name__, 'dict': self.__dict__})
return get_db_api().delete(self)
@classmethod

View File

@ -39,8 +39,8 @@ class AccountController(wsgi.Controller):
def show(self, req, tenant_id, id):
"""Return a account and instances associated with a single account."""
LOG.info(_("req : '%s'\n\n") % req)
LOG.info(_("Showing account information for '%s' to '%s'") %
(id, tenant_id))
LOG.info(_("Showing account information for '%(account)s' "
"to '%(tenant)s'") % {'account': id, 'tenant': tenant_id})
context = req.environ[wsgi.CONTEXT_KEY]
account = models.Account.load(context, id)

View File

@ -209,8 +209,8 @@ class RootHistory(object):
self.created = utils.utcnow()
def save(self):
LOG.debug(_("Saving %s: %s") % (self.__class__.__name__,
self.__dict__))
LOG.debug(_("Saving %(name)s: %(dict)s") %
{'name': self.__class__.__name__, 'dict': self.__dict__})
return get_db_api().save(self)
@classmethod

View File

@ -76,8 +76,7 @@ class SecurityGroup(DatabaseModelBase):
@classmethod
def create_for_instance(cls, instance_id, context):
# Create a new security group
name = _("%s_%s") %\
(CONF.trove_security_group_name_prefix, instance_id)
name = "%s_%s" % (CONF.trove_security_group_name_prefix, instance_id)
description = _("Security Group for %s") % instance_id
sec_group = cls.create_sec_group(name, description, context)

View File

@ -160,7 +160,8 @@ class API(proxy.RpcProxy):
def delete_user(self, user):
"""Make an asynchronous call to delete an existing database user"""
LOG.debug(_("Deleting user %s for Instance %s"), user, self.id)
LOG.debug(_("Deleting user %(user)s for Instance %(instance_id)s") %
{'user': user, 'instance_id': self.id})
self._cast("delete_user", user=user)
def create_database(self, databases):
@ -178,7 +179,9 @@ class API(proxy.RpcProxy):
def delete_database(self, database):
"""Make an asynchronous call to delete an existing database
within the specified container"""
LOG.debug(_("Deleting database %s for Instance %s"), database, self.id)
LOG.debug(_("Deleting database %(database)s for "
"Instance %(instance_id)s") % {'database': database,
'instance_id': self.id})
self._cast("delete_database", database=database)
def enable_root(self):
@ -265,5 +268,7 @@ class API(proxy.RpcProxy):
def create_backup(self, backup_id):
"""Make async call to create a full backup of this instance"""
LOG.debug(_("Create Backup %s for Instance %s"), backup_id, self.id)
LOG.debug(_("Create Backup %(backup_id)s "
"for Instance %(instance_id)s") % {'backup_id': backup_id,
'instance_id': self.id})
self._cast("create_backup", backup_id=backup_id)

View File

@ -55,8 +55,8 @@ class AgentHeartBeat(dbmodels.DatabaseModelBase):
if not self.is_valid():
raise exception.InvalidModelError(errors=self.errors)
self['updated_at'] = utils.utcnow()
LOG.debug(_("Saving %s: %s") %
(self.__class__.__name__, self.__dict__))
LOG.debug(_("Saving %(name)s: %(dict)s") %
{'name': self.__class__.__name__, 'dict': self.__dict__})
return get_db_api().save(self)
@staticmethod

View File

@ -193,9 +193,10 @@ class SimpleInstance(object):
if self.db_info.server_status in ["ACTIVE", "SHUTDOWN", "DELETED"]:
return InstanceStatus.SHUTDOWN
else:
msg = _("While shutting down instance (%s): server had "
"status (%s).")
LOG.error(msg % (self.id, self.db_info.server_status))
LOG.error(_("While shutting down instance (%(instance)s): "
"server had status (%(status)s).") %
{'instance': self.id,
'status': self.db_info.server_status})
return InstanceStatus.ERROR
### Check against the service status.
@ -455,8 +456,9 @@ class Instance(BuiltInstance):
volume_size=volume_size,
service_type=service_type,
task_status=InstanceTasks.BUILDING)
LOG.debug(_("Tenant %s created new Trove instance %s...")
% (context.tenant, db_info.id))
LOG.debug(_("Tenant %(tenant)s created new "
"Trove instance %(db)s...") %
{'tenant': context.tenant, 'db': db_info.id})
service_status = InstanceServiceStatus.create(
instance_id=db_info.id,
@ -611,8 +613,9 @@ def create_server_list_matcher(server_list):
instance_id=instance_id, server_id=server_id)
else:
# Should never happen, but never say never.
LOG.error(_("Server %s for instance %s was found twice!") %
(server_id, instance_id))
LOG.error(_("Server %(server)s for instance %(instance)s was"
"found twice!") % {'server': server_id,
'instance': instance_id})
raise exception.TroveError(uuid=instance_id)
return find_server

View File

@ -438,9 +438,10 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
return False
elif (server.addresses == {} and
server.status == InstanceStatus.ERROR):
msg = _("Instance IP not available, instance (%s): "
"server had status (%s).")
LOG.error(msg % (self.id, server.status))
LOG.error(_("Instance IP not available, "
"instance (%(instance)s): "
"server had status (%(status)s)." %
{'instance': self.id, 'status': server.status}))
raise TroveError(status=server.status)
poll_until(get_server, ip_is_available,