From 4e5677f5dd74201ca102b6dc898bf482837e6f8b Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Tue, 4 Dec 2018 20:59:11 +0100 Subject: [PATCH] Remove debug --- esphomeyaml/platformio_api.py | 24 +++--------------------- esphomeyaml/util.py | 24 ------------------------ 2 files changed, 3 insertions(+), 45 deletions(-) diff --git a/esphomeyaml/platformio_api.py b/esphomeyaml/platformio_api.py index f2398416f8..e58c447240 100644 --- a/esphomeyaml/platformio_api.py +++ b/esphomeyaml/platformio_api.py @@ -2,6 +2,7 @@ from __future__ import print_function import json import logging +import os import re import subprocess @@ -12,29 +13,10 @@ _LOGGER = logging.getLogger(__name__) def run_platformio_cli(*args, **kwargs): - cmd = ['platformio'] + list(args) - try: - import click - - # pylint: disable=protected-access - print("ON Windows: {}".format(click._compat.WIN)) - - def strip_ansi(x): - print("strip_ansi({})".format(x)) - return 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 = should_strip_ansi - except Exception as e: # pylint: disable=broad-except - print("Error: {}".format(e)) - import platformio.__main__ + os.environ["PLATFORMIO_FORCE_COLOR"] = "true" + cmd = ['platformio'] + list(args) return run_external_command(platformio.__main__.main, *cmd, **kwargs) diff --git a/esphomeyaml/util.py b/esphomeyaml/util.py index 14276356b7..bb9f4b3e66 100644 --- a/esphomeyaml/util.py +++ b/esphomeyaml/util.py @@ -48,19 +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): - print("isatty: True") - return True - - def run_external_command(func, *cmd, **kwargs): def mock_exit(return_code): raise SystemExit(return_code) @@ -70,10 +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.stdin = RedirectText(sys.stdin) - sys.stdout = RedirectText(sys.stdout) - sys.stderr = RedirectText(sys.stderr) - capture_stdout = kwargs.get('capture_stdout', False) if capture_stdout: sys.stdout = io.BytesIO() @@ -93,13 +76,6 @@ 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): - sys.stderr = sys.__stderr__ - if capture_stdout: # pylint: disable=lost-exception stdout = sys.stdout.getvalue()