forked from platformio/platformio-core
Move "in_silence" to PlatformioCLI
This commit is contained in:
2
docs
2
docs
Submodule docs updated: b96d5511cb...103ed8445c
@ -22,6 +22,14 @@ class PlatformioCLI(click.MultiCommand):
|
||||
|
||||
leftover_args = []
|
||||
|
||||
@staticmethod
|
||||
def in_silence():
|
||||
args = PlatformioCLI.leftover_args
|
||||
return args and any([
|
||||
args[0] == "debug" and "--interpreter" in " ".join(args),
|
||||
args[0] == "upgrade", "--json-output" in args, "--version" in args
|
||||
])
|
||||
|
||||
def invoke(self, ctx):
|
||||
PlatformioCLI.leftover_args = ctx.args
|
||||
if hasattr(ctx, "protected_args"):
|
||||
|
@ -80,7 +80,7 @@ def cli(ctx, **options):
|
||||
ctx.invoked_subcommand)
|
||||
|
||||
ctx.obj = LibraryManager(storage_dir)
|
||||
if "--json-output" not in PlatformioCLI.leftover_args:
|
||||
if not PlatformioCLI.in_silence():
|
||||
click.echo("Library Storage: " + storage_dir)
|
||||
|
||||
|
||||
|
@ -42,12 +42,12 @@ def on_platformio_start(ctx, force, caller):
|
||||
set_caller(caller)
|
||||
telemetry.on_command()
|
||||
|
||||
if not in_silence():
|
||||
if not PlatformioCLI.in_silence():
|
||||
after_upgrade(ctx)
|
||||
|
||||
|
||||
def on_platformio_end(ctx, result): # pylint: disable=unused-argument
|
||||
if in_silence():
|
||||
if PlatformioCLI.in_silence():
|
||||
return
|
||||
|
||||
try:
|
||||
@ -66,14 +66,6 @@ def on_platformio_exception(e):
|
||||
telemetry.on_exception(e)
|
||||
|
||||
|
||||
def in_silence():
|
||||
args = PlatformioCLI.leftover_args
|
||||
return args and any([
|
||||
args[0] == "debug" and "--interpreter" in " ".join(args),
|
||||
args[0] == "upgrade", "--json-output" in args, "--version" in args
|
||||
])
|
||||
|
||||
|
||||
def set_caller(caller=None):
|
||||
if not caller:
|
||||
if getenv("PLATFORMIO_CALLER"):
|
||||
|
@ -33,6 +33,7 @@ import click
|
||||
import requests
|
||||
|
||||
from platformio import __apiurl__, __version__, exception
|
||||
from platformio.commands import PlatformioCLI
|
||||
from platformio.compat import PY2, WINDOWS, get_file_contents, path_to_unicode
|
||||
from platformio.proc import LineBufferedAsyncPipe as AsyncPipe
|
||||
from platformio.proc import exec_command, is_ci, where_is_program
|
||||
@ -425,9 +426,8 @@ def get_api_result(url, params=None, data=None, auth=None, cache_valid=None):
|
||||
return json.loads(result)
|
||||
except (requests.exceptions.ConnectionError,
|
||||
requests.exceptions.Timeout) as e:
|
||||
from platformio.maintenance import in_silence
|
||||
total += 1
|
||||
if not in_silence():
|
||||
if not PlatformioCLI.in_silence():
|
||||
click.secho(
|
||||
"[API] ConnectionError: {0} (incremented retry: max={1}, "
|
||||
"total={2})".format(e, max_retries, total),
|
||||
|
Reference in New Issue
Block a user