From 7ac5746e0d549f079c1e121d5fa95b681de48dc3 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Wed, 28 May 2025 23:00:27 -0400 Subject: [PATCH] Fix colors in update all (#8854) --- esphome/__main__.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/esphome/__main__.py b/esphome/__main__.py index 9f638456e6..adada75163 100644 --- a/esphome/__main__.py +++ b/esphome/__main__.py @@ -593,15 +593,20 @@ def command_update_all(args): middle_text = f" {middle_text} " width = len(click.unstyle(middle_text)) half_line = "=" * ((twidth - width) // 2) - click.echo(f"{half_line}{middle_text}{half_line}") + safe_print(f"{half_line}{middle_text}{half_line}") for f in files: - print(f"Updating {color(AnsiFore.CYAN, f)}") - print("-" * twidth) - print() - rc = run_external_process( - "esphome", "--dashboard", "run", f, "--no-logs", "--device", "OTA" - ) + safe_print(f"Updating {color(AnsiFore.CYAN, f)}") + safe_print("-" * twidth) + safe_print() + if CORE.dashboard: + rc = run_external_process( + "esphome", "--dashboard", "run", f, "--no-logs", "--device", "OTA" + ) + else: + rc = run_external_process( + "esphome", "run", f, "--no-logs", "--device", "OTA" + ) if rc == 0: print_bar(f"[{color(AnsiFore.BOLD_GREEN, 'SUCCESS')}] {f}") success[f] = True @@ -609,17 +614,17 @@ def command_update_all(args): print_bar(f"[{color(AnsiFore.BOLD_RED, 'ERROR')}] {f}") success[f] = False - print() - print() - print() + safe_print() + safe_print() + safe_print() print_bar(f"[{color(AnsiFore.BOLD_WHITE, 'SUMMARY')}]") failed = 0 for f in files: if success[f]: - print(f" - {f}: {color(AnsiFore.GREEN, 'SUCCESS')}") + safe_print(f" - {f}: {color(AnsiFore.GREEN, 'SUCCESS')}") else: - print(f" - {f}: {color(AnsiFore.BOLD_RED, 'FAILED')}") + safe_print(f" - {f}: {color(AnsiFore.BOLD_RED, 'FAILED')}") failed += 1 return failed