Use enviornment variable

This commit is contained in:
Otto Winter 2018-11-30 19:04:08 +01:00
parent 7354551954
commit 7f038eb5d2
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
2 changed files with 2 additions and 20 deletions

View File

@ -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)

View File

@ -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()