Enable Ruff TRY300 (#114437)

* Enable Ruff TRY300

* Update validation.py

* Address review comments
This commit is contained in:
Sid
2024-03-30 10:37:59 +01:00
committed by GitHub
parent 9a79320861
commit 6587ee20db
97 changed files with 259 additions and 243 deletions

View File

@@ -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."""