Add stdout and stderr to debug output for shell_command (#14465)
This commit is contained in:
parent
25dcddfeef
commit
1053473111
2 changed files with 51 additions and 5 deletions
|
@ -68,8 +68,9 @@ def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
|
|||
cmd,
|
||||
loop=hass.loop,
|
||||
stdin=None,
|
||||
stdout=asyncio.subprocess.DEVNULL,
|
||||
stderr=asyncio.subprocess.DEVNULL)
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
)
|
||||
else:
|
||||
# Template used. Break into list and use create_subprocess_exec
|
||||
# (which uses shell=False) for security
|
||||
|
@ -80,12 +81,19 @@ def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
|
|||
*shlexed_cmd,
|
||||
loop=hass.loop,
|
||||
stdin=None,
|
||||
stdout=asyncio.subprocess.DEVNULL,
|
||||
stderr=asyncio.subprocess.DEVNULL)
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
)
|
||||
|
||||
process = yield from create_process
|
||||
yield from process.communicate()
|
||||
stdout_data, stderr_data = yield from process.communicate()
|
||||
|
||||
if stdout_data:
|
||||
_LOGGER.debug("Stdout of command: `%s`, return code: %s:\n%s",
|
||||
cmd, process.returncode, stdout_data)
|
||||
if stderr_data:
|
||||
_LOGGER.debug("Stderr of command: `%s`, return code: %s:\n%s",
|
||||
cmd, process.returncode, stderr_data)
|
||||
if process.returncode != 0:
|
||||
_LOGGER.exception("Error running command: `%s`, return code: %s",
|
||||
cmd, process.returncode)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue