Detect absence of a TTY, and refuse to use the CLI backend interactively in that...
authorRalf Jung <post@ralfj.de>
Tue, 28 Jul 2015 19:39:19 +0000 (21:39 +0200)
committerRalf Jung <post@ralfj.de>
Tue, 28 Jul 2015 19:39:19 +0000 (21:39 +0200)
Fixes #2

cli_frontend.py
lilass

index 5e9d400537ff3b6d6eecff624cd0662f0ead2406..15d081c06fb427dc0d3a9bcc7051713f13e41ac2 100644 (file)
@@ -26,6 +26,8 @@ class CLIFrontend(QuestionFrontend):
         print(message, file=sys.stderr)
 
     def userChoose (self, title, choices, returns, fallback):
         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)
         while True:
             # print question
             print(title)
diff --git a/lilass b/lilass
index 33b05fdb8be8105b7aaf5b036f92250af3d25a07..49dbeea61d24fa251af53a6702de379c495e43a6 100755 (executable)
--- a/lilass
+++ b/lilass
@@ -147,4 +147,3 @@ if __name__ == "__main__":
             turnOnBacklight()
     except Exception as e:
         frontend.error(str(e))
             turnOnBacklight()
     except Exception as e:
         frontend.error(str(e))
-        raise