From f55c3b890b0bd598084233e44875c3f3076931fb Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Fri, 4 Oct 2024 13:26:17 +1300 Subject: [PATCH] Tools: improve uploader output in scripts When the px_uploader.py is used scripted, so without an interactive shell, the progress bar doesn't update. Therefore, I suggest to print a new line instead of a carriage return for the non-interactive shell case. --- Tools/px_uploader.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tools/px_uploader.py b/Tools/px_uploader.py index 0ab3a6ff25..4aee08f388 100755 --- a/Tools/px_uploader.py +++ b/Tools/px_uploader.py @@ -428,7 +428,8 @@ class uploader: percent = (float(progress) / float(maxVal)) * 100.0 - sys.stdout.write("\r%s: [%-20s] %.1f%%" % (label, '='*int(percent/5.0), percent)) + redraw = "\r" if sys.stdout.isatty() else "\n" + sys.stdout.write("%s%s: [%-20s] %.1f%%" % (redraw, label, '='*int(percent/5.0), percent)) sys.stdout.flush() # send the CHIP_ERASE command and wait for the bootloader to become ready