Better formatting of envs summary

This commit is contained in:
Ivan Kravets
2016-10-03 16:47:23 +03:00
parent 0595201d81
commit 214f4501b0

View File

@ -109,28 +109,7 @@ def cli(ctx, environment, target, upload_port, project_dir, silent, verbose,
if len(results) > 1:
click.echo()
print_header("[%s]" % click.style("SUMMARY"))
successed = True
for envname, status in results.items():
status_str = click.style("SUCCESS", fg="green")
if status is False:
successed = False
status_str = click.style("ERROR", fg="red")
elif status is None:
status_str = click.style("SKIP", fg="yellow")
click.echo(
"Environment %s\t[%s]" % (click.style(
envname, fg="cyan"), status_str),
err=status is False)
print_header(
"[%s] Took %.2f seconds" % ((click.style(
"SUCCESS", fg="green",
bold=True) if successed else click.style(
"ERROR", fg="red", bold=True)), time() - start_time),
is_error=not successed)
print_summary(results, start_time)
if any([r is False for r in results.values()]):
raise exception.ReturnErrorCode()
@ -326,6 +305,38 @@ def print_header(label, is_error=False):
click.echo("%s %s %s" % (half_line, label, half_line), err=is_error)
def print_summary(results, start_time):
print_header("[%s]" % click.style("SUMMARY"))
envname_max_len = 0
for envname in results:
if len(envname) > envname_max_len:
envname_max_len = len(envname)
successed = True
for envname, status in results.items():
status_str = click.style("SUCCESS", fg="green")
if status is False:
successed = False
status_str = click.style("ERROR", fg="red")
elif status is None:
status_str = click.style("SKIP", fg="yellow")
format_str = (
"Environment {0:<" + str(envname_max_len + 9) + "}\t[{1}]")
click.echo(
format_str.format(
click.style(
envname, fg="cyan"), status_str),
err=status is False)
print_header(
"[%s] Took %.2f seconds" % ((click.style(
"SUCCESS", fg="green", bold=True) if successed else click.style(
"ERROR", fg="red", bold=True)), time() - start_time),
is_error=not successed)
def check_project_defopts(config):
if not config.has_section("platformio"):
return True