From fd633865937e596a647c1ad39a30d88b10a766c3 Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Sun, 4 Jun 2017 13:58:26 +0200 Subject: [PATCH] check for tty when running mitmproxy --- mitmproxy/tools/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mitmproxy/tools/main.py b/mitmproxy/tools/main.py index 84dab1fe4..6ac8a261c 100644 --- a/mitmproxy/tools/main.py +++ b/mitmproxy/tools/main.py @@ -30,7 +30,7 @@ def assert_utf8_env(): file=sys.stderr ) print( - "Set your LANG enviroment variable to something like en_US.UTF-8", + "Set your LANG environment variable to something like en_US.UTF-8", file=sys.stderr ) sys.exit(1) @@ -111,6 +111,12 @@ def mitmproxy(args=None): # pragma: no cover print("Error: mitmproxy's console interface is not supported on Windows. " "You can run mitmdump or mitmweb instead.", file=sys.stderr) sys.exit(1) + + if not sys.stdout.isatty(): + print("Error: mitmproxy's console interface requires a tty. " + "Please run mitmproxy in an interactive shell environment.", file=sys.stderr) + sys.exit(1) + assert_utf8_env() from mitmproxy.tools import console