summaryrefslogtreecommitdiff
path: root/python/vyos/utils
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-11-15 13:57:46 +0100
committerGitHub <noreply@github.com>2023-11-15 13:57:46 +0100
commit525d3364aa1aa35861bdb459c60d7a4cd7cd21f9 (patch)
treec6e85cf7815b3e83ae5901dfe11179c0197aac7f /python/vyos/utils
parent5ea97243eb50c48520b8210e47c161637691a365 (diff)
parent910cffb196ab82c16fae52709d9717319f131e51 (diff)
downloadvyos-1x-525d3364aa1aa35861bdb459c60d7a4cd7cd21f9.tar.gz
vyos-1x-525d3364aa1aa35861bdb459c60d7a4cd7cd21f9.zip
Merge pull request #2485 from vyos/mergify/bp/sagitta/pr-2483
remote: T5726: Disable the progressbar if the shell is noninteractive or the terminal is missing capabilities (backport #2483)
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']