mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07: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
|
except: # pylint: disable=bare-except
|
||||||
pass
|
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)
|
cli(None, None, None)
|
||||||
except Exception as e: # pylint: disable=W0703
|
except Exception as e: # pylint: disable=W0703
|
||||||
if not isinstance(e, exception.ReturnErrorCode):
|
if not isinstance(e, exception.ReturnErrorCode):
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
from imp import load_source
|
from imp import load_source
|
||||||
from multiprocessing import cpu_count
|
from multiprocessing import cpu_count
|
||||||
from os.path import basename, dirname, isdir, isfile, join
|
from os.path import basename, dirname, isdir, isfile, join
|
||||||
@ -395,10 +394,7 @@ class PlatformRunMixin(object):
|
|||||||
fg = (None, "yellow", "red")[level - 1]
|
fg = (None, "yellow", "red")[level - 1]
|
||||||
if level == 1 and "is up to date" in line:
|
if level == 1 and "is up to date" in line:
|
||||||
fg = "green"
|
fg = "green"
|
||||||
try:
|
click.secho(line, fg=fg, err=level > 1)
|
||||||
click.secho(line, fg=fg, err=level > 1)
|
|
||||||
except IOError:
|
|
||||||
(sys.stderr.write if level > 1 else sys.stdout.write)(line + "\n")
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_job_nums():
|
def get_job_nums():
|
||||||
|
Reference in New Issue
Block a user