Minor sw-patch tox cleanup

These changes will not affect the behaviour of sw-patch.

- Remove fm-api from tox dependencies for sw-patch.
  - fm-api is not used by sw-patch

- Cleanup flake8 error:
  H401  docstring should not start with a space

- Cleanup pylint error:
  R1710 inconsistent-return-statements

- Cleanup pylint error:
   W1505 deprecated-method
    The following are the deprecated methods
    - LOG.warn  -> LOG.warning
    - ConfigParser.readfp -> ConfigParser.read_file

- Added missing description for a suppressed pylint error
  - W3101 missing-timeout

- Added two additional tox utilities:
  Neither tool is wired into the default tox, or zuul jobs.

  - tox -e prospector
     prospector calls multiple linters and validators

  - tox -e vulture
      vulture is a tool that detects unused code.

Test Plan:
  - Run tox
  - Build / Install / Unlock AIO-DX
  - Apply a reboot required patch

Story: 2009969
Task: 46265
Signed-off-by: Al Bailey <al.bailey@windriver.com>
Change-Id: I7fcd386d11ec3836059b1036fb334dcae9bedeb1
This commit is contained in:
Al Bailey 2022-09-11 14:28:57 +00:00
parent dd6bc2242c
commit 93163a4aaa
6 changed files with 28 additions and 19 deletions

View File

@ -66,7 +66,7 @@ def read_config():
# for ConfigParser. So we'll fake it out.
ini_str = '[platform_conf]\n' + open(tsc.PLATFORM_CONF_FILE, 'r').read()
ini_fp = io.StringIO(ini_str)
config.readfp(ini_fp)
config.read_file(ini_fp)
try:
value = str(config.get('platform_conf', 'nodetype'))
@ -75,7 +75,6 @@ def read_config():
nodetype = value
except configparser.Error:
logging.exception("Failed to read nodetype from config")
return False
def get_mgmt_ip():
@ -111,7 +110,7 @@ def get_mgmt_iface():
# for ConfigParser. So we'll fake it out.
ini_str = '[platform_conf]\n' + open(tsc.PLATFORM_CONF_FILE, 'r').read()
ini_fp = io.StringIO(ini_str)
config.readfp(ini_fp)
config.read_file(ini_fp)
try:
value = str(config.get('platform_conf', 'management_interface'))

View File

@ -344,7 +344,7 @@ class PatchAgent(PatchService):
self.listener.listen(2) # Allow two connections, for two controllers
def query(self):
""" Check current patch state """
"""Check current patch state """
if not check_install_uuid():
LOG.info("Failed install_uuid check. Skipping query")
return False
@ -366,7 +366,7 @@ class PatchAgent(PatchService):
try:
self.latest_feed_commit = ostree_utils.get_feed_latest_commit(SW_VERSION)
except OSTreeCommandFail:
LOG.warn("Unable to query latest feed commit")
LOG.warning("Unable to query latest feed commit")
# latest_feed_commit will remain as None
if self.latest_feed_commit:
@ -507,7 +507,7 @@ class PatchAgent(PatchService):
self.query()
if self.changes:
LOG.warn("Installing the patch did not change the patch current status")
LOG.warning("Installing the patch did not change the patch current status")
# Send a hello to provide a state update
if self.sock_out is not None:

View File

@ -1085,7 +1085,7 @@ def patch_upload_dir_req(debug, args):
def patch_install_local(debug, args): # pylint: disable=unused-argument
""" This function is used to trigger patch installation prior to configuration """
"""This function is used to trigger patch installation prior to configuration """
# Check to see if initial configuration has completed
if os.path.isfile(INITIAL_CONTROLLER_CONFIG_COMPLETE):
# Disallow the install

View File

