Commit 7a2384cf by Ben Patterson

Make pep8 failure output easier to understand.

parent ecbfe5c9
...@@ -143,7 +143,6 @@ def _count_pylint_violations(report_file): ...@@ -143,7 +143,6 @@ def _count_pylint_violations(report_file):
@needs('pavelib.prereqs.install_python_prereqs') @needs('pavelib.prereqs.install_python_prereqs')
@cmdopts([ @cmdopts([
("system=", "s", "System to act on"), ("system=", "s", "System to act on"),
("limit=", "l", "limit for number of acceptable violations"),
]) ])
def run_pep8(options): def run_pep8(options):
""" """
...@@ -152,7 +151,6 @@ def run_pep8(options): ...@@ -152,7 +151,6 @@ def run_pep8(options):
""" """
num_violations = 0 num_violations = 0
systems = getattr(options, 'system', ALL_SYSTEMS).split(',') systems = getattr(options, 'system', ALL_SYSTEMS).split(',')
violations_limit = int(getattr(options, 'limit', -1))
for system in systems: for system in systems:
# Directory to put the pep8 report in. # Directory to put the pep8 report in.
...@@ -160,14 +158,19 @@ def run_pep8(options): ...@@ -160,14 +158,19 @@ def run_pep8(options):
report_dir = (Env.REPORT_DIR / system).makedirs_p() report_dir = (Env.REPORT_DIR / system).makedirs_p()
sh('pep8 {system} | tee {report_dir}/pep8.report'.format(system=system, report_dir=report_dir)) sh('pep8 {system} | tee {report_dir}/pep8.report'.format(system=system, report_dir=report_dir))
num_violations = num_violations + _count_pep8_violations( num_violations = num_violations + _
count = _count_pep8_violations(
"{report_dir}/pep8.report".format(report_dir=report_dir)) "{report_dir}/pep8.report".format(report_dir=report_dir))
print("Number of pep8 violations: " + str(num_violations)) print("Number of pep8 violations: {count}".format(count=count))
# Fail the task if the violations limit has been reached if count:
if num_violations > violations_limit > -1: raise Exception(
raise Exception("Failed. Too many pep8 violations. " "Too many pep8 violations. Number of violations found: {count}.".format(
"The limit is {violations_limit}.".format(violations_limit=violations_limit)) count=count
)
)
def _count_pep8_violations(report_file): def _count_pep8_violations(report_file):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment