summaryrefslogtreecommitdiff
path: root/python/vyos/utils
diff options
context:
space:
mode:
authorerkin <me@erkin.party>2023-11-14 20:10:05 +0300
committererkin <me@erkin.party>2023-11-14 20:10:05 +0300
commit59b432b97e361f3f5670302f51881ee596afe2f8 (patch)
tree7183c7ad9ba66a96fd2e8db12cfee9cb4ee39faf /python/vyos/utils
parent799d24eba18d6710219b7380cbafb954b9eec5ce (diff)
downloadvyos-1x-59b432b97e361f3f5670302f51881ee596afe2f8.tar.gz
vyos-1x-59b432b97e361f3f5670302f51881ee596afe2f8.zip
remote: T5726: Disable the progressbar if the shell is noninteractive or the terminal is missing capabilities
Diffstat (limited to 'python/vyos/utils')
-rw-r--r--python/vyos/utils/io.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/python/vyos/utils/io.py b/python/vyos/utils/io.py
index 5fffa62f8..8790cbaac 100644
--- a/python/vyos/utils/io.py
+++ b/python/vyos/utils/io.py
@@ -62,3 +62,13 @@ def ask_yes_no(question, default=False) -> bool:
stdout.write("Please respond with yes/y or no/n\n")
except EOFError:
stdout.write("\nPlease respond with yes/y or no/n\n")
+
+def is_interactive():
+ """Try to determine if the routine was called from an interactive shell."""
+ import os, sys
+ return os.getenv('TERM', default=False) and sys.stderr.isatty() and sys.stdout.isatty()
+
+def is_dumb_terminal():
+ """Check if the current TTY is dumb, so that we can disable advanced terminal features."""
+ import os
+ return os.getenv('TERM') in ['vt100', 'dumb']