mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-12-24 12:29:08 +00:00
Add blockbuster library and find I/O from unit tests (#5731)
* Add blockbuster library and find I/O from unit tests * Fix lint and test issue * Fixes from feedback * Avoid modifying webapp object in executor * Split su options validation and only validate timezone on change
This commit is contained in:
@@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
from collections.abc import Callable, Coroutine
|
||||
from contextvars import Context, copy_context
|
||||
from datetime import datetime
|
||||
from datetime import UTC, datetime, tzinfo
|
||||
from functools import partial
|
||||
import logging
|
||||
import os
|
||||
@@ -22,7 +22,6 @@ from .const import (
|
||||
MACHINE_ID,
|
||||
SERVER_SOFTWARE,
|
||||
)
|
||||
from .utils.dt import UTC, get_time_zone
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .addons.manager import AddonManager
|
||||
@@ -143,13 +142,19 @@ class CoreSys:
|
||||
"""Return system timezone."""
|
||||
if self.config.timezone:
|
||||
return self.config.timezone
|
||||
# pylint bug with python 3.12.4 (https://github.com/pylint-dev/pylint/issues/9811)
|
||||
# pylint: disable=no-member
|
||||
if self.host.info.timezone:
|
||||
return self.host.info.timezone
|
||||
# pylint: enable=no-member
|
||||
return "UTC"
|
||||
|
||||
@property
|
||||
def timezone_tzinfo(self) -> tzinfo:
|
||||
"""Return system timezone as tzinfo object."""
|
||||
if self.config.timezone_tzinfo:
|
||||
return self.config.timezone_tzinfo
|
||||
if self.host.info.timezone_tzinfo:
|
||||
return self.host.info.timezone_tzinfo
|
||||
return UTC
|
||||
|
||||
@property
|
||||
def loop(self) -> asyncio.BaseEventLoop:
|
||||
"""Return loop object."""
|
||||
@@ -555,7 +560,7 @@ class CoreSys:
|
||||
|
||||
def now(self) -> datetime:
|
||||
"""Return now in local timezone."""
|
||||
return datetime.now(get_time_zone(self.timezone) or UTC)
|
||||
return datetime.now(self.timezone_tzinfo)
|
||||
|
||||
def add_set_task_context_callback(
|
||||
self, callback: Callable[[Context], Context]
|
||||
@@ -642,6 +647,11 @@ class CoreSysAttributes:
|
||||
"""Return running machine type of the Supervisor system."""
|
||||
return self.coresys.machine
|
||||
|
||||
@property
|
||||
def sys_machine_id(self) -> str | None:
|
||||
"""Return machine id."""
|
||||
return self.coresys.machine_id
|
||||
|
||||
@property
|
||||
def sys_dev(self) -> bool:
|
||||
"""Return True if we run dev mode."""
|
||||
|
||||
Reference in New Issue
Block a user