forked from platformio/platformio-core
Handle PlatformIO's "on_exit" event
This commit is contained in:
@ -53,7 +53,13 @@ def cli(ctx, force, caller, no_ansi): # pylint: disable=unused-argument
|
|||||||
except: # pylint: disable=bare-except
|
except: # pylint: disable=bare-except
|
||||||
pass
|
pass
|
||||||
|
|
||||||
maintenance.on_platformio_start(ctx, caller)
|
maintenance.on_cmd_start(ctx, caller)
|
||||||
|
|
||||||
|
|
||||||
|
@cli.result_callback()
|
||||||
|
@click.pass_context
|
||||||
|
def process_result(*_, **__):
|
||||||
|
maintenance.on_cmd_end()
|
||||||
|
|
||||||
|
|
||||||
def configure():
|
def configure():
|
||||||
@ -125,7 +131,7 @@ 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()
|
maintenance.on_platformio_exit()
|
||||||
sys.argv = prev_sys_argv
|
sys.argv = prev_sys_argv
|
||||||
return exit_code
|
return exit_code
|
||||||
|
|
||||||
|
@ -29,17 +29,16 @@ from platformio.package.version import pepver_to_semver
|
|||||||
from platformio.system.prune import calculate_unnecessary_system_data
|
from platformio.system.prune import calculate_unnecessary_system_data
|
||||||
|
|
||||||
|
|
||||||
def on_platformio_start(ctx, caller):
|
def on_cmd_start(ctx, caller):
|
||||||
app.set_session_var("command_ctx", ctx)
|
app.set_session_var("command_ctx", ctx)
|
||||||
set_caller(caller)
|
set_caller(caller)
|
||||||
telemetry.on_platformio_start(ctx)
|
telemetry.on_cmd_start(ctx)
|
||||||
if PlatformioCLI.in_silence():
|
if PlatformioCLI.in_silence():
|
||||||
return
|
return
|
||||||
after_upgrade(ctx)
|
after_upgrade(ctx)
|
||||||
|
|
||||||
|
|
||||||
def on_platformio_end():
|
def on_cmd_end():
|
||||||
telemetry.on_platformio_end()
|
|
||||||
if PlatformioCLI.in_silence():
|
if PlatformioCLI.in_silence():
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -62,6 +61,10 @@ def on_platformio_exception(exc):
|
|||||||
telemetry.log_exception(exc)
|
telemetry.log_exception(exc)
|
||||||
|
|
||||||
|
|
||||||
|
def on_platformio_exit():
|
||||||
|
telemetry.on_exit()
|
||||||
|
|
||||||
|
|
||||||
def set_caller(caller=None):
|
def set_caller(caller=None):
|
||||||
caller = caller or os.getenv("PLATFORMIO_CALLER")
|
caller = caller or os.getenv("PLATFORMIO_CALLER")
|
||||||
if not caller:
|
if not caller:
|
||||||
|
@ -170,12 +170,12 @@ def log_event(name, params, instant_sending=False):
|
|||||||
TelemetryLogger().log_event(name, params, instant_sending=instant_sending)
|
TelemetryLogger().log_event(name, params, instant_sending=instant_sending)
|
||||||
|
|
||||||
|
|
||||||
def on_platformio_start(cmd_ctx):
|
def on_cmd_start(cmd_ctx):
|
||||||
process_postponed_logs()
|
process_postponed_logs()
|
||||||
log_command(cmd_ctx)
|
log_command(cmd_ctx)
|
||||||
|
|
||||||
|
|
||||||
def on_platformio_end():
|
def on_exit():
|
||||||
TelemetryLogger().send()
|
TelemetryLogger().send()
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user