Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call out timeout error while downloading files #2515

Merged
merged 4 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions custom_components/hacs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,10 +592,18 @@ async def async_download_file(self, url: str) -> bytes | None:
raise HacsException(
f"Got status code {request.status} when trying to download {url}"
)
except asyncio.TimeoutError:
self.log.error(
"A timeout of 60! seconds was encountered while downloading %s, "
"check the network on the host running Home Assistant",
url,
)
return None
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
self.log.debug("Download failed - %s", exception)
tries_left -= 1
await asyncio.sleep(1)
continue

self.log.error("Download from %s failed", url)
return None
8 changes: 7 additions & 1 deletion custom_components/hacs/system_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ async def system_health_info(hass):

data = {
"GitHub API": system_health.async_check_can_reach_url(hass, BASE_API_URL, GITHUB_STATUS),
"Github API Calls Remaining": response.data.resources.core.remaining,
"GitHub Content": system_health.async_check_can_reach_url(
hass, "https://raw.githubusercontent.com/hacs/integration/main/hacs.json"
),
"GitHub Web": system_health.async_check_can_reach_url(
hass, "https://github.com/", GITHUB_STATUS
),
"GitHub API Calls Remaining": response.data.resources.core.remaining,
"Installed Version": hacs.version,
"Stage": hacs.stage,
"Available Repositories": len(hacs.repositories.list_all),
Expand Down