mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-28 03:26:32 +00:00
Small cleanup & adjustments for 236 (#1978)
This commit is contained in:
parent
30fe36ae05
commit
127073c01b
@ -551,6 +551,7 @@ class Addon(AddonModel):
|
|||||||
try:
|
try:
|
||||||
await self.instance.run()
|
await self.instance.run()
|
||||||
except DockerAPIError as err:
|
except DockerAPIError as err:
|
||||||
|
self.state = AddonState.ERROR
|
||||||
raise AddonsError() from err
|
raise AddonsError() from err
|
||||||
else:
|
else:
|
||||||
self.state = AddonState.STARTED
|
self.state = AddonState.STARTED
|
||||||
@ -560,6 +561,7 @@ class Addon(AddonModel):
|
|||||||
try:
|
try:
|
||||||
return await self.instance.stop()
|
return await self.instance.stop()
|
||||||
except DockerAPIError as err:
|
except DockerAPIError as err:
|
||||||
|
self.state = AddonState.ERROR
|
||||||
raise AddonsError() from err
|
raise AddonsError() from err
|
||||||
else:
|
else:
|
||||||
self.state = AddonState.STOPPED
|
self.state = AddonState.STOPPED
|
||||||
|
@ -66,7 +66,7 @@ from ..const import (
|
|||||||
SECURITY_DEFAULT,
|
SECURITY_DEFAULT,
|
||||||
SECURITY_DISABLE,
|
SECURITY_DISABLE,
|
||||||
SECURITY_PROFILE,
|
SECURITY_PROFILE,
|
||||||
AddonStages,
|
AddonStage,
|
||||||
AddonStartup,
|
AddonStartup,
|
||||||
)
|
)
|
||||||
from ..coresys import CoreSys, CoreSysAttributes
|
from ..coresys import CoreSys, CoreSysAttributes
|
||||||
@ -207,7 +207,7 @@ class AddonModel(CoreSysAttributes, ABC):
|
|||||||
return self.data[ATTR_ADVANCED]
|
return self.data[ATTR_ADVANCED]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def stage(self) -> AddonStages:
|
def stage(self) -> AddonStage:
|
||||||
"""Return stage mode of add-on."""
|
"""Return stage mode of add-on."""
|
||||||
return self.data[ATTR_STAGE]
|
return self.data[ATTR_STAGE]
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ from ..const import (
|
|||||||
PRIVILEGED_ALL,
|
PRIVILEGED_ALL,
|
||||||
ROLE_ALL,
|
ROLE_ALL,
|
||||||
ROLE_DEFAULT,
|
ROLE_DEFAULT,
|
||||||
AddonStages,
|
AddonStage,
|
||||||
AddonStartup,
|
AddonStartup,
|
||||||
AddonState,
|
AddonState,
|
||||||
)
|
)
|
||||||
@ -196,7 +196,7 @@ SCHEMA_ADDON_CONFIG = vol.Schema(
|
|||||||
vol.Required(ATTR_BOOT): vol.In([BOOT_AUTO, BOOT_MANUAL]),
|
vol.Required(ATTR_BOOT): vol.In([BOOT_AUTO, BOOT_MANUAL]),
|
||||||
vol.Optional(ATTR_INIT, default=True): vol.Boolean(),
|
vol.Optional(ATTR_INIT, default=True): vol.Boolean(),
|
||||||
vol.Optional(ATTR_ADVANCED, default=False): vol.Boolean(),
|
vol.Optional(ATTR_ADVANCED, default=False): vol.Boolean(),
|
||||||
vol.Optional(ATTR_STAGE, default=AddonStages.STABLE): vol.Coerce(AddonStages),
|
vol.Optional(ATTR_STAGE, default=AddonStage.STABLE): vol.Coerce(AddonStage),
|
||||||
vol.Optional(ATTR_PORTS): docker_ports,
|
vol.Optional(ATTR_PORTS): docker_ports,
|
||||||
vol.Optional(ATTR_PORTS_DESCRIPTION): docker_ports_description,
|
vol.Optional(ATTR_PORTS_DESCRIPTION): docker_ports_description,
|
||||||
vol.Optional(ATTR_WATCHDOG): vol.Match(
|
vol.Optional(ATTR_WATCHDOG): vol.Match(
|
||||||
|
@ -41,7 +41,7 @@ from ..const import (
|
|||||||
CONTENT_TYPE_BINARY,
|
CONTENT_TYPE_BINARY,
|
||||||
SUPERVISOR_VERSION,
|
SUPERVISOR_VERSION,
|
||||||
LogLevel,
|
LogLevel,
|
||||||
UpdateChannels,
|
UpdateChannel,
|
||||||
)
|
)
|
||||||
from ..coresys import CoreSysAttributes
|
from ..coresys import CoreSysAttributes
|
||||||
from ..exceptions import APIError
|
from ..exceptions import APIError
|
||||||
@ -54,7 +54,7 @@ _LOGGER: logging.Logger = logging.getLogger(__name__)
|
|||||||
# pylint: disable=no-value-for-parameter
|
# pylint: disable=no-value-for-parameter
|
||||||
SCHEMA_OPTIONS = vol.Schema(
|
SCHEMA_OPTIONS = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Optional(ATTR_CHANNEL): vol.Coerce(UpdateChannels),
|
vol.Optional(ATTR_CHANNEL): vol.Coerce(UpdateChannel),
|
||||||
vol.Optional(ATTR_ADDONS_REPOSITORIES): repositories,
|
vol.Optional(ATTR_ADDONS_REPOSITORIES): repositories,
|
||||||
vol.Optional(ATTR_TIMEZONE): validate_timezone,
|
vol.Optional(ATTR_TIMEZONE): validate_timezone,
|
||||||
vol.Optional(ATTR_WAIT_BOOT): wait_boot,
|
vol.Optional(ATTR_WAIT_BOOT): wait_boot,
|
||||||
|
@ -24,7 +24,7 @@ from .const import (
|
|||||||
SOCKET_DOCKER,
|
SOCKET_DOCKER,
|
||||||
SUPERVISOR_VERSION,
|
SUPERVISOR_VERSION,
|
||||||
LogLevel,
|
LogLevel,
|
||||||
UpdateChannels,
|
UpdateChannel,
|
||||||
)
|
)
|
||||||
from .core import Core
|
from .core import Core
|
||||||
from .coresys import CoreSys
|
from .coresys import CoreSys
|
||||||
@ -170,7 +170,7 @@ def initialize_system_data(coresys: CoreSys) -> None:
|
|||||||
# Check if ENV is in development mode
|
# Check if ENV is in development mode
|
||||||
if bool(os.environ.get(ENV_SUPERVISOR_DEV, 0)):
|
if bool(os.environ.get(ENV_SUPERVISOR_DEV, 0)):
|
||||||
_LOGGER.warning("SUPERVISOR_DEV is set")
|
_LOGGER.warning("SUPERVISOR_DEV is set")
|
||||||
coresys.updater.channel = UpdateChannels.DEV
|
coresys.updater.channel = UpdateChannel.DEV
|
||||||
coresys.config.logging = LogLevel.DEBUG
|
coresys.config.logging = LogLevel.DEBUG
|
||||||
coresys.config.debug = True
|
coresys.config.debug = True
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ class AddonStartup(str, Enum):
|
|||||||
ONCE = "once"
|
ONCE = "once"
|
||||||
|
|
||||||
|
|
||||||
class AddonStages(str, Enum):
|
class AddonStage(str, Enum):
|
||||||
"""Stage types of add-on."""
|
"""Stage types of add-on."""
|
||||||
|
|
||||||
STABLE = "stable"
|
STABLE = "stable"
|
||||||
@ -373,9 +373,10 @@ class AddonState(str, Enum):
|
|||||||
STARTED = "started"
|
STARTED = "started"
|
||||||
STOPPED = "stopped"
|
STOPPED = "stopped"
|
||||||
UNKNOWN = "unknown"
|
UNKNOWN = "unknown"
|
||||||
|
ERROR = "error"
|
||||||
|
|
||||||
|
|
||||||
class UpdateChannels(str, Enum):
|
class UpdateChannel(str, Enum):
|
||||||
"""Core supported update channels."""
|
"""Core supported update channels."""
|
||||||
|
|
||||||
STABLE = "stable"
|
STABLE = "stable"
|
||||||
@ -383,7 +384,7 @@ class UpdateChannels(str, Enum):
|
|||||||
DEV = "dev"
|
DEV = "dev"
|
||||||
|
|
||||||
|
|
||||||
class CoreStates(str, Enum):
|
class CoreState(str, Enum):
|
||||||
"""Represent current loading state."""
|
"""Represent current loading state."""
|
||||||
|
|
||||||
INITIALIZE = "initialize"
|
INITIALIZE = "initialize"
|
||||||
|
@ -5,7 +5,7 @@ import logging
|
|||||||
|
|
||||||
import async_timeout
|
import async_timeout
|
||||||
|
|
||||||
from .const import SOCKET_DBUS, SUPERVISED_SUPPORTED_OS, AddonStartup, CoreStates
|
from .const import SOCKET_DBUS, SUPERVISED_SUPPORTED_OS, AddonStartup, CoreState
|
||||||
from .coresys import CoreSys, CoreSysAttributes
|
from .coresys import CoreSys, CoreSysAttributes
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
DockerAPIError,
|
DockerAPIError,
|
||||||
@ -23,7 +23,7 @@ class Core(CoreSysAttributes):
|
|||||||
def __init__(self, coresys: CoreSys):
|
def __init__(self, coresys: CoreSys):
|
||||||
"""Initialize Supervisor object."""
|
"""Initialize Supervisor object."""
|
||||||
self.coresys: CoreSys = coresys
|
self.coresys: CoreSys = coresys
|
||||||
self.state: CoreStates = CoreStates.INITIALIZE
|
self.state: CoreState = CoreState.INITIALIZE
|
||||||
self.healthy: bool = True
|
self.healthy: bool = True
|
||||||
self.supported: bool = True
|
self.supported: bool = True
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ class Core(CoreSysAttributes):
|
|||||||
|
|
||||||
async def setup(self):
|
async def setup(self):
|
||||||
"""Start setting up supervisor orchestration."""
|
"""Start setting up supervisor orchestration."""
|
||||||
self.state = CoreStates.SETUP
|
self.state = CoreState.SETUP
|
||||||
|
|
||||||
# Load DBus
|
# Load DBus
|
||||||
await self.sys_dbus.load()
|
await self.sys_dbus.load()
|
||||||
@ -152,7 +152,7 @@ class Core(CoreSysAttributes):
|
|||||||
|
|
||||||
async def start(self):
|
async def start(self):
|
||||||
"""Start Supervisor orchestration."""
|
"""Start Supervisor orchestration."""
|
||||||
self.state = CoreStates.STARTUP
|
self.state = CoreState.STARTUP
|
||||||
await self.sys_api.start()
|
await self.sys_api.start()
|
||||||
|
|
||||||
# Check if system is healthy
|
# Check if system is healthy
|
||||||
@ -232,16 +232,16 @@ class Core(CoreSysAttributes):
|
|||||||
self.sys_create_task(self.sys_updater.reload())
|
self.sys_create_task(self.sys_updater.reload())
|
||||||
|
|
||||||
_LOGGER.info("Supervisor is up and running")
|
_LOGGER.info("Supervisor is up and running")
|
||||||
self.state = CoreStates.RUNNING
|
self.state = CoreState.RUNNING
|
||||||
|
|
||||||
async def stop(self):
|
async def stop(self):
|
||||||
"""Stop a running orchestration."""
|
"""Stop a running orchestration."""
|
||||||
# store new last boot / prevent time adjustments
|
# store new last boot / prevent time adjustments
|
||||||
if self.state == CoreStates.RUNNING:
|
if self.state == CoreState.RUNNING:
|
||||||
self._update_last_boot()
|
self._update_last_boot()
|
||||||
|
|
||||||
# don't process scheduler anymore
|
# don't process scheduler anymore
|
||||||
self.state = CoreStates.STOPPING
|
self.state = CoreState.STOPPING
|
||||||
|
|
||||||
# Stage 1
|
# Stage 1
|
||||||
try:
|
try:
|
||||||
@ -269,8 +269,8 @@ class Core(CoreSysAttributes):
|
|||||||
async def shutdown(self):
|
async def shutdown(self):
|
||||||
"""Shutdown all running containers in correct order."""
|
"""Shutdown all running containers in correct order."""
|
||||||
# don't process scheduler anymore
|
# don't process scheduler anymore
|
||||||
if self.state == CoreStates.RUNNING:
|
if self.state == CoreState.RUNNING:
|
||||||
self.state = CoreStates.STOPPING
|
self.state = CoreState.STOPPING
|
||||||
|
|
||||||
# Shutdown Application Add-ons, using Home Assistant API
|
# Shutdown Application Add-ons, using Home Assistant API
|
||||||
await self.sys_addons.shutdown(AddonStartup.APPLICATION)
|
await self.sys_addons.shutdown(AddonStartup.APPLICATION)
|
||||||
@ -285,7 +285,7 @@ class Core(CoreSysAttributes):
|
|||||||
await self.sys_addons.shutdown(AddonStartup.INITIALIZE)
|
await self.sys_addons.shutdown(AddonStartup.INITIALIZE)
|
||||||
|
|
||||||
# Shutdown all Plugins
|
# Shutdown all Plugins
|
||||||
if self.state == CoreStates.STOPPING:
|
if self.state == CoreState.STOPPING:
|
||||||
await self.sys_plugins.shutdown()
|
await self.sys_plugins.shutdown()
|
||||||
|
|
||||||
def _update_last_boot(self):
|
def _update_last_boot(self):
|
||||||
|
@ -8,7 +8,7 @@ import aiohttp
|
|||||||
import sentry_sdk
|
import sentry_sdk
|
||||||
|
|
||||||
from .config import CoreConfig
|
from .config import CoreConfig
|
||||||
from .const import UpdateChannels
|
from .const import UpdateChannel
|
||||||
from .docker import DockerAPI
|
from .docker import DockerAPI
|
||||||
from .misc.hardware import Hardware
|
from .misc.hardware import Hardware
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ class CoreSys:
|
|||||||
"""Return True if we run dev mode."""
|
"""Return True if we run dev mode."""
|
||||||
if self._updater is None:
|
if self._updater is None:
|
||||||
return False
|
return False
|
||||||
return self._updater.channel == UpdateChannels.DEV
|
return self._updater.channel == UpdateChannel.DEV
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def loop(self) -> asyncio.BaseEventLoop:
|
def loop(self) -> asyncio.BaseEventLoop:
|
||||||
|
@ -4,7 +4,7 @@ import re
|
|||||||
|
|
||||||
from aiohttp import hdrs
|
from aiohttp import hdrs
|
||||||
|
|
||||||
from ..const import ENV_SUPERVISOR_DEV, HEADER_TOKEN_OLD, CoreStates
|
from ..const import ENV_SUPERVISOR_DEV, HEADER_TOKEN_OLD, CoreState
|
||||||
from ..coresys import CoreSys
|
from ..coresys import CoreSys
|
||||||
from ..exceptions import AddonConfigurationError
|
from ..exceptions import AddonConfigurationError
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ def filter_data(coresys: CoreSys, event: dict, hint: dict) -> dict:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
# Not full startup - missing information
|
# Not full startup - missing information
|
||||||
if coresys.core.state in (CoreStates.INITIALIZE, CoreStates.SETUP):
|
if coresys.core.state in (CoreState.INITIALIZE, CoreState.SETUP):
|
||||||
return event
|
return event
|
||||||
|
|
||||||
# List installed addons
|
# List installed addons
|
||||||
|
@ -8,7 +8,7 @@ from uuid import UUID, uuid4
|
|||||||
import async_timeout
|
import async_timeout
|
||||||
import attr
|
import attr
|
||||||
|
|
||||||
from ..const import CoreStates
|
from ..const import CoreState
|
||||||
from ..coresys import CoreSys, CoreSysAttributes
|
from ..coresys import CoreSys, CoreSysAttributes
|
||||||
|
|
||||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
@ -58,10 +58,10 @@ class Scheduler(CoreSysAttributes):
|
|||||||
async def _wrap_task():
|
async def _wrap_task():
|
||||||
"""Run schedule task and reschedule."""
|
"""Run schedule task and reschedule."""
|
||||||
try:
|
try:
|
||||||
if self.sys_core.state == CoreStates.RUNNING:
|
if self.sys_core.state == CoreState.RUNNING:
|
||||||
await task.coro_callback()
|
await task.coro_callback()
|
||||||
finally:
|
finally:
|
||||||
if task.repeat and self.sys_core.state != CoreStates.STOPPING:
|
if task.repeat and self.sys_core.state != CoreState.STOPPING:
|
||||||
self._schedule_task(task)
|
self._schedule_task(task)
|
||||||
else:
|
else:
|
||||||
self._tasks.remove(task)
|
self._tasks.remove(task)
|
||||||
|
@ -3,7 +3,7 @@ import asyncio
|
|||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from ..const import FOLDER_HOMEASSISTANT, SNAPSHOT_FULL, SNAPSHOT_PARTIAL, CoreStates
|
from ..const import FOLDER_HOMEASSISTANT, SNAPSHOT_FULL, SNAPSHOT_PARTIAL, CoreState
|
||||||
from ..coresys import CoreSysAttributes
|
from ..coresys import CoreSysAttributes
|
||||||
from ..exceptions import AddonsError
|
from ..exceptions import AddonsError
|
||||||
from ..utils.dt import utcnow
|
from ..utils.dt import utcnow
|
||||||
@ -126,7 +126,7 @@ class SnapshotManager(CoreSysAttributes):
|
|||||||
snapshot = self._create_snapshot(name, SNAPSHOT_FULL, password)
|
snapshot = self._create_snapshot(name, SNAPSHOT_FULL, password)
|
||||||
_LOGGER.info("Full-Snapshot %s start", snapshot.slug)
|
_LOGGER.info("Full-Snapshot %s start", snapshot.slug)
|
||||||
try:
|
try:
|
||||||
self.sys_core.state = CoreStates.FREEZE
|
self.sys_core.state = CoreState.FREEZE
|
||||||
await self.lock.acquire()
|
await self.lock.acquire()
|
||||||
|
|
||||||
async with snapshot:
|
async with snapshot:
|
||||||
@ -148,7 +148,7 @@ class SnapshotManager(CoreSysAttributes):
|
|||||||
return snapshot
|
return snapshot
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
self.sys_core.state = CoreStates.RUNNING
|
self.sys_core.state = CoreState.RUNNING
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
|
|
||||||
async def do_snapshot_partial(
|
async def do_snapshot_partial(
|
||||||
@ -165,7 +165,7 @@ class SnapshotManager(CoreSysAttributes):
|
|||||||
|
|
||||||
_LOGGER.info("Partial-Snapshot %s start", snapshot.slug)
|
_LOGGER.info("Partial-Snapshot %s start", snapshot.slug)
|
||||||
try:
|
try:
|
||||||
self.sys_core.state = CoreStates.FREEZE
|
self.sys_core.state = CoreState.FREEZE
|
||||||
await self.lock.acquire()
|
await self.lock.acquire()
|
||||||
|
|
||||||
async with snapshot:
|
async with snapshot:
|
||||||
@ -197,7 +197,7 @@ class SnapshotManager(CoreSysAttributes):
|
|||||||
return snapshot
|
return snapshot
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
self.sys_core.state = CoreStates.RUNNING
|
self.sys_core.state = CoreState.RUNNING
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
|
|
||||||
async def do_restore_full(self, snapshot, password=None):
|
async def do_restore_full(self, snapshot, password=None):
|
||||||
@ -216,7 +216,7 @@ class SnapshotManager(CoreSysAttributes):
|
|||||||
|
|
||||||
_LOGGER.info("Full-Restore %s start", snapshot.slug)
|
_LOGGER.info("Full-Restore %s start", snapshot.slug)
|
||||||
try:
|
try:
|
||||||
self.sys_core.state = CoreStates.FREEZE
|
self.sys_core.state = CoreState.FREEZE
|
||||||
await self.lock.acquire()
|
await self.lock.acquire()
|
||||||
|
|
||||||
async with snapshot:
|
async with snapshot:
|
||||||
@ -269,7 +269,7 @@ class SnapshotManager(CoreSysAttributes):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
self.sys_core.state = CoreStates.RUNNING
|
self.sys_core.state = CoreState.RUNNING
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
|
|
||||||
async def do_restore_partial(
|
async def do_restore_partial(
|
||||||
@ -289,7 +289,7 @@ class SnapshotManager(CoreSysAttributes):
|
|||||||
|
|
||||||
_LOGGER.info("Partial-Restore %s start", snapshot.slug)
|
_LOGGER.info("Partial-Restore %s start", snapshot.slug)
|
||||||
try:
|
try:
|
||||||
self.sys_core.state = CoreStates.FREEZE
|
self.sys_core.state = CoreState.FREEZE
|
||||||
await self.lock.acquire()
|
await self.lock.acquire()
|
||||||
|
|
||||||
async with snapshot:
|
async with snapshot:
|
||||||
@ -343,5 +343,5 @@ class SnapshotManager(CoreSysAttributes):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
self.sys_core.state = CoreStates.RUNNING
|
self.sys_core.state = CoreState.RUNNING
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
|
@ -20,7 +20,7 @@ from .const import (
|
|||||||
ATTR_SUPERVISOR,
|
ATTR_SUPERVISOR,
|
||||||
FILE_HASSIO_UPDATER,
|
FILE_HASSIO_UPDATER,
|
||||||
URL_HASSIO_VERSION,
|
URL_HASSIO_VERSION,
|
||||||
UpdateChannels,
|
UpdateChannel,
|
||||||
)
|
)
|
||||||
from .coresys import CoreSysAttributes
|
from .coresys import CoreSysAttributes
|
||||||
from .exceptions import HassioUpdaterError
|
from .exceptions import HassioUpdaterError
|
||||||
@ -133,12 +133,12 @@ class Updater(JsonConfig, CoreSysAttributes):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def channel(self) -> UpdateChannels:
|
def channel(self) -> UpdateChannel:
|
||||||
"""Return upstream channel of Supervisor instance."""
|
"""Return upstream channel of Supervisor instance."""
|
||||||
return self._data[ATTR_CHANNEL]
|
return self._data[ATTR_CHANNEL]
|
||||||
|
|
||||||
@channel.setter
|
@channel.setter
|
||||||
def channel(self, value: UpdateChannels):
|
def channel(self, value: UpdateChannel):
|
||||||
"""Set upstream mode."""
|
"""Set upstream mode."""
|
||||||
self._data[ATTR_CHANNEL] = value
|
self._data[ATTR_CHANNEL] = value
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ from .const import (
|
|||||||
ATTR_WATCHDOG,
|
ATTR_WATCHDOG,
|
||||||
SUPERVISOR_VERSION,
|
SUPERVISOR_VERSION,
|
||||||
LogLevel,
|
LogLevel,
|
||||||
UpdateChannels,
|
UpdateChannel,
|
||||||
)
|
)
|
||||||
from .utils.validate import validate_timezone
|
from .utils.validate import validate_timezone
|
||||||
|
|
||||||
@ -128,8 +128,8 @@ SCHEMA_HASS_CONFIG = vol.Schema(
|
|||||||
|
|
||||||
SCHEMA_UPDATER_CONFIG = vol.Schema(
|
SCHEMA_UPDATER_CONFIG = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Optional(ATTR_CHANNEL, default=UpdateChannels.STABLE): vol.Coerce(
|
vol.Optional(ATTR_CHANNEL, default=UpdateChannel.STABLE): vol.Coerce(
|
||||||
UpdateChannels
|
UpdateChannel
|
||||||
),
|
),
|
||||||
vol.Optional(ATTR_HOMEASSISTANT): vol.All(version_tag, str),
|
vol.Optional(ATTR_HOMEASSISTANT): vol.All(version_tag, str),
|
||||||
vol.Optional(ATTR_SUPERVISOR): vol.All(version_tag, str),
|
vol.Optional(ATTR_SUPERVISOR): vol.All(version_tag, str),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""Test sentry data filter."""
|
"""Test sentry data filter."""
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from supervisor.const import SUPERVISOR_VERSION, CoreStates
|
from supervisor.const import SUPERVISOR_VERSION, CoreState
|
||||||
from supervisor.exceptions import AddonConfigurationError
|
from supervisor.exceptions import AddonConfigurationError
|
||||||
from supervisor.misc.filter import filter_data
|
from supervisor.misc.filter import filter_data
|
||||||
|
|
||||||
@ -41,10 +41,10 @@ def test_not_started(coresys):
|
|||||||
coresys.config.diagnostics = True
|
coresys.config.diagnostics = True
|
||||||
coresys.core.supported = True
|
coresys.core.supported = True
|
||||||
|
|
||||||
coresys.core.state = CoreStates.INITIALIZE
|
coresys.core.state = CoreState.INITIALIZE
|
||||||
assert filter_data(coresys, SAMPLE_EVENT, {}) == SAMPLE_EVENT
|
assert filter_data(coresys, SAMPLE_EVENT, {}) == SAMPLE_EVENT
|
||||||
|
|
||||||
coresys.core.state = CoreStates.SETUP
|
coresys.core.state = CoreState.SETUP
|
||||||
assert filter_data(coresys, SAMPLE_EVENT, {}) == SAMPLE_EVENT
|
assert filter_data(coresys, SAMPLE_EVENT, {}) == SAMPLE_EVENT
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ def test_defaults(coresys):
|
|||||||
coresys.config.diagnostics = True
|
coresys.config.diagnostics = True
|
||||||
coresys.supported = True
|
coresys.supported = True
|
||||||
|
|
||||||
coresys.core.state = CoreStates.RUNNING
|
coresys.core.state = CoreState.RUNNING
|
||||||
with patch("shutil.disk_usage", return_value=(42, 42, 2 * (1024.0 ** 3))):
|
with patch("shutil.disk_usage", return_value=(42, 42, 2 * (1024.0 ** 3))):
|
||||||
filtered = filter_data(coresys, SAMPLE_EVENT, {})
|
filtered = filter_data(coresys, SAMPLE_EVENT, {})
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ def test_sanitize(coresys):
|
|||||||
coresys.config.diagnostics = True
|
coresys.config.diagnostics = True
|
||||||
coresys.supported = True
|
coresys.supported = True
|
||||||
|
|
||||||
coresys.core.state = CoreStates.RUNNING
|
coresys.core.state = CoreState.RUNNING
|
||||||
with patch("shutil.disk_usage", return_value=(42, 42, 2 * (1024.0 ** 3))):
|
with patch("shutil.disk_usage", return_value=(42, 42, 2 * (1024.0 ** 3))):
|
||||||
filtered = filter_data(coresys, event, {})
|
filtered = filter_data(coresys, event, {})
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
"""Test Supervisor scheduler backend."""
|
"""Test Supervisor scheduler backend."""
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from supervisor.const import CoreStates
|
from supervisor.const import CoreState
|
||||||
|
|
||||||
|
|
||||||
async def test_simple_task(coresys):
|
async def test_simple_task(coresys):
|
||||||
"""Schedule a simple task."""
|
"""Schedule a simple task."""
|
||||||
coresys.core.state = CoreStates.RUNNING
|
coresys.core.state = CoreState.RUNNING
|
||||||
trigger = []
|
trigger = []
|
||||||
|
|
||||||
async def test_task():
|
async def test_task():
|
||||||
@ -21,7 +21,7 @@ async def test_simple_task(coresys):
|
|||||||
|
|
||||||
async def test_simple_task_repeat(coresys):
|
async def test_simple_task_repeat(coresys):
|
||||||
"""Schedule a simple task and repeat."""
|
"""Schedule a simple task and repeat."""
|
||||||
coresys.core.state = CoreStates.RUNNING
|
coresys.core.state = CoreState.RUNNING
|
||||||
trigger = []
|
trigger = []
|
||||||
|
|
||||||
async def test_task():
|
async def test_task():
|
||||||
@ -36,7 +36,7 @@ async def test_simple_task_repeat(coresys):
|
|||||||
|
|
||||||
async def test_simple_task_shutdown(coresys):
|
async def test_simple_task_shutdown(coresys):
|
||||||
"""Schedule a simple task with shudown."""
|
"""Schedule a simple task with shudown."""
|
||||||
coresys.core.state = CoreStates.RUNNING
|
coresys.core.state = CoreState.RUNNING
|
||||||
trigger = []
|
trigger = []
|
||||||
|
|
||||||
async def test_task():
|
async def test_task():
|
||||||
@ -57,7 +57,7 @@ async def test_simple_task_shutdown(coresys):
|
|||||||
|
|
||||||
async def test_simple_task_repeat_block(coresys):
|
async def test_simple_task_repeat_block(coresys):
|
||||||
"""Schedule a simple task with repeat and block."""
|
"""Schedule a simple task with repeat and block."""
|
||||||
coresys.core.state = CoreStates.RUNNING
|
coresys.core.state = CoreState.RUNNING
|
||||||
trigger = []
|
trigger = []
|
||||||
|
|
||||||
async def test_task():
|
async def test_task():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user