summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfmenguy <francoisregis.menguy@orange.com>2020-08-24 16:00:01 +0200
committerfmenguy <francoisregis.menguy@orange.com>2020-08-24 16:04:06 +0200
commitdbb932797aff64d458231519d3cf245913913d67 (patch)
tree6e3d0571e21d98cb116d87bbbdd65eaa9e9d311c
parent259a75b97d735cff6cfc91c12bf84801c9dc992b (diff)
NFVBENCH-175 pylint w0707 correction
Change-Id: I16927f051f80c540ffc1989f5311e47e68b14a73 Signed-off-by: fmenguy <francoisregis.menguy@orange.com>
-rw-r--r--nfvbench/chaining.py5
-rw-r--r--nfvbench/config.py4
-rw-r--r--nfvbench/nfvbench.py3
-rwxr-xr-xnfvbench/traffic_client.py2
-rw-r--r--nfvbench/traffic_gen/trex_gen.py4
-rw-r--r--nfvbench/utils.py6
6 files changed, 13 insertions, 11 deletions
diff --git a/nfvbench/chaining.py b/nfvbench/chaining.py
index a52c7e9..ed2f309 100644
--- a/nfvbench/chaining.py
+++ b/nfvbench/chaining.py
@@ -279,7 +279,7 @@ class ChainNetwork(object):
return item_field[index]
except IndexError:
raise ChainException("List %s is too short for chain index %d" %
- (str(item_field), index))
+ (str(item_field), index)) from IndexError
# single value is configured
if auto_index:
return item_field + index
@@ -1195,7 +1195,8 @@ class ChainManager(object):
self.vlans = [self._check_list('vlans[0]', self.config.vlans[0], re_vlan),
self._check_list('vlans[1]', self.config.vlans[1], re_vlan)]
except IndexError:
- raise ChainException('vlans parameter is mandatory. Set valid value in config file')
+ raise ChainException(
+ 'vlans parameter is mandatory. Set valid value in config file') from IndexError
def _get_dest_macs_from_config(self):
re_mac = "[0-9a-fA-F]{2}([-:])[0-9a-fA-F]{2}(\\1[0-9a-fA-F]{2}){4}$"
diff --git a/nfvbench/config.py b/nfvbench/config.py
index 4cc9c86..c107958 100644
--- a/nfvbench/config.py
+++ b/nfvbench/config.py
@@ -28,7 +28,7 @@ def config_load(file_name, from_cfg=None, whitelist_keys=None):
except IOError:
raise Exception("Configuration file at '{}' was not found. Please use correct path "
"and verify it is visible to container if you run nfvbench in container."
- .format(file_name))
+ .format(file_name)) from IOError
if from_cfg:
if not whitelist_keys:
@@ -52,7 +52,7 @@ def config_loads(cfg_text, from_cfg=None, whitelist_keys=None):
LOG.error("String %s is not well formatted. Please verify your yaml/json string. "
"If string is a file path, file was not found. Please use correct path and "
"verify it is visible to container if you run nfvbench in container.", cfg_text)
- raise Exception(e)
+ raise Exception(e) from e
if from_cfg:
if not whitelist_keys:
whitelist_keys = []
diff --git a/nfvbench/nfvbench.py b/nfvbench/nfvbench.py
index 06ca19d..651d06b 100644
--- a/nfvbench/nfvbench.py
+++ b/nfvbench/nfvbench.py
@@ -571,7 +571,8 @@ def main():
factory = getattr(factory_module, config['factory_class'])()
except AttributeError:
raise Exception("Requested factory module '{m}' or class '{c}' was not found."
- .format(m=config['factory_module'], c=config['factory_class']))
+ .format(m=config['factory_module'],
+ c=config['factory_class'])) from AttributeError
# create config plugin for this platform
config_plugin = factory.get_config_plugin_class()(config)
config = config_plugin.get_config()
diff --git a/nfvbench/traffic_client.py b/nfvbench/traffic_client.py
index 89653a8..460e7c2 100755
--- a/nfvbench/traffic_client.py
+++ b/nfvbench/traffic_client.py
@@ -288,7 +288,7 @@ class Device(object):
value = int((ip_size / step)) + 1
return value
except ZeroDivisionError:
- raise ZeroDivisionError("step can't be zero !")
+ raise ZeroDivisionError("step can't be zero !") from ZeroDivisionError
def set_mac(self, mac):
"""Set the local MAC for this port device."""
diff --git a/nfvbench/traffic_gen/trex_gen.py b/nfvbench/traffic_gen/trex_gen.py
index b35d13f..0bf6d93 100644
--- a/nfvbench/traffic_gen/trex_gen.py
+++ b/nfvbench/traffic_gen/trex_gen.py
@@ -640,7 +640,7 @@ class TRex(AbstractTrafficGenerator):
if server_ip == '127.0.0.1':
self.__start_local_server()
else:
- raise TrafficGeneratorException(e.message)
+ raise TrafficGeneratorException(e.message) from e
ports = list(self.generator_config.ports)
self.port_handle = ports
@@ -696,7 +696,7 @@ class TRex(AbstractTrafficGenerator):
message = f.read()
else:
message = e.message
- raise TrafficGeneratorException(message)
+ raise TrafficGeneratorException(message) from e
def __start_server(self):
server = TRexTrafficServer()
diff --git a/nfvbench/utils.py b/nfvbench/utils.py
index b92c75e..06f643c 100644
--- a/nfvbench/utils.py
+++ b/nfvbench/utils.py
@@ -166,7 +166,7 @@ def parse_flow_count(flow_count):
try:
flow_count = int(flow_count)
except ValueError:
- raise Exception("Unknown flow count format '{}'".format(input_fc))
+ raise Exception("Unknown flow count format '{}'".format(input_fc)) from ValueError
return flow_count * multiplier
@@ -190,8 +190,8 @@ class RunLock(object):
try:
self._fd = os.open(self._path, os.O_CREAT)
fcntl.flock(self._fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
- except (OSError, IOError):
- raise Exception('Other NFVbench process is running. Please wait')
+ except (OSError, IOError) as e:
+ raise Exception('Other NFVbench process is running. Please wait') from e
def __exit__(self, *args):
fcntl.flock(self._fd, fcntl.LOCK_UN)