mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 09:17:46 +01:00
Fix compilation using subprocesses (#2834)
This commit is contained in:
parent
24a5325db3
commit
fbe1bca1b9
1 changed files with 5 additions and 6 deletions
|
@ -219,24 +219,23 @@ def run_external_process(*cmd, **kwargs):
|
||||||
|
|
||||||
capture_stdout = kwargs.get("capture_stdout", False)
|
capture_stdout = kwargs.get("capture_stdout", False)
|
||||||
if capture_stdout:
|
if capture_stdout:
|
||||||
sub_stdout = io.BytesIO()
|
sub_stdout = subprocess.PIPE
|
||||||
else:
|
else:
|
||||||
sub_stdout = RedirectText(sys.stdout, filter_lines=filter_lines)
|
sub_stdout = RedirectText(sys.stdout, filter_lines=filter_lines)
|
||||||
|
|
||||||
sub_stderr = RedirectText(sys.stderr, filter_lines=filter_lines)
|
sub_stderr = RedirectText(sys.stderr, filter_lines=filter_lines)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return subprocess.call(cmd, stdout=sub_stdout, stderr=sub_stderr)
|
proc = subprocess.run(
|
||||||
|
cmd, stdout=sub_stdout, stderr=sub_stderr, encoding="utf-8", check=False
|
||||||
|
)
|
||||||
|
return proc.stdout if capture_stdout else proc.returncode
|
||||||
except KeyboardInterrupt: # pylint: disable=try-except-raise
|
except KeyboardInterrupt: # pylint: disable=try-except-raise
|
||||||
raise
|
raise
|
||||||
except Exception as err: # pylint: disable=broad-except
|
except Exception as err: # pylint: disable=broad-except
|
||||||
_LOGGER.error("Running command failed: %s", err)
|
_LOGGER.error("Running command failed: %s", err)
|
||||||
_LOGGER.error("Please try running %s locally.", full_cmd)
|
_LOGGER.error("Please try running %s locally.", full_cmd)
|
||||||
return 1
|
return 1
|
||||||
finally:
|
|
||||||
if capture_stdout:
|
|
||||||
# pylint: disable=lost-exception
|
|
||||||
return sub_stdout.getvalue()
|
|
||||||
|
|
||||||
|
|
||||||
def is_dev_esphome_version():
|
def is_dev_esphome_version():
|
||||||
|
|
Loading…
Reference in a new issue