mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Better catching of IOError for VSCode/Colorama
This commit is contained in:
@ -101,6 +101,18 @@ def main():
|
||||
except: # pylint: disable=bare-except
|
||||
pass
|
||||
|
||||
# Handle IOError issue with colorama/VSCode
|
||||
click_echo_origin = click.echo
|
||||
|
||||
def _echo(*args, **kwargs):
|
||||
try:
|
||||
click_echo_origin(*args, **kwargs)
|
||||
except IOError:
|
||||
(sys.stderr.write if kwargs.get("err") else
|
||||
sys.stdout.write)("%s\n" % (args[0] if args else ""))
|
||||
|
||||
click.echo = _echo
|
||||
|
||||
cli(None, None, None)
|
||||
except Exception as e: # pylint: disable=W0703
|
||||
if not isinstance(e, exception.ReturnErrorCode):
|
||||
|
@ -15,7 +15,6 @@
|
||||
import base64
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from imp import load_source
|
||||
from multiprocessing import cpu_count
|
||||
from os.path import basename, dirname, isdir, isfile, join
|
||||
@ -395,10 +394,7 @@ class PlatformRunMixin(object):
|
||||
fg = (None, "yellow", "red")[level - 1]
|
||||
if level == 1 and "is up to date" in line:
|
||||
fg = "green"
|
||||
try:
|
||||
click.secho(line, fg=fg, err=level > 1)
|
||||
except IOError:
|
||||
(sys.stderr.write if level > 1 else sys.stdout.write)(line + "\n")
|
||||
click.secho(line, fg=fg, err=level > 1)
|
||||
|
||||
@staticmethod
|
||||
def get_job_nums():
|
||||
|
Reference in New Issue
Block a user