Convert pep8 to flake8 for stx-nfv
Flake8 and Hacking offer stricter style checks than pep8. This submission fixes these codes: E305 expected 2 blank lines after class or function definition, found 1 E722 do not use bare except' F841 local variable 'blah' is assigned to but never used H101: Use TODO(NAME) H201: no 'except:' at least use 'except Exception:' H237: module commands is removed in Python 3 H238: old style class declaration, use new style(inherit from `object`) This submission enables 2 additional checks that are off by default H106 vim config in files H203 Use assertIs(Not)None to check for None 8 hacking codes and 2 flake8 types were added to the ignore list and will be fixed by later updates. An optional hacking code H904 will be enabled and the code fixed by a later commit Story: 2003499 Task: 26195 Change-Id: I48f99fc0dd41addc574c81cee6662600faeb8e75 Signed-off-by: Al Bailey <Al.Bailey@windriver.com>
This commit is contained in:
parent
adb8214db0
commit
5539db9dcf
@ -57,7 +57,7 @@ call("cp nfv-vim.log nfv-vim.log.[0-9] nfv-vim.log.[0-9][0-9] nfv-vim.log.[0-9].
|
||||
call("gunzip logs/nfv-vim.log.[0-9].gz logs/nfv-vim.log.[0-9][0-9].gz", shell=True)
|
||||
|
||||
|
||||
class Parser:
|
||||
class Parser(object):
|
||||
def __init__(self):
|
||||
self.proc="" # Name of process being read
|
||||
self.timestamp="" # Timestamp found on line stating process name
|
||||
@ -132,6 +132,7 @@ class Parser:
|
||||
csvOut.write(line+"\n")
|
||||
csvOut.close()
|
||||
|
||||
|
||||
process=Parser()
|
||||
process.main()
|
||||
print("\nComplete\n")
|
||||
|
@ -48,7 +48,7 @@ import plotly.graph_objs as go
|
||||
from plotly.graph_objs import Scatter, Layout
|
||||
from plotly import tools
|
||||
from glob import iglob
|
||||
import commands
|
||||
import subprocess
|
||||
from builtins import input
|
||||
|
||||
dir = os.path.dirname(__file__)
|
||||
@ -195,7 +195,6 @@ def gCommand(groups):
|
||||
liNum=i
|
||||
if str("GroupName="+g) == cfgLines[i].strip():
|
||||
groupFound=True
|
||||
linum=i
|
||||
while not finishedGroup:
|
||||
liNum+=1
|
||||
if "GroupEND" in cfgLines[liNum]:
|
||||
@ -366,7 +365,7 @@ def setFilename(graphName):
|
||||
|
||||
print("Welcome to plotter, type --help for information")
|
||||
# Checks that plotly is installed, otherwise graphs cannot be generated.
|
||||
plotCheck=commands.getstatusoutput("pip list | grep plotly")
|
||||
plotCheck=subprocess.getstatusoutput("pip list | grep plotly")
|
||||
if plotCheck[0]==0:
|
||||
if "plotly" not in plotCheck[1]:
|
||||
print("\n\tWARNING: Plotly is not installed on your system.\n\tPlease install it with: sudo pip install plotly\n")
|
||||
|
@ -122,7 +122,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
||||
|
||||
@staticmethod
|
||||
def _host_supports_kubernetes(personality):
|
||||
# TODO: This check will disappear once kubernetes is the default
|
||||
# TODO(bwensley): This check will disappear once kubernetes is the default
|
||||
if os.path.isfile('/etc/kubernetes/admin.conf'):
|
||||
return ('compute' in personality or 'controller' in personality)
|
||||
else:
|
||||
|
@ -249,7 +249,7 @@ def fake_event_issue(a, b, c, d):
|
||||
@mock.patch('nfv_vim.tables._instance_table._instance_table', _instance_table)
|
||||
@mock.patch('nfv_vim.tables._instance_type_table._instance_type_table', _instance_type_table)
|
||||
@mock.patch('nfv_vim.tables._image_table._image_table', _image_table)
|
||||
class TestInstance:
|
||||
class TestInstance(object):
|
||||
|
||||
def setup(self):
|
||||
"""
|
||||
|
@ -297,7 +297,7 @@ def fake_event_issue(a, b, c, d):
|
||||
@mock.patch('nfv_vim.tables._host_aggregate_table._host_aggregate_table', _host_aggregate_table)
|
||||
@mock.patch('nfv_vim.tables._instance_table._instance_table', _instance_table)
|
||||
@mock.patch('nfv_vim.strategy._strategy.get_local_host_name', fake_host_name)
|
||||
class TestSwPatchStrategy:
|
||||
class TestSwPatchStrategy(object):
|
||||
|
||||
def setup(self):
|
||||
"""
|
||||
|
@ -304,7 +304,7 @@ def fake_event_issue(a, b, c, d):
|
||||
@mock.patch('nfv_vim.tables._host_group_table._host_group_table', _host_group_table)
|
||||
@mock.patch('nfv_vim.tables._host_aggregate_table._host_aggregate_table', _host_aggregate_table)
|
||||
@mock.patch('nfv_vim.tables._instance_table._instance_table', _instance_table)
|
||||
class TestSwUpgradeStrategy:
|
||||
class TestSwUpgradeStrategy(object):
|
||||
|
||||
def setup(self):
|
||||
"""
|
||||
|
@ -105,6 +105,7 @@ class Histogram(object):
|
||||
'*' * min(60, bucket_value)))
|
||||
LOG.info("%s" % '-' * 120)
|
||||
|
||||
|
||||
_histograms = list()
|
||||
|
||||
|
||||
|
@ -35,6 +35,7 @@ class ProxySysLogHandler(SysLogHandler):
|
||||
msg = logging.handlers.SysLogHandler.format(self, record)
|
||||
return self.binary_name + '(' + self.app + ')' + ': ' + msg
|
||||
|
||||
|
||||
_loggers = {}
|
||||
|
||||
|
||||
|
@ -15,11 +15,12 @@ class timespec(ctypes.Structure):
|
||||
"""
|
||||
_fields_ = [('tv_sec', ctypes.c_long), ('tv_nsec', ctypes.c_long)]
|
||||
|
||||
|
||||
try:
|
||||
librt = ctypes.CDLL('librt.so.1', use_errno=True)
|
||||
clock_gettime = librt.clock_gettime
|
||||
clock_gettime.argtypes = [ctypes.c_int, ctypes.POINTER(timespec)]
|
||||
except:
|
||||
except Exception:
|
||||
raise OSError("Could not load librt.so.1 library")
|
||||
|
||||
|
||||
|
28
tox.ini
28
tox.ini
@ -24,7 +24,7 @@ commands =
|
||||
-o -type f -name '*.yaml' \
|
||||
-print0 | xargs -0 yamllint"
|
||||
|
||||
[pep8]
|
||||
[flake8]
|
||||
# Temporarily ignoring these warnings
|
||||
# E116 unexpected indentation (comment)
|
||||
# E121 continuation line under-indented for hanging indent
|
||||
@ -43,16 +43,34 @@ commands =
|
||||
# E265 block comment should start with '# '
|
||||
# E501 line too long
|
||||
# E712 comparison to bool should be reworded
|
||||
|
||||
ignore = E116,E121,E122,E123,E124,E126,E127,E128,E129,E225,E226,E231,E241,E261,E265,E501,E712
|
||||
# - hacking codes -
|
||||
# H102: license header not found
|
||||
# H104: File contains nothing but comments
|
||||
# H301: one import per line
|
||||
# H306: imports not in alphabetical order
|
||||
# H401: docstring should not start with a space
|
||||
# H404: multi line docstring should start without a leading new line
|
||||
# H405: multi line docstring summary not separated with an empty line
|
||||
# H501: Do not use self.__dict__ for string formatting
|
||||
# - flake8 codes -
|
||||
# F401 '<module>' imported but unused
|
||||
# F821 undefined name 'unicode' (python3 specific)
|
||||
ignore = E116,E121,E122,E123,E124,E126,E127,E128,E129,E225,E226,E231,E241,E261,E265,E501,E712,
|
||||
H102,H104,H301,H306,H401,H404,H405,H501,
|
||||
F401,F821,
|
||||
# H106 Don’t put vim configuration in source files (off by default).
|
||||
# H203 Use assertIs(Not)None to check for None (off by default).
|
||||
# TODO: enable: H904 Delay string interpolations at logging calls (off by default).
|
||||
enable-extensions = H106,H203
|
||||
|
||||
[testenv:pep8]
|
||||
usedevelop = False
|
||||
skip_install = True
|
||||
deps =
|
||||
pep8
|
||||
hacking
|
||||
flake8
|
||||
commands =
|
||||
pep8
|
||||
flake8
|
||||
|
||||
[testenv:venv]
|
||||
commands = {posargs}
|
||||
|
Loading…
x
Reference in New Issue
Block a user