|
@@ -212,7 +212,6 @@ def stream_logs(
|
|
progress=None,
|
|
progress=None,
|
|
suppress_errors: bool = False,
|
|
suppress_errors: bool = False,
|
|
analytics_enabled: bool = False,
|
|
analytics_enabled: bool = False,
|
|
- error_filter_fn: Callable[[str], bool] | None = None,
|
|
|
|
):
|
|
):
|
|
"""Stream the logs for a process.
|
|
"""Stream the logs for a process.
|
|
|
|
|
|
@@ -222,7 +221,6 @@ def stream_logs(
|
|
progress: The ongoing progress bar if one is being used.
|
|
progress: The ongoing progress bar if one is being used.
|
|
suppress_errors: If True, do not exit if errors are encountered (for fallback).
|
|
suppress_errors: If True, do not exit if errors are encountered (for fallback).
|
|
analytics_enabled: Whether analytics are enabled for this command.
|
|
analytics_enabled: Whether analytics are enabled for this command.
|
|
- error_filter_fn: A function that takes a line of output and returns True if the line should be considered an error, False otherwise. If None, all lines are considered errors.
|
|
|
|
|
|
|
|
Yields:
|
|
Yields:
|
|
The lines of the process output.
|
|
The lines of the process output.
|
|
@@ -253,15 +251,7 @@ def stream_logs(
|
|
for line in logs:
|
|
for line in logs:
|
|
console.error(line, end="")
|
|
console.error(line, end="")
|
|
if analytics_enabled:
|
|
if analytics_enabled:
|
|
- error_lines = [
|
|
|
|
- line.strip()
|
|
|
|
- for line in logs
|
|
|
|
- if error_filter_fn is None or error_filter_fn(line)
|
|
|
|
- ]
|
|
|
|
- max_error_lines = 20
|
|
|
|
- telemetry.send(
|
|
|
|
- "error", context=message, detail=error_lines[:max_error_lines]
|
|
|
|
- )
|
|
|
|
|
|
+ telemetry.send("error", context=message)
|
|
console.error("Run with [bold]--loglevel debug [/bold] for the full log.")
|
|
console.error("Run with [bold]--loglevel debug [/bold] for the full log.")
|
|
raise typer.Exit(1)
|
|
raise typer.Exit(1)
|
|
|
|
|
|
@@ -282,7 +272,6 @@ def show_status(
|
|
process: subprocess.Popen,
|
|
process: subprocess.Popen,
|
|
suppress_errors: bool = False,
|
|
suppress_errors: bool = False,
|
|
analytics_enabled: bool = False,
|
|
analytics_enabled: bool = False,
|
|
- error_filter_fn: Callable[[str], bool] | None = None,
|
|
|
|
):
|
|
):
|
|
"""Show the status of a process.
|
|
"""Show the status of a process.
|
|
|
|
|
|
@@ -291,7 +280,6 @@ def show_status(
|
|
process: The process.
|
|
process: The process.
|
|
suppress_errors: If True, do not exit if errors are encountered (for fallback).
|
|
suppress_errors: If True, do not exit if errors are encountered (for fallback).
|
|
analytics_enabled: Whether analytics are enabled for this command.
|
|
analytics_enabled: Whether analytics are enabled for this command.
|
|
- error_filter_fn: A function that takes a line of output and returns True if the line should be considered an error, False otherwise. If None, all lines are considered errors.
|
|
|
|
"""
|
|
"""
|
|
with console.status(message) as status:
|
|
with console.status(message) as status:
|
|
for line in stream_logs(
|
|
for line in stream_logs(
|
|
@@ -299,7 +287,6 @@ def show_status(
|
|
process,
|
|
process,
|
|
suppress_errors=suppress_errors,
|
|
suppress_errors=suppress_errors,
|
|
analytics_enabled=analytics_enabled,
|
|
analytics_enabled=analytics_enabled,
|
|
- error_filter_fn=error_filter_fn,
|
|
|
|
):
|
|
):
|
|
status.update(f"{message} {line}")
|
|
status.update(f"{message} {line}")
|
|
|
|
|
|
@@ -355,7 +342,6 @@ def run_process_with_fallback(
|
|
show_status_message,
|
|
show_status_message,
|
|
fallback=None,
|
|
fallback=None,
|
|
analytics_enabled: bool = False,
|
|
analytics_enabled: bool = False,
|
|
- error_filter_fn: Callable[[str], bool] | None = None,
|
|
|
|
**kwargs,
|
|
**kwargs,
|
|
):
|
|
):
|
|
"""Run subprocess and retry using fallback command if initial command fails.
|
|
"""Run subprocess and retry using fallback command if initial command fails.
|
|
@@ -365,7 +351,6 @@ def run_process_with_fallback(
|
|
show_status_message: The status message to be displayed in the console.
|
|
show_status_message: The status message to be displayed in the console.
|
|
fallback: The fallback command to run.
|
|
fallback: The fallback command to run.
|
|
analytics_enabled: Whether analytics are enabled for this command.
|
|
analytics_enabled: Whether analytics are enabled for this command.
|
|
- error_filter_fn: A function that takes a line of output and returns True if the line should be considered an error, False otherwise. If None, all lines are considered errors.
|
|
|
|
kwargs: Kwargs to pass to new_process function.
|
|
kwargs: Kwargs to pass to new_process function.
|
|
"""
|
|
"""
|
|
process = new_process(get_command_with_loglevel(args), **kwargs)
|
|
process = new_process(get_command_with_loglevel(args), **kwargs)
|
|
@@ -375,7 +360,6 @@ def run_process_with_fallback(
|
|
show_status_message,
|
|
show_status_message,
|
|
process,
|
|
process,
|
|
analytics_enabled=analytics_enabled,
|
|
analytics_enabled=analytics_enabled,
|
|
- error_filter_fn=error_filter_fn,
|
|
|
|
)
|
|
)
|
|
else:
|
|
else:
|
|
# Suppress errors for initial command, because we will try to fallback
|
|
# Suppress errors for initial command, because we will try to fallback
|
|
@@ -391,7 +375,6 @@ def run_process_with_fallback(
|
|
show_status_message=show_status_message,
|
|
show_status_message=show_status_message,
|
|
fallback=None,
|
|
fallback=None,
|
|
analytics_enabled=analytics_enabled,
|
|
analytics_enabled=analytics_enabled,
|
|
- error_filter_fn=error_filter_fn,
|
|
|
|
**kwargs,
|
|
**kwargs,
|
|
)
|
|
)
|
|
|
|
|