Better catching of IOError for VSCode/Colorama

This commit is contained in:
Ivan Kravets
2017-09-02 16:23:24 +03:00
parent 68c75735f4
commit b55b80ecc8
2 changed files with 13 additions and 5 deletions

View File

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

View File

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