Cleanup pylint errors in sysinv

These are pylint errors (rather than warnings)
  E0702: raising-bad-type
  E0712: catching-non-exception
  E1003: bad-super-call
  E1111: assignment-from-no-return
  E1305: too-many-format-args

As part of testing, config controller was run.

Story: 2004515
Task: 28687
Change-Id: If7005dfd3c61e5a6d5de9e2266c898c5f1119b96
Signed-off-by: Al Bailey <Al.Bailey@windriver.com>
This commit is contained in:
Al Bailey 2018-12-28 09:02:11 -06:00
parent e6c0e0af8c
commit a6bb91bccc
11 changed files with 24 additions and 27 deletions

View File

@ -78,24 +78,19 @@ load-plugins=
# E0611: no-name-in-module
# E0633: unpacking-non-sequence
# E0701: bad-except-order
# E0702: raising-bad-type
# E0712: catching-non-exception
# E1003: bad-super-call
# E1101: no-member
# E1102: not-callable
# E1111: assignment-from-no-return
# E1120: no-value-for-parameter
# E1121: too-many-function-args
# E1124: redundant-keyword-arg
# E1136: unsubscriptable-object
# E1205: logging-too-many-args
# E1305: too-many-format-args
disable=C, R, fixme, W0101, W0102, W0105, W0106, W0107, W0108, W0110, W0120, W0123, W0150,
W0201, W0211, W0212, W0221, W0223, W0231, W0235, W0311, W0402, W0403, W0404,
W0603, W0611, W0612, W0613, W0621, W0622, W0631, W0632, W0701, W0703,
W1113, W1201, W1401, W1505,
E0202, E0203, E0213, E0401, E0602, E0604, E0611, E0633, E0701, E0702, E0712,
E1003, E1101, E1102, E1111, E1120, E1121, E1124, E1136, E1205, E1305
E0202, E0203, E0213, E0401, E0602, E0604, E0611, E0633, E0701,
E1101, E1102, E1120, E1121, E1124, E1136, E1205
[REPORTS]
# Set the output format. Available formats are text, parseable, colorized, msvs

View File

@ -27,7 +27,8 @@ from sysinv.api.controllers.v1 import utils as api_utils
from sysinv.common import exception
from sysinv.common import utils as cutils
from sysinv import objects
from sysinv.openstack.common.db import exception as Exception
from sysinv.openstack.common.db.exception import DBDuplicateEntry
from sysinv.openstack.common.db.exception import DBError
from sysinv.openstack.common.gettextutils import _
from sysinv.openstack.common import log
@ -177,11 +178,11 @@ class CommunityController(rest.RestController):
try:
new_icommunity = \
pecan.request.dbapi.icommunity_create(icommunity.as_dict())
except Exception.DBDuplicateEntry as e:
except DBDuplicateEntry as e:
LOG.error(e)
raise wsme.exc.ClientSideError(_(
"Rejected: Cannot add %s, it is an existing community.") % icommunity.as_dict().get('community'))
except Exception.DBError as e:
except DBError as e:
LOG.error(e)
raise wsme.exc.ClientSideError(_(
"Database check error on community %s create.") % icommunity.as_dict().get('community'))

View File

@ -1197,7 +1197,7 @@ def _create_cpu_profile(profile_name, profile_node):
except dbException.DBDuplicateEntry as e:
LOG.exception(e)
return "Warning", _('warning: CPU profile %s already exists and is not imported.') % profile_name, None
except exception as e:
except Exception as e:
LOG.exception(e)
return "Error", _('error: importing CPU profile %s failed.') % profile_name, e.message
@ -1331,7 +1331,7 @@ def _create_if_profile(profile_name, profile_node):
except dbException.DBDuplicateEntry as e:
LOG.exception(e)
return "Warning", _('warning: interface profile %s already exists and is not imported.') % profile_name, None
except exception as e:
except Exception as e:
LOG.exception(e)
return "Error", _('error: importing interface profile %s failed.') % profile_name, e.message
@ -1540,7 +1540,7 @@ def _create_mem_profile(profile_name, profile_node):
except dbException.DBDuplicateEntry as e:
LOG.exception(e)
return "Warning", _('warning: Memory profile %s already exists and is not imported.') % profile_name, None
except exception as e:
except Exception as e:
LOG.exception(e)
return "Error", _('error: Creating memory profile %s failed.') % profile_name, e.message
@ -1660,7 +1660,7 @@ def _create_storage_profile(profile_name, profile_node):
except dbException.DBDuplicateEntry as e:
LOG.exception(e)
return "Warning", _('warning: Storage profile %s already exists and is not imported.') % profile_name, None
except exception as e:
except Exception as e:
LOG.exception(e)
return "Error", _('error: importing storage profile %s failed.') % profile_name, e.message
@ -1803,7 +1803,7 @@ def _create_localstorage_profile(profile_name, profile_node):
LOG.exception(e)
return ("Warning", _('warning: Local Storage profile %s already '
'exists and is not imported.') % profile_name, None)
except exception as e:
except Exception as e:
LOG.exception(e)
return ("Error", _('error: importing Local Storage profile %s '
'failed.') % profile_name, e.message)
@ -1859,7 +1859,7 @@ def _create_localstorage_profile(profile_name, profile_node):
LOG.exception(cse)
return "Fail", _('Local Storage profile %s not imported.') % profile_name, str(cse)
except exception as exc:
except Exception as exc:
pecan.request.dbapi.ihost_destroy(profile_id)
LOG.exception(exc)
return "Fail", _('Local Storage profile %s not imported.') % profile_name, str(exc)

