#743 - Trying to fix this.

This commit is contained in:
ccostan
2020-05-21 18:48:00 -04:00
parent cf3764e3e4
commit 5c7334bc05
42 changed files with 863 additions and 513 deletions

View File

@@ -6,7 +6,7 @@ https://hacs.xyz/
"""
import voluptuous as vol
from aiogithubapi import AIOGitHub, AIOGitHubException
from aiogithubapi import GitHub, AIOGitHubAPIException
from homeassistant import config_entries
from homeassistant.const import EVENT_HOMEASSISTANT_START
from homeassistant.const import __version__ as HAVERSION
@@ -15,12 +15,9 @@ from homeassistant.exceptions import ConfigEntryNotReady, ServiceNotFound
from homeassistant.helpers.aiohttp_client import async_create_clientsession
from homeassistant.helpers.event import async_call_later
from custom_components.hacs.configuration_schema import (
hacs_base_config_schema,
hacs_config_option_schema,
)
from custom_components.hacs.configuration_schema import hacs_config_combined
from custom_components.hacs.const import DOMAIN, ELEMENT_TYPES, STARTUP, VERSION
from custom_components.hacs.constrains import check_constans, check_requirements
from custom_components.hacs.constrains import check_constrains
from custom_components.hacs.helpers.remaining_github_calls import get_fetch_updates_for
from custom_components.hacs.hacsbase.configuration import Configuration
from custom_components.hacs.hacsbase.data import HacsData
@@ -34,9 +31,7 @@ from custom_components.hacs.globals import get_hacs
from custom_components.hacs.helpers.network import internet_connectivity_check
SCHEMA = hacs_base_config_schema()
SCHEMA[vol.Optional("options")] = hacs_config_option_schema()
CONFIG_SCHEMA = vol.Schema({DOMAIN: SCHEMA}, extra=vol.ALLOW_EXTRA)
CONFIG_SCHEMA = vol.Schema({DOMAIN: hacs_config_combined()}, extra=vol.ALLOW_EXTRA)
async def async_setup(hass, config):
@@ -49,17 +44,10 @@ async def async_setup(hass, config):
hass.data[DOMAIN] = config
hacs.hass = hass
hacs.session = async_create_clientsession(hass)
hacs.configuration = Configuration.from_dict(
config[DOMAIN], config[DOMAIN].get("options")
)
hacs.configuration = Configuration.from_dict(config[DOMAIN])
hacs.configuration.config = config
hacs.configuration.config_type = "yaml"
await startup_wrapper_for_yaml()
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data={}
)
)
return True
@@ -67,11 +55,10 @@ async def async_setup_entry(hass, config_entry):
"""Set up this integration using UI."""
hacs = get_hacs()
conf = hass.data.get(DOMAIN)
if conf is not None:
return False
if config_entry.source == config_entries.SOURCE_IMPORT:
if conf is None:
hass.async_create_task(
hass.config_entries.async_remove(config_entry.entry_id)
)
hass.async_create_task(hass.config_entries.async_remove(config_entry.entry_id))
return False
hacs.hass = hass
hacs.session = async_create_clientsession(hass)
@@ -83,7 +70,7 @@ async def async_setup_entry(hass, config_entry):
config_entry.add_update_listener(reload_hacs)
try:
startup_result = await hacs_startup()
except AIOGitHubException:
except AIOGitHubAPIException:
startup_result = False
if not startup_result:
hacs.system.disabled = True
@@ -97,7 +84,7 @@ async def startup_wrapper_for_yaml():
hacs = get_hacs()
try:
startup_result = await hacs_startup()
except AIOGitHubException:
except AIOGitHubAPIException:
startup_result = False
if not startup_result:
hacs.system.disabled = True
@@ -115,8 +102,6 @@ async def startup_wrapper_for_yaml():
async def hacs_startup():
"""HACS startup tasks."""
hacs = get_hacs()
if not check_requirements():
return False
if hacs.configuration.debug:
try:
await hacs.hass.services.async_call(
@@ -142,7 +127,7 @@ async def hacs_startup():
hacs.system.lovelace_mode = lovelace_info.get("mode", "yaml")
hacs.system.disabled = False
hacs.github = AIOGitHub(
hacs.github = GitHub(
hacs.configuration.token, async_create_clientsession(hacs.hass)
)
hacs.data = HacsData()
@@ -154,7 +139,7 @@ async def hacs_startup():
hacs.logger.debug(f"Can update {can_update} repositories")
# Check HACS Constrains
if not await hacs.hass.async_add_executor_job(check_constans):
if not await hacs.hass.async_add_executor_job(check_constrains):
if hacs.configuration.config_type == "flow":
if hacs.configuration.config_entry is not None:
await async_remove_entry(hacs.hass, hacs.configuration.config_entry)
@@ -189,18 +174,6 @@ async def hacs_startup():
hacs.common.categories.append("appdaemon")
if hacs.configuration.netdaemon:
hacs.common.categories.append("netdaemon")
if hacs.configuration.python_script:
hacs.configuration.python_script = False
if hacs.configuration.config_type == "yaml":
hacs.logger.warning(
"Configuration option 'python_script' is deprecated and you should remove it from your configuration, HACS will know if you use 'python_script' in your Home Assistant configuration, this option will be removed in a future release."
)
if hacs.configuration.theme:
hacs.configuration.theme = False
if hacs.configuration.config_type == "yaml":
hacs.logger.warning(
"Configuration option 'theme' is deprecated and you should remove it from your configuration, HACS will know if you use 'theme' in your Home Assistant configuration, this option will be removed in a future release."
)
# Setup startup tasks
if hacs.configuration.config_type == "yaml":