Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if file.name.lower() in info_files:
info = await self.repository_object.get_contents(
file.name, self.ref
)
break
if info is None:
self.information.additional_info = ""
else:
info = info.content.replace("
if file.name.lower() in info_files:
info = await self.repository_object.get_contents(
file.name, self.ref
)
break
if info is None:
self.information.additional_info = ""
else:
info = info.content.replace("
async def handle_critical_repositories(self):
"""Handled critical repositories during runtime."""
# Get critical repositories
instored = []
critical = []
was_installed = False
try:
critical = await self.data_repo.get_contents("critical")
critical = json.loads(critical.content)
except AIOGitHubException:
pass
if not critical:
self.logger.debug("No critical repositories")
return
stored_critical = await async_load_from_store(self.hass, "critical")
for stored in stored_critical or []:
instored.append(stored["repository"])
stored_critical = []
for repository in critical:
self.common.blacklist.append(repository["repository"])
repo = self.get_by_name(repository["repository"])
async def load_hacs_repository(hacs):
"""Load HACS repositroy."""
from .const import VERSION
from aiogithubapi import (
AIOGitHubAuthentication,
AIOGitHubException,
AIOGitHubRatelimit,
)
try:
repository = hacs().get_by_name("hacs/integration")
if repository is None:
await hacs().register_repository("hacs/integration", "integration")
repository = hacs().get_by_name("hacs/integration")
if repository is None:
raise AIOGitHubException("Unknown error")
repository.status.installed = True
repository.versions.installed = VERSION
repository.status.new = False
hacs.repo = repository.repository_object
hacs.data_repo = await hacs().github.get_repo("hacs/default")
except (
AIOGitHubException,
AIOGitHubRatelimit,
AIOGitHubAuthentication,
) as exception:
hacs.logger.critical(f"[{exception}] - Could not load HACS!")
return False
return True
async def load_hacs_repository(hacs):
"""Load HACS repositroy."""
try:
repository = hacs().get_by_name("hacs/integration")
if repository is None:
await hacs().register_repository("hacs/integration", "integration")
repository = hacs().get_by_name("hacs/integration")
if repository is None:
raise AIOGitHubException("Unknown error")
repository.status.installed = True
repository.versions.installed = VERSION
repository.status.new = False
hacs.repo = repository.repository_object
hacs.data_repo = await hacs().github.get_repo("hacs/default")
except (
AIOGitHubException,
AIOGitHubRatelimit,
AIOGitHubAuthentication,
) as exception:
hacs.logger.critical(f"[{exception}] - Could not load HACS!")
return False
return True
async def safe_register(self, hacs, repo, category):
async with max_concurrent_tasks:
try:
await hacs.register_repository(repo, category)
except AIOGitHubException as exception:
logger.error(exception)
# Due to GitHub ratelimits we need to sleep a bit
await asyncio.sleep(sleeper)
repository.status.show_beta = False
repository.remove()
elif action == "set_version":
if msg["version"] == repository.information.default_branch:
repository.status.selected_tag = None
else:
repository.status.selected_tag = msg["version"]
await repository.update_repository()
else:
Hacs().logger.error(f"WS action '{action}' is not valid")
repository.state = None
await Hacs().data.async_write()
except AIOGitHubException as exception:
hass.bus.async_fire("hacs/error", {"message": str(exception)})
except AttributeError as exception:
hass.bus.async_fire(
"hacs/error", {"message": f"Could not use repository with ID {repo_id}"}
)
except Exception as exception: # pylint: disable=broad-except
hass.bus.async_fire("hacs/error", {"message": str(exception)})
repository.status.show_beta = False
repository.remove()
elif action == "set_version":
if msg["version"] == repository.information.default_branch:
repository.status.selected_tag = None
else:
repository.status.selected_tag = msg["version"]
await repository.update_repository()
else:
Hacs().logger.error(f"WS action '{action}' is not valid")
repository.state = None
await Hacs().data.async_write()
except AIOGitHubException as exception:
hass.bus.async_fire("hacs/error", {"message": str(exception)})
except AttributeError as exception:
hass.bus.async_fire(
"hacs/error", {"message": f"Could not use repository with ID {repo_id}"}
)
except Exception as exception: # pylint: disable=broad-except
hass.bus.async_fire("hacs/error", {"message": str(exception)})
info = info.replace("<code>", "<code class="codeinfo">")
info = info.replace(
'<a href="http', '<a rel=">", "<li style="list-style-type: initial;">")
# Special changes that needs to be done:
info = info.replace(
"</li></a></code></code>