View File

@ -786,7 +786,7 @@ def _check_device(new_pv, ihost):
def _check(op, pv):
# Semantic checks
LOG.debug("Semantic check for %s operation".format(op))
LOG.debug("Semantic check for %s operation" % op)
# Check parameters
_check_parameters(pv)

View File

@ -398,7 +398,7 @@ def _pre_patch_checks(tier_obj, patch_obj):
def _check(op, tier):
# Semantic checks
LOG.debug("storage_tier: Semantic check for %s operation".format(op))
LOG.debug("storage_tier: Semantic check for %s operation" % op)
# Check storage tier parameters
_check_parameters(tier)

View File

@ -450,6 +450,7 @@ class SBApiHelper(object):
else:
raise wsme.exc.ClientSideError("This operation requires storage "
"backend name to be specified.")
return backend
@staticmethod
def common_checks(operation, storage_backend_dict):

View File

@ -408,7 +408,7 @@ class OpenStackOperator(object):
if not agg_add_to:
LOG.error("The nova-local LVG for host: %s has an invalid "
"instance backing: " % (ihost_uuid, agg_add_to))
"instance backing: " % ihost_uuid)
ihost = self.dbapi.ihost_get(ihost_uuid)
for aggregate in aggregates.values():

View File

@ -117,7 +117,7 @@ class OpenstackBaseHelm(base.BaseHelm):
'namespace': namespace,
}
override = self.dbapi.helm_override_create(values=values)
except exception as e:
except Exception as e:
LOG.exception(e)
return None
@ -135,7 +135,7 @@ class OpenstackBaseHelm(base.BaseHelm):
try:
self.dbapi.helm_override_update(
name=chart, namespace=namespace, values=values)
except exception as e:
except Exception as e:
LOG.exception(e)
return password.encode('utf8', 'strict')

View File

@ -555,4 +555,4 @@ class DeprecatedConfig(Exception):
message = _("Fatal call to deprecated config: %(msg)s")
def __init__(self, msg):
super(Exception, self).__init__(self.message % dict(msg=msg))
super(DeprecatedConfig, self).__init__(self.message % dict(msg=msg))

View File

@ -514,7 +514,7 @@ class MulticallProxyWaiter(object):
raise StopIteration
if isinstance(result, Exception):
self.done()
raise result
raise result # pylint: disable=raising-bad-type
yield result
@ -567,7 +567,7 @@ class MulticallWaiter(object):
result = self._result
if isinstance(result, Exception):
self.done()
raise result
raise result # pylint: disable=raising-bad-type
yield result

View File

@ -303,7 +303,7 @@ class LocalhostExchange(Exchange):
"""Exchange where all direct topics are local."""
def __init__(self, host='localhost'):
self.host = host
super(Exchange, self).__init__()
super(LocalhostExchange, self).__init__()
def run(self, key):
return [('.'.join((key.split('.')[0], self.host)), self.host)]
@ -315,7 +315,7 @@ class DirectExchange(Exchange):
i.e. "compute.host" sends a message to "compute.host" running on "host"
"""
def __init__(self):
super(Exchange, self).__init__()
super(DirectExchange, self).__init__()
def run(self, key):
e = key.split('.', 1)[1]
@ -341,7 +341,7 @@ class MatchMakerStub(MatchMakerBase):
Will not work where knowledge of hosts is known (i.e. zeromq)
"""
def __init__(self):
super(MatchMakerLocalhost, self).__init__()
super(MatchMakerStub, self).__init__()
self.add_binding(FanoutBinding(), StubExchange())
self.add_binding(DirectBinding(), StubExchange())