mirror of
https://github.com/esphome/esphome.git
synced 2026-09-03 19:46:02 +00:00
Address review: pass line_callbacks to run_external_process, fix filter_lines type
- Pass line_callbacks through to run_external_process so the crystal frequency warning works when ESPHOME_USE_SUBPROCESS is set - Fix filter_lines type annotation from str to list[str] to match actual usage
This commit is contained in:
+1
-1
@@ -733,7 +733,7 @@ def upload_using_esptool(
|
||||
esptool.main, *cmd, line_callbacks=line_callbacks
|
||||
) # pylint: disable=no-member
|
||||
|
||||
return run_external_process(*cmd)
|
||||
return run_external_process(*cmd, line_callbacks=line_callbacks)
|
||||
|
||||
rc = run_esptool(first_baudrate)
|
||||
if rc == 0 or first_baudrate == 115200:
|
||||
|
||||
+8
-3
@@ -127,7 +127,7 @@ class RedirectText:
|
||||
def __init__(
|
||||
self,
|
||||
out,
|
||||
filter_lines: str | None = None,
|
||||
filter_lines: list[str] | None = None,
|
||||
line_callbacks: list[Callable[[str], str | None]] | None = None,
|
||||
) -> None:
|
||||
self._out = out
|
||||
@@ -273,14 +273,19 @@ def run_external_process(*cmd: str, **kwargs: Any) -> int | str:
|
||||
full_cmd = " ".join(shlex_quote(x) for x in cmd)
|
||||
_LOGGER.debug("Running: %s", full_cmd)
|
||||
filter_lines = kwargs.get("filter_lines")
|
||||
line_callbacks = kwargs.get("line_callbacks")
|
||||
|
||||
capture_stdout = kwargs.get("capture_stdout", False)
|
||||
if capture_stdout:
|
||||
sub_stdout = subprocess.PIPE
|
||||
else:
|
||||
sub_stdout = RedirectText(sys.stdout, filter_lines=filter_lines)
|
||||
sub_stdout = RedirectText(
|
||||
sys.stdout, filter_lines=filter_lines, line_callbacks=line_callbacks
|
||||
)
|
||||
|
||||
sub_stderr = RedirectText(sys.stderr, filter_lines=filter_lines)
|
||||
sub_stderr = RedirectText(
|
||||
sys.stderr, filter_lines=filter_lines, line_callbacks=line_callbacks
|
||||
)
|
||||
|
||||
try:
|
||||
proc = subprocess.run(
|
||||
|
||||
Reference in New Issue
Block a user