forked from platformio/platformio-core
Fix an issue with unhandled warnings from PIO Core when calling it internally // Resolved #2727
This commit is contained in:
@ -19,6 +19,7 @@ import os
|
||||
import sys
|
||||
from io import BytesIO, StringIO
|
||||
|
||||
import click
|
||||
import jsonrpc # pylint: disable=import-error
|
||||
from twisted.internet import threads # pylint: disable=import-error
|
||||
|
||||
@ -102,7 +103,22 @@ class PIOCoreRPC(object):
|
||||
text = ("%s\n\n%s" % (out, err)).strip()
|
||||
if code != 0:
|
||||
raise Exception(text)
|
||||
return json.loads(out) if json_output else text
|
||||
if not json_output:
|
||||
return text
|
||||
try:
|
||||
return json.loads(out)
|
||||
except ValueError as e:
|
||||
click.secho("%s => `%s`" % (e, out), fg="red", err=True)
|
||||
# if PIO Core prints unhandled warnings
|
||||
for line in out.split("\n"):
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
try:
|
||||
return json.loads(line)
|
||||
except ValueError:
|
||||
pass
|
||||
raise e
|
||||
|
||||
@staticmethod
|
||||
def _call_errback(failure):
|
||||
|
@ -21,6 +21,7 @@ import click
|
||||
import semantic_version
|
||||
|
||||
from platformio import exception, util
|
||||
from platformio.commands import PlatformioCLI
|
||||
from platformio.compat import dump_json_to_unicode
|
||||
from platformio.managers.lib import (LibraryManager, get_builtin_libs,
|
||||
is_builtin_lib)
|
||||
@ -89,6 +90,7 @@ def cli(ctx, **options):
|
||||
get_project_global_lib_dir(),
|
||||
ctx.invoked_subcommand)
|
||||
|
||||
in_silence = PlatformioCLI.in_silence()
|
||||
ctx.meta[CTX_META_PROJECT_ENVIRONMENTS_KEY] = options['environment']
|
||||
ctx.meta[CTX_META_INPUT_DIRS_KEY] = storage_dirs
|
||||
ctx.meta[CTX_META_STORAGE_DIRS_KEY] = []
|
||||
@ -101,7 +103,7 @@ def cli(ctx, **options):
|
||||
libdeps_dir = get_project_libdeps_dir()
|
||||
config = ProjectConfig.get_instance(join(storage_dir,
|
||||
"platformio.ini"))
|
||||
config.validate(options['environment'])
|
||||
config.validate(options['environment'], silent=in_silence)
|
||||
for env in config.envs():
|
||||
if options['environment'] and env not in options['environment']:
|
||||
continue
|
||||
@ -261,6 +263,7 @@ def lib_update(ctx, libraries, only_check, dry_run, json_output):
|
||||
@click.option("--json-output", is_flag=True)
|
||||
@click.pass_context
|
||||
def lib_list(ctx, json_output):
|
||||
print("hello")
|
||||
storage_dirs = ctx.meta[CTX_META_STORAGE_DIRS_KEY]
|
||||
json_result = {}
|
||||
for storage_dir in storage_dirs:
|
||||
|
Reference in New Issue
Block a user