Fix pylint errors (raise-missing-from)
Change-Id: I02a00ed6b3611606785a3521361bf88705d42e07
This commit is contained in:
parent
154c0981f5
commit
946e59680e
|
@ -65,9 +65,9 @@ class TobikoException(Exception):
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
try:
|
try:
|
||||||
return self._properties[name]
|
return self._properties[name]
|
||||||
except KeyError:
|
except KeyError as ex:
|
||||||
msg = ("{!r} object has no attribute {!r}").format(self, name)
|
raise AttributeError(f"{self!r} object has no attribute "
|
||||||
raise AttributeError(msg)
|
f"'{name}'") from ex
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "{class_name}({message!r})".format(
|
return "{class_name}({message!r})".format(
|
||||||
|
|
|
@ -16,7 +16,7 @@ from __future__ import absolute_import
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import typing
|
import typing # noqa
|
||||||
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from stestr import config_file
|
from stestr import config_file
|
||||||
|
@ -112,10 +112,9 @@ class TestCasesFinder(object):
|
||||||
ids = cmd.list_tests()
|
ids = cmd.list_tests()
|
||||||
else:
|
else:
|
||||||
ids = cmd.test_ids
|
ids = cmd.test_ids
|
||||||
except SystemExit:
|
except SystemExit as ex:
|
||||||
msg = ("Error discovering test cases IDs with parameters: "
|
raise RuntimeError("Error discovering test cases IDs with "
|
||||||
"{!r}").format(params)
|
f"parameters: {params}") from ex
|
||||||
raise RuntimeError(msg)
|
|
||||||
finally:
|
finally:
|
||||||
cmd.cleanUp()
|
cmd.cleanUp()
|
||||||
|
|
||||||
|
|
|
@ -45,17 +45,14 @@ class HTTPConnection(connection.HTTPConnection):
|
||||||
conn = connection.connection.create_connection(
|
conn = connection.connection.create_connection(
|
||||||
address, self.timeout, **extra_kw)
|
address, self.timeout, **extra_kw)
|
||||||
|
|
||||||
except connection.SocketTimeout:
|
except connection.SocketTimeout as ex:
|
||||||
raise connection.ConnectTimeoutError(
|
raise connection.ConnectTimeoutError(
|
||||||
self,
|
self, (f"Connection to {self.host} timed out. "
|
||||||
"Connection to %s timed out. (connect timeout=%s)"
|
f"(connect timeout={self.timeout})")) from ex
|
||||||
% (self.host, self.timeout),
|
|
||||||
)
|
|
||||||
|
|
||||||
except connection.SocketError as e:
|
except connection.SocketError as ex:
|
||||||
raise connection.NewConnectionError(
|
raise connection.NewConnectionError(
|
||||||
self, "Failed to establish a new connection: %s" % e
|
self, f"Failed to establish a new connection: {ex}") from ex
|
||||||
)
|
|
||||||
|
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
|
|
|
@ -139,29 +139,29 @@ def get_network(network, client=None, **params):
|
||||||
try:
|
try:
|
||||||
return neutron_client(client).show_network(network,
|
return neutron_client(client).show_network(network,
|
||||||
**params)['network']
|
**params)['network']
|
||||||
except neutronclient.exceptions.NotFound:
|
except neutronclient.exceptions.NotFound as ex:
|
||||||
raise NoSuchNetwork(id=network)
|
raise NoSuchNetwork(id=network) from ex
|
||||||
|
|
||||||
|
|
||||||
def get_port(port, client=None, **params):
|
def get_port(port, client=None, **params):
|
||||||
try:
|
try:
|
||||||
return neutron_client(client).show_port(port, **params)['port']
|
return neutron_client(client).show_port(port, **params)['port']
|
||||||
except neutronclient.exceptions.NotFound:
|
except neutronclient.exceptions.NotFound as ex:
|
||||||
raise NoSuchPort(id=port)
|
raise NoSuchPort(id=port) from ex
|
||||||
|
|
||||||
|
|
||||||
def get_router(router, client=None, **params):
|
def get_router(router, client=None, **params):
|
||||||
try:
|
try:
|
||||||
return neutron_client(client).show_router(router, **params)['router']
|
return neutron_client(client).show_router(router, **params)['router']
|
||||||
except neutronclient.exceptions.NotFound:
|
except neutronclient.exceptions.NotFound as ex:
|
||||||
raise NoSuchRouter(id=router)
|
raise NoSuchRouter(id=router) from ex
|
||||||
|
|
||||||
|
|
||||||
def get_subnet(subnet, client=None, **params):
|
def get_subnet(subnet, client=None, **params):
|
||||||
try:
|
try:
|
||||||
return neutron_client(client).show_subnet(subnet, **params)['subnet']
|
return neutron_client(client).show_subnet(subnet, **params)['subnet']
|
||||||
except neutronclient.exceptions.NotFound:
|
except neutronclient.exceptions.NotFound as ex:
|
||||||
raise NoSuchSubnet(id=subnet)
|
raise NoSuchSubnet(id=subnet) from ex
|
||||||
|
|
||||||
|
|
||||||
def list_l3_agent_hosting_routers(router, client=None, **params):
|
def list_l3_agent_hosting_routers(router, client=None, **params):
|
||||||
|
|
|
@ -60,10 +60,9 @@ def check_server_ip_address(address, ip_version=None, address_type=None):
|
||||||
try:
|
try:
|
||||||
if address_type != address['OS-EXT-IPS:type']:
|
if address_type != address['OS-EXT-IPS:type']:
|
||||||
return False
|
return False
|
||||||
except KeyError:
|
except KeyError as ex:
|
||||||
message = ("Unable to get IP type from server address {!r}"
|
raise ValueError("Unable to get IP type from server address "
|
||||||
).format(address)
|
f"'{address}'") from ex
|
||||||
raise ValueError(message)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -269,13 +269,12 @@ def find_external_network(name=None):
|
||||||
params['name'] = name
|
params['name'] = name
|
||||||
try:
|
try:
|
||||||
network = neutron.find_network(**params)
|
network = neutron.find_network(**params)
|
||||||
except tobiko.ObjectNotFound:
|
except tobiko.ObjectNotFound as ex:
|
||||||
LOG.exception('No such network (%s):',
|
LOG.exception('No such network (%s):',
|
||||||
json.dumps(params, sort_keys=True))
|
json.dumps(params, sort_keys=True))
|
||||||
if name:
|
if name:
|
||||||
message = ('No such external network with name or ID '
|
raise ValueError("No such external network with name or ID "
|
||||||
'{!r}').format(name)
|
f"'{name}'") from ex
|
||||||
raise ValueError(message)
|
|
||||||
|
|
||||||
if network:
|
if network:
|
||||||
LOG.debug('Found external network %r:\n%s',
|
LOG.debug('Found external network %r:\n%s',
|
||||||
|
|
|
@ -15,7 +15,7 @@ from __future__ import absolute_import
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import socket
|
import socket
|
||||||
import typing
|
import typing # noqa
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
|
|
||||||
|
@ -300,8 +300,9 @@ class OpenStackTopology(tobiko.SharedFixture):
|
||||||
def get_group(self, group):
|
def get_group(self, group):
|
||||||
try:
|
try:
|
||||||
return self._nodes_by_group[group]
|
return self._nodes_by_group[group]
|
||||||
except KeyError:
|
except KeyError as ex:
|
||||||
raise _exception.NoSuchOpenStackTopologyNodeGroup(group=group)
|
raise _exception.NoSuchOpenStackTopologyNodeGroup(
|
||||||
|
group=group) from ex
|
||||||
|
|
||||||
def get_groups(self, groups):
|
def get_groups(self, groups):
|
||||||
nodes = []
|
nodes = []
|
||||||
|
|
|
@ -28,8 +28,10 @@ def discover_podman_socket(ssh_client=None, **execute_params):
|
||||||
raise _exception.PodmanSocketNotFoundError(details=result.stderr)
|
raise _exception.PodmanSocketNotFoundError(details=result.stderr)
|
||||||
try:
|
try:
|
||||||
socket = result.stdout.splitlines()[0]
|
socket = result.stdout.splitlines()[0]
|
||||||
except IndexError:
|
except IndexError as ex:
|
||||||
raise _exception.PodmanSocketNotFoundError(details=result.stderr)
|
podman_error = _exception.PodmanSocketNotFoundError(
|
||||||
|
details=result.stderr)
|
||||||
|
raise podman_error from ex
|
||||||
if '0 sockets listed' in socket:
|
if '0 sockets listed' in socket:
|
||||||
raise _exception.PodmanSocketNotFoundError(details=socket)
|
raise _exception.PodmanSocketNotFoundError(details=socket)
|
||||||
return socket
|
return socket
|
||||||
|
|
|
@ -223,9 +223,9 @@ class ShellProcessFixture(tobiko.SharedFixture):
|
||||||
try:
|
try:
|
||||||
# Get attributes from parameters class
|
# Get attributes from parameters class
|
||||||
return getattr(self.parameters, name)
|
return getattr(self.parameters, name)
|
||||||
except AttributeError:
|
except AttributeError as ex:
|
||||||
message = "object {!r} has not attribute {!r}".format(self, name)
|
message = "object {!r} has not attribute {!r}".format(self, name)
|
||||||
raise AttributeError(message)
|
raise AttributeError(message) from ex
|
||||||
|
|
||||||
def kill(self):
|
def kill(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
|
@ -118,13 +118,13 @@ class SSHShellProcessFixture(_process.ShellProcessFixture):
|
||||||
exc_info=1)
|
exc_info=1)
|
||||||
try:
|
try:
|
||||||
attempt.check_limits()
|
attempt.check_limits()
|
||||||
except tobiko.RetryTimeLimitError:
|
except tobiko.RetryTimeLimitError as ex:
|
||||||
LOG.debug(f"Timed out creating remote process. ({details})")
|
LOG.debug(f"Timed out creating remote process. ({details})")
|
||||||
raise _exception.ShellTimeoutExpired(command=command,
|
raise _exception.ShellTimeoutExpired(command=command,
|
||||||
stdin=None,
|
stdin=None,
|
||||||
stdout=None,
|
stdout=None,
|
||||||
stderr=None,
|
stderr=None,
|
||||||
timeout=timeout)
|
timeout=timeout) from ex
|
||||||
|
|
||||||
def setup_stdin(self):
|
def setup_stdin(self):
|
||||||
self.stdin = _io.ShellStdin(
|
self.stdin = _io.ShellStdin(
|
||||||
|
|
Loading…
Reference in New Issue