From 4f2f7a5d68e1b791cb3d9f8d1e360a2a414dd11b Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Tue, 4 Dec 2018 20:47:04 +0100 Subject: [PATCH] Debug --- esphomeyaml/platformio_api.py | 5 +++-- esphomeyaml/util.py | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/esphomeyaml/platformio_api.py b/esphomeyaml/platformio_api.py index a388bf64c9..f2398416f8 100644 --- a/esphomeyaml/platformio_api.py +++ b/esphomeyaml/platformio_api.py @@ -21,14 +21,15 @@ def run_platformio_cli(*args, **kwargs): def strip_ansi(x): print("strip_ansi({})".format(x)) + return x - click._compat.strip_ansi = lambda x: x + click._compat.strip_ansi = strip_ansi def should_strip_ansi(stream=None, color=None): print("should_strip_ansi({}, {})".format(stream, color)) return False - click._compat.should_strip_ansi = lambda x: False + click._compat.should_strip_ansi = should_strip_ansi except Exception as e: # pylint: disable=broad-except print("Error: {}".format(e)) diff --git a/esphomeyaml/util.py b/esphomeyaml/util.py index 4013d37053..14276356b7 100644 --- a/esphomeyaml/util.py +++ b/esphomeyaml/util.py @@ -57,6 +57,7 @@ class RedirectText(object): # pylint: disable=no-self-use def isatty(self): + print("isatty: True") return True @@ -69,6 +70,7 @@ def run_external_command(func, *cmd, **kwargs): full_cmd = u' '.join(shlex_quote(x) for x in cmd) _LOGGER.info(u"Running: %s", full_cmd) + sys.stdin = RedirectText(sys.stdin) sys.stdout = RedirectText(sys.stdout) sys.stderr = RedirectText(sys.stderr) @@ -91,6 +93,8 @@ def run_external_command(func, *cmd, **kwargs): sys.argv = orig_argv sys.exit = orig_exit + if isinstance(sys.stdin, RedirectText): + sys.stdin = sys.__stdin__ if isinstance(sys.stdout, RedirectText): sys.stdout = sys.__stdout__ if isinstance(sys.stderr, RedirectText):