mirror of
https://github.com/esphome/esphome.git
synced 2025-03-15 15:18:16 +00:00
Remove debug
This commit is contained in:
parent
4f2f7a5d68
commit
4e5677f5dd
@ -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)
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user