From: Ralf Jung Date: Tue, 28 Jul 2015 19:39:19 +0000 (+0200) Subject: Detect absence of a TTY, and refuse to use the CLI backend interactively in that... X-Git-Url: https://git.ralfj.de/lilass.git/commitdiff_plain/19a90b1cacb47a7bbb42e4ac7c7746885f92ac38?ds=inline Detect absence of a TTY, and refuse to use the CLI backend interactively in that case Fixes #2 --- diff --git a/cli_frontend.py b/cli_frontend.py index 5e9d400..15d081c 100644 --- a/cli_frontend.py +++ b/cli_frontend.py @@ -26,6 +26,8 @@ class CLIFrontend(QuestionFrontend): print(message, file=sys.stderr) def userChoose (self, title, choices, returns, fallback): + if not sys.stdin.isatty(): + raise Exception("Choosing the setup interactively is not possible, due to lack of a TTY") while True: # print question print(title) diff --git a/lilass b/lilass index 33b05fd..49dbeea 100755 --- a/lilass +++ b/lilass @@ -147,4 +147,3 @@ if __name__ == "__main__": turnOnBacklight() except Exception as e: frontend.error(str(e)) - raise