check tty after options parsing

This commit is contained in:
Thomas Kriechbaumer 2017-06-04 14:34:28 +02:00
parent fd63386593
commit 0c91503b97
2 changed files with 6 additions and 5 deletions

View File

@ -481,6 +481,12 @@ class ConsoleMaster(master.Master):
def __init__(self, options, server): def __init__(self, options, server):
super().__init__(options, server) super().__init__(options, server)
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)
self.view = view.View() # type: view.View self.view = view.View() # type: view.View
self.stream_path = None self.stream_path = None
# This line is just for type hinting # This line is just for type hinting

View File

@ -112,11 +112,6 @@ def mitmproxy(args=None): # pragma: no cover
"You can run mitmdump or mitmweb instead.", file=sys.stderr) "You can run mitmdump or mitmweb instead.", file=sys.stderr)
sys.exit(1) 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() assert_utf8_env()
from mitmproxy.tools import console from mitmproxy.tools import console