@ -24,7 +24,7 @@ def if_nametoindex(name):
def gethostbyname(hostname):
""" gethostbyname with IPv6 support """
"""gethostbyname with IPv6 support """
try:
return socket.getaddrinfo(hostname, None)[0][4][0]
except Exception:
@ -32,7 +32,7 @@ def gethostbyname(hostname):
def get_management_version():
""" Determine whether management is IPv4 or IPv6 """
"""Determine whether management is IPv4 or IPv6 """
controller_ip_string = gethostbyname(constants.CONTROLLER_FLOATING_HOSTNAME)
if controller_ip_string:
controller_ip_address = IPAddress(controller_ip_string)
@ -58,7 +58,7 @@ def get_versioned_address_all():
def ip_to_url(ip_address_string):
""" Add brackets if an IPv6 address """
"""Add brackets if an IPv6 address """
try:
ip_address = IPAddress(ip_address_string)
if ip_address.version == constants.ADDRESS_VERSION_IPV6:
@ -70,7 +70,7 @@ def ip_to_url(ip_address_string):
def ip_to_versioned_localhost(ip_address_string):
""" Add brackets if an IPv6 address """
"""Add brackets if an IPv6 address """
ip_address = IPAddress(ip_address_string)
if ip_address.version == constants.ADDRESS_VERSION_IPV6:
return "::1"
@ -108,8 +108,8 @@ def safe_rstrip(value, chars=None):
"""
if not isinstance(value, str):
LOG.warn("Failed to remove trailing character. Returning original "
"object. Supplied object is not a string: %s", value)
LOG.warning("Failed to remove trailing character. Returning original "
"object. Supplied object is not a string: %s", value)
return value
return value.rstrip(chars) or value

View File

@ -73,7 +73,6 @@ extension-pkg-whitelist=lxml
# R0915 too-many-statements
# R1702 too-many-nested-blocks
# R1705 no-else-return
# R1710 inconsistent-return-statements
# R1714 consider-using-in
# R1715 consider-using-get
# R1722 consider-using-sys-exit
@ -89,12 +88,13 @@ extension-pkg-whitelist=lxml
# W0707 raise-missing-from
# W1505 deprecated-method
# W1514 unspecified-encoding
# W3101 missing-timeout
disable= C0103,C0114,C0115,C0116,C0201,C0206,C0209,C2801,
C0301,C0302,C0325,C0411,C0415,
R0205,R0402,R0801,R0902,R0903,R0904,R0911,
R0912,R0913,R0914,R0915,R1702,R1705,R1710,R1714,
R0912,R0913,R0914,R0915,R1702,R1705,R1714,
R1715,R1722,R1724,R1725,R1732,R1735,
W0107,W0602,W0603,W0703,W0707,W1505,W1514,W3101
W0107,W0602,W0603,W0703,W0707,W1514,W3101
[REPORTS]

View File

@ -16,7 +16,6 @@ basepython = python3
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
-e{[tox]stxdir}/fault/fm-api/source
-e{[tox]stxdir}/config/tsconfig/tsconfig
install_command = pip install \
@ -84,7 +83,6 @@ commands = bandit --ini tox.ini -n 5 -r cgcs_patch
[flake8]
# ignore below errors , will fix flake8 errors in future
# 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
# Note: W503 and W504 are mutually exclusive. Must select one of them to suppress.
@ -92,7 +90,7 @@ commands = bandit --ini tox.ini -n 5 -r cgcs_patch
# E501 line too long. skipped because some of the code files include templates
# that end up quite wide
show-source = True
ignore = H306,H401,H404,H405,W504,E501
ignore = H306,H404,H405,W504,E501
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,release-tag-*
# H106: Don't put vim configuration in source files (off by default).
@ -110,6 +108,18 @@ commands = flake8 {posargs}
[testenv:pylint]
commands = pylint cgcs_patch cgcs_make_patch --rcfile=./pylint.rc
[testenv:prospector]
basepython = python3.9
deps = {[testenv]deps}
prospector
commands = prospector cgcs_patch
[testenv:vulture]
basepython = python3.9
deps = {[testenv]deps}
vulture
commands = vulture cgcs_make_patch cgcs_patch
[testenv:cover]
setenv =
PYTHONWARNINGS=ignore::DeprecationWarning,ignore::SyntaxWarning