Fixes issues with tox

A recent change updated the settings of yapf in Spyglass. This change
matches this recent change and fixes the directory used in tox. It also
fixes the directories used in tox.ini and removes unnecessary flake8
ignores.

Change-Id: I7036f885a3c45880b7b9be604bc6c1c533622134
This commit is contained in:
Ian H. Pittwood 2019-05-29 10:27:07 -05:00
parent ec863a4f16
commit 93e78c472d
6 changed files with 51 additions and 40 deletions

View File

@ -33,5 +33,6 @@ class NoSpecMatched(BaseError):
self.specs = excel_specs self.specs = excel_specs
def display_error(self): def display_error(self):
print("No spec matched. Following are the available specs:\n".format( print(
"No spec matched. Following are the available specs:\n".format(
self.specs)) self.specs))

View File

@ -24,7 +24,8 @@ LOG_FORMAT = '%(asctime)s %(levelname)-8s %(name)s:' \
'%(funcName)s [%(lineno)3d] %(message)s' '%(funcName)s [%(lineno)3d] %(message)s'
@click.option('-v', @click.option(
'-v',
'--verbose', '--verbose',
is_flag=True, is_flag=True,
default=False, default=False,
@ -108,7 +109,8 @@ FORCE_OPTION = click.option(
help="Forces manifests to be written, regardless of undefined data.") help="Forces manifests to be written, regardless of undefined data.")
@excel.command('intermediary', @excel.command(
'intermediary',
short_help='generate intermediary', short_help='generate intermediary',
help='Generates an intermediary file from passed excel data.') help='Generates an intermediary file from passed excel data.')
@EXCEL_FILE_OPTION @EXCEL_FILE_OPTION
@ -124,7 +126,8 @@ def generate_intermediary(*args, **kwargs):
process_input_ob.dump_intermediary_file(kwargs['intermediary_dir']) process_input_ob.dump_intermediary_file(kwargs['intermediary_dir'])
@excel.command('documents', @excel.command(
'documents',
short_help='generates manifest documents and intermediary', short_help='generates manifest documents and intermediary',
help='Generates manifest documents and intermediary file.') help='Generates manifest documents and intermediary file.')
@click.option( @click.option(

View File

@ -107,7 +107,8 @@ class ExcelPlugin(BaseDataSourcePlugin):
host_list = [] host_list = []
for rack in rackwise_hosts.keys(): for rack in rackwise_hosts.keys():
for host in rackwise_hosts[rack]: for host in rackwise_hosts[rack]:
host_list.append({ host_list.append(
{
"rack_name": rack, "rack_name": rack,
"name": host, "name": host,
"host_profile": ipmi_data[host]["host_profile"], "host_profile": ipmi_data[host]["host_profile"],
@ -151,7 +152,8 @@ class ExcelPlugin(BaseDataSourcePlugin):
tmp_vlan["name"] = "ingress" tmp_vlan["name"] = "ingress"
tmp_vlan["subnet"] = net_val tmp_vlan["subnet"] = net_val
vlan_list.append(tmp_vlan) vlan_list.append(tmp_vlan)
LOG.debug("vlan list extracted from spyglass-plugin-xls:\n{}".format( LOG.debug(
"vlan list extracted from spyglass-plugin-xls:\n{}".format(
pprint.pformat(vlan_list))) pprint.pformat(vlan_list)))
return vlan_list return vlan_list
@ -194,8 +196,8 @@ class ExcelPlugin(BaseDataSourcePlugin):
ldap_info["domain"] = url.split(".")[1] ldap_info["domain"] = url.split(".")[1]
except IndexError as e: except IndexError as e:
LOG.error("url.split:{}".format(e)) LOG.error("url.split:{}".format(e))
ldap_info["common_name"] = ldap_raw_data.get("common_name", ldap_info["common_name"] = ldap_raw_data.get(
"#CHANGE_ME") "common_name", "#CHANGE_ME")
ldap_info["subdomain"] = ldap_raw_data.get("subdomain", "#CHANGE_ME") ldap_info["subdomain"] = ldap_raw_data.get("subdomain", "#CHANGE_ME")
return ldap_info return ldap_info
@ -227,8 +229,8 @@ class ExcelPlugin(BaseDataSourcePlugin):
location_data = self.parsed_xl_data["site_info"]["location"] location_data = self.parsed_xl_data["site_info"]["location"]
corridor_pattern = r"\d+" corridor_pattern = r"\d+"
corridor_number = re.findall(corridor_pattern, corridor_number = re.findall(
location_data["corridor"])[0] corridor_pattern, location_data["corridor"])[0]
name = location_data.get("name", "#CHANGE_ME") name = location_data.get("name", "#CHANGE_ME")
state = location_data.get("state", "#CHANGE_ME") state = location_data.get("state", "#CHANGE_ME")
country = location_data.get("country", "#CHANGE_ME") country = location_data.get("country", "#CHANGE_ME")

View File

@ -127,9 +127,11 @@ class ExcelParser(object):
"type": type, "type": type,
} }
row += 1 row += 1
LOG.debug("ipmi data extracted from excel:\n{}".format( LOG.debug(
"ipmi data extracted from excel:\n{}".format(
pprint.pformat(ipmi_data))) pprint.pformat(ipmi_data)))
LOG.debug("host data extracted from excel:\n{}".format( LOG.debug(
"host data extracted from excel:\n{}".format(
pprint.pformat(hosts))) pprint.pformat(hosts)))
return [ipmi_data, hosts] return [ipmi_data, hosts]
@ -149,8 +151,8 @@ class ExcelParser(object):
vlan = vlan.lower() vlan = vlan.lower()
vlan_data[vlan] = cell_value vlan_data[vlan] = cell_value
row += 1 row += 1
LOG.debug("vlan data extracted from excel:\n%s", LOG.debug(
pprint.pformat(vlan_data)) "vlan data extracted from excel:\n%s", pprint.pformat(vlan_data))
return vlan_data return vlan_data
def get_private_network_data(self): def get_private_network_data(self):
@ -270,10 +272,12 @@ class ExcelParser(object):
ntp_servers = ws.cell(row=ntp_row, column=ntp_col).value ntp_servers = ws.cell(row=ntp_row, column=ntp_col).value
try: try:
if dns_servers is None: if dns_servers is None:
raise RuntimeError(( raise RuntimeError(
(
"No value for dns_server from:{} Sheet:'{}' ", "No value for dns_server from:{} Sheet:'{}' ",
"Row:{} Col:{}", "Row:{} Col:{}",
).format(self.file_name, provided_sheetname, dns_row, dns_col)) ).format(
self.file_name, provided_sheetname, dns_row, dns_col))
except RuntimeError as rerror: except RuntimeError as rerror:
LOG.critical(rerror) LOG.critical(rerror)
sys.exit("Tugboat exited!!") sys.exit("Tugboat exited!!")

View File

@ -6,6 +6,7 @@ hacking==1.1.0
# Security # Security
bandit==1.6.0 bandit==1.6.0
safety==1.8.5
# Installs Spyglass for independent tests, but not in requirements.txt since Spyglass will always install this plugin # Installs Spyglass for independent tests, but not in requirements.txt since Spyglass will always install this plugin
git+https://opendev.org/airship/spyglass.git#egg=spyglass git+https://opendev.org/airship/spyglass.git#egg=spyglass

12
tox.ini
View File

@ -24,7 +24,7 @@ basepython = python3
deps = deps =
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
commands = commands =
yapf -ir {toxinidir}/spyglass-plugin-xls {toxinidir}/setup.py yapf -ir {toxinidir}/spyglass_plugin_xls {toxinidir}/setup.py
[testenv:pep8] [testenv:pep8]
basepython = python3 basepython = python3
@ -32,9 +32,9 @@ deps =
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
commands = commands =
bash -c "{toxinidir}/tools/gate/whitespace-linter.sh" bash -c "{toxinidir}/tools/gate/whitespace-linter.sh"
yapf -dr {toxinidir}/spyglass-plugin-xls {toxinidir}/setup.py yapf -dr {toxinidir}/spyglass_plugin_xls {toxinidir}/setup.py
flake8 {toxinidir}/spyglass-plugin-xls flake8 {toxinidir}/spyglass_plugin_xls
bandit -r spyglass-plugin-xls -n 5 bandit -r spyglass_plugin_xls -n 5
safety check -r requirements.txt --bare safety check -r requirements.txt --bare
whitelist_externals = whitelist_externals =
bash bash
@ -49,10 +49,10 @@ commands =
[testenv:bandit] [testenv:bandit]
deps = deps =
bandit bandit
commands = bandit -r spyglass-plugin-xls -n 5 commands = bandit -r spyglass_plugin_xls -n 5
[flake8] [flake8]
ignore = E125,E251,W503 ignore = W503
[testenv:docs] [testenv:docs]
basepython = python3 basepython = python3