Code Review
/
nfvbench.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
NFVBENCH-40 Add pylint to tox
[nfvbench.git]
/
nfvbench
/
utils.py
diff --git
a/nfvbench/utils.py
b/nfvbench/utils.py
index
4d9749c
..
412dfae
100644
(file)
--- a/
nfvbench/utils.py
+++ b/
nfvbench/utils.py
@@
-12,15
+12,17
@@
# License for the specific language governing permissions and limitations
# under the License.
# License for the specific language governing permissions and limitations
# under the License.
+from math import isnan
+import os
+import re
+import signal
+import subprocess
+
import errno
import fcntl
from functools import wraps
import json
from log import LOG
import errno
import fcntl
from functools import wraps
import json
from log import LOG
-import os
-import re
-import signal
-import subprocess
class TimeoutError(Exception):
class TimeoutError(Exception):
@@
-29,7
+31,7
@@
class TimeoutError(Exception):
def timeout(seconds=10, error_message=os.strerror(errno.ETIME)):
def decorator(func):
def timeout(seconds=10, error_message=os.strerror(errno.ETIME)):
def decorator(func):
- def _handle_timeout(
signum,
frame):
+ def _handle_timeout(
_signum, _
frame):
raise TimeoutError(error_message)
def wrapper(*args, **kwargs):
raise TimeoutError(error_message)
def wrapper(*args, **kwargs):
@@
-109,7
+111,7
@@
def get_intel_pci(nic_ports):
for driver in ['i40e', 'ixgbe']:
matches = re.findall(regex.format(hx=hx, driver=driver), devices)
if matches:
for driver in ['i40e', 'ixgbe']:
matches = re.findall(regex.format(hx=hx, driver=driver), devices)
if matches:
- pcis =
map(lambda x: x[0], matches)
+ pcis =
[x[0] for x in matches]
if len(pcis) < 2:
continue
pcis.sort()
if len(pcis) < 2:
continue
pcis.sort()
@@
-141,6
+143,10
@@
def parse_flow_count(flow_count):
return flow_count * multiplier
return flow_count * multiplier
+def cast_integer(value):
+ return int(value) if not isnan(value) else value
+
+
class RunLock(object):
"""
Attempts to lock file and run current instance of NFVbench as the first,
class RunLock(object):
"""
Attempts to lock file and run current instance of NFVbench as the first,