fix: Fix redirection of STDOUT

Closes https://github.com/espressif/esptool/issues/904
This commit is contained in:
radim.karnis
2023-08-08 13:44:46 +02:00
parent 82739162c5
commit 9585c0e702

View File

@@ -68,7 +68,7 @@ def print_overwrite(message, last_line=False):
If output is not a TTY (for example redirected a pipe),
no overwriting happens and this function is the same as print().
"""
if sys.stdout.isatty():
if hasattr(sys.stdout, "isatty") and sys.stdout.isatty():
print("\r%s" % message, end="\n" if last_line else "")
else:
print(message)