1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-09 14:52:20 +01:00

Merge branch 'subproc' into integration

This commit is contained in:
J. Nick Koston
2025-08-08 16:23:03 -05:00
13 changed files with 41 additions and 14 deletions

View File

@@ -36,7 +36,9 @@ def get_sdl_options(value):
if value != "":
return value
try:
return subprocess.check_output(["sdl2-config", "--cflags", "--libs"]).decode()
return subprocess.check_output(
["sdl2-config", "--cflags", "--libs"], close_fds=False
).decode()
except Exception as e:
raise cv.Invalid("Unable to run sdl2-config - have you installed sdl2?") from e

View File

@@ -229,6 +229,7 @@ class EsphomeCommandWebSocket(tornado.websocket.WebSocketHandler):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
close_fds=False,
)
stdout_thread = threading.Thread(target=self._stdout_thread)
stdout_thread.daemon = True

View File

@@ -17,7 +17,9 @@ _LOGGER = logging.getLogger(__name__)
def run_git_command(cmd, cwd=None) -> str:
_LOGGER.debug("Running git command: %s", " ".join(cmd))
try:
ret = subprocess.run(cmd, cwd=cwd, capture_output=True, check=False)
ret = subprocess.run(
cmd, cwd=cwd, capture_output=True, check=False, close_fds=False
)
except FileNotFoundError as err:
raise cv.Invalid(
"git is not installed but required for external_components.\n"

View File

@@ -114,7 +114,9 @@ def cpp_string_escape(string, encoding="utf-8"):
def run_system_command(*args):
import subprocess
with subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p:
with subprocess.Popen(
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=False
) as p:
stdout, stderr = p.communicate()
rc = p.returncode
return rc, stdout, stderr

View File

@@ -221,7 +221,7 @@ def _decode_pc(config, addr):
return
command = [idedata.addr2line_path, "-pfiaC", "-e", idedata.firmware_elf_path, addr]
try:
translation = subprocess.check_output(command).decode().strip()
translation = subprocess.check_output(command, close_fds=False).decode().strip()
except Exception: # pylint: disable=broad-except
_LOGGER.debug("Caught exception for command %s", command, exc_info=1)
return

View File

@@ -239,7 +239,12 @@ def run_external_process(*cmd: str, **kwargs: Any) -> int | str:
try:
proc = subprocess.run(
cmd, stdout=sub_stdout, stderr=sub_stderr, encoding="utf-8", check=False
cmd,
stdout=sub_stdout,
stderr=sub_stderr,
encoding="utf-8",
check=False,
close_fds=False,
)
return proc.stdout if capture_stdout else proc.returncode
except KeyboardInterrupt: # pylint: disable=try-except-raise