From 7f038eb5d26df72f76ea9ae76774e2cec1fd7f59 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Fri, 30 Nov 2018 19:04:08 +0100 Subject: [PATCH] Use enviornment variable --- esphomeyaml/platformio_api.py | 2 ++ esphomeyaml/util.py | 20 -------------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/esphomeyaml/platformio_api.py b/esphomeyaml/platformio_api.py index fb25f0ebfe..7cc57df869 100644 --- a/esphomeyaml/platformio_api.py +++ b/esphomeyaml/platformio_api.py @@ -1,5 +1,6 @@ import json import logging +import os import re import subprocess @@ -13,6 +14,7 @@ def run_platformio_cli(*args, **kwargs): import platformio.__main__ cmd = ['platformio'] + list(args) + os.environ["PLATFORMIO_FORCE_COLOR"] = 'true' return run_external_command(platformio.__main__.main, *cmd, **kwargs) diff --git a/esphomeyaml/util.py b/esphomeyaml/util.py index 4013d37053..bb9f4b3e66 100644 --- a/esphomeyaml/util.py +++ b/esphomeyaml/util.py @@ -48,18 +48,6 @@ def shlex_quote(s): return u"'" + s.replace(u"'", u"'\"'\"'") + u"'" -class RedirectText(object): - def __init__(self, out): - self._out = out - - def __getattr__(self, item): - return getattr(self._out, item) - - # pylint: disable=no-self-use - def isatty(self): - return True - - def run_external_command(func, *cmd, **kwargs): def mock_exit(return_code): raise SystemExit(return_code) @@ -69,9 +57,6 @@ 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.stdout = RedirectText(sys.stdout) - sys.stderr = RedirectText(sys.stderr) - capture_stdout = kwargs.get('capture_stdout', False) if capture_stdout: sys.stdout = io.BytesIO() @@ -91,11 +76,6 @@ def run_external_command(func, *cmd, **kwargs): sys.argv = orig_argv sys.exit = orig_exit - if isinstance(sys.stdout, RedirectText): - sys.stdout = sys.__stdout__ - if isinstance(sys.stderr, RedirectText): - sys.stderr = sys.__stderr__ - if capture_stdout: # pylint: disable=lost-exception stdout = sys.stdout.getvalue()