mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 02:27:13 +02:00
Call "on_platformio_end" when Click finished
This commit is contained in:
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from traceback import format_exc
|
import traceback
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
@ -56,12 +56,6 @@ def cli(ctx, force, caller, no_ansi): # pylint: disable=unused-argument
|
|||||||
maintenance.on_platformio_start(ctx, caller)
|
maintenance.on_platformio_start(ctx, caller)
|
||||||
|
|
||||||
|
|
||||||
@cli.result_callback()
|
|
||||||
@click.pass_context
|
|
||||||
def process_result(ctx, result, *_, **__):
|
|
||||||
maintenance.on_platformio_end(ctx, result)
|
|
||||||
|
|
||||||
|
|
||||||
def configure():
|
def configure():
|
||||||
if IS_CYGWIN:
|
if IS_CYGWIN:
|
||||||
raise exception.CygwinEnvDetected()
|
raise exception.CygwinEnvDetected()
|
||||||
@ -96,6 +90,7 @@ def main(argv=None):
|
|||||||
if argv:
|
if argv:
|
||||||
assert isinstance(argv, list)
|
assert isinstance(argv, list)
|
||||||
sys.argv = argv
|
sys.argv = argv
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ensure_python3(raise_exception=True)
|
ensure_python3(raise_exception=True)
|
||||||
configure()
|
configure()
|
||||||
@ -110,7 +105,7 @@ def main(argv=None):
|
|||||||
if isinstance(exc, exception.PlatformioException):
|
if isinstance(exc, exception.PlatformioException):
|
||||||
error_str += str(exc)
|
error_str += str(exc)
|
||||||
else:
|
else:
|
||||||
error_str += format_exc()
|
error_str += traceback.format_exc()
|
||||||
error_str += """
|
error_str += """
|
||||||
============================================================
|
============================================================
|
||||||
|
|
||||||
@ -129,6 +124,8 @@ An unexpected error occurred. Further steps:
|
|||||||
"""
|
"""
|
||||||
click.secho(error_str, fg="red", err=True)
|
click.secho(error_str, fg="red", err=True)
|
||||||
exit_code = int(str(exc)) if str(exc).isdigit() else 1
|
exit_code = int(str(exc)) if str(exc).isdigit() else 1
|
||||||
|
|
||||||
|
maintenance.on_platformio_end()
|
||||||
sys.argv = prev_sys_argv
|
sys.argv = prev_sys_argv
|
||||||
return exit_code
|
return exit_code
|
||||||
|
|
||||||
|
@ -38,7 +38,8 @@ def on_platformio_start(ctx, caller):
|
|||||||
after_upgrade(ctx)
|
after_upgrade(ctx)
|
||||||
|
|
||||||
|
|
||||||
def on_platformio_end(ctx, result): # pylint: disable=unused-argument
|
def on_platformio_end():
|
||||||
|
telemetry.on_platformio_end()
|
||||||
if PlatformioCLI.in_silence():
|
if PlatformioCLI.in_silence():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user