mirror of
https://github.com/home-assistant/core.git
synced 2025-11-14 21:40:16 +00:00
Enable Ruff TRY300 (#114437)
* Enable Ruff TRY300 * Update validation.py * Address review comments
This commit is contained in:
@@ -25,20 +25,21 @@ async def async_call_shell_with_timeout(
|
||||
)
|
||||
async with asyncio.timeout(timeout):
|
||||
await proc.communicate()
|
||||
return_code = proc.returncode
|
||||
if return_code == _EXEC_FAILED_CODE:
|
||||
_LOGGER.error("Error trying to exec command: %s", command)
|
||||
elif log_return_code and return_code != 0:
|
||||
_LOGGER.error(
|
||||
"Command failed (with return code %s): %s",
|
||||
proc.returncode,
|
||||
command,
|
||||
)
|
||||
return return_code or 0
|
||||
except TimeoutError:
|
||||
_LOGGER.error("Timeout for command: %s", command)
|
||||
return -1
|
||||
|
||||
return_code = proc.returncode
|
||||
if return_code == _EXEC_FAILED_CODE:
|
||||
_LOGGER.error("Error trying to exec command: %s", command)
|
||||
elif log_return_code and return_code != 0:
|
||||
_LOGGER.error(
|
||||
"Command failed (with return code %s): %s",
|
||||
proc.returncode,
|
||||
command,
|
||||
)
|
||||
return return_code or 0
|
||||
|
||||
|
||||
async def async_check_output_or_log(command: str, timeout: int) -> str | None:
|
||||
"""Run a shell command with a timeout and return the output."""
|
||||
|
||||
Reference in New Issue
Block a user