mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-21 16:16:31 +00:00
Report error correct for rauc (#1403)
* Report error correct * Use new style
This commit is contained in:
parent
bf1a9ec42d
commit
a0d106529c
@ -1,5 +1,6 @@
|
|||||||
"""D-Bus interface for rauc."""
|
"""D-Bus interface for rauc."""
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from .interface import DBusInterface
|
from .interface import DBusInterface
|
||||||
from .utils import dbus_connected
|
from .utils import dbus_connected
|
||||||
@ -15,6 +16,14 @@ DBUS_OBJECT = "/"
|
|||||||
class Rauc(DBusInterface):
|
class Rauc(DBusInterface):
|
||||||
"""Handle D-Bus interface for rauc."""
|
"""Handle D-Bus interface for rauc."""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
"""Initialize Properties."""
|
||||||
|
self._operation: Optional[str] = None
|
||||||
|
self._last_error: Optional[str] = None
|
||||||
|
self._compatible: Optional[str] = None
|
||||||
|
self._variant: Optional[str] = None
|
||||||
|
self._boot_slot: Optional[str] = None
|
||||||
|
|
||||||
async def connect(self):
|
async def connect(self):
|
||||||
"""Connect to D-Bus."""
|
"""Connect to D-Bus."""
|
||||||
try:
|
try:
|
||||||
@ -24,6 +33,31 @@ class Rauc(DBusInterface):
|
|||||||
except DBusInterfaceError:
|
except DBusInterfaceError:
|
||||||
_LOGGER.warning("Host has no rauc support. OTA updates have been disabled.")
|
_LOGGER.warning("Host has no rauc support. OTA updates have been disabled.")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def operation(self) -> Optional[str]:
|
||||||
|
"""Return the current (global) operation."""
|
||||||
|
return self._operation
|
||||||
|
|
||||||
|
@property
|
||||||
|
def last_error(self) -> Optional[str]:
|
||||||
|
"""Return the last message of the last error that occurred."""
|
||||||
|
return self._last_error
|
||||||
|
|
||||||
|
@property
|
||||||
|
def compatible(self) -> Optional[str]:
|
||||||
|
"""Return the system compatible string."""
|
||||||
|
return self._compatible
|
||||||
|
|
||||||
|
@property
|
||||||
|
def variant(self) -> Optional[str]:
|
||||||
|
"""Return the system variant string."""
|
||||||
|
return self._variant
|
||||||
|
|
||||||
|
@property
|
||||||
|
def boot_slot(self) -> Optional[str]:
|
||||||
|
"""Return the used boot slot."""
|
||||||
|
return self._boot_slot
|
||||||
|
|
||||||
@dbus_connected
|
@dbus_connected
|
||||||
def install(self, raucb_file):
|
def install(self, raucb_file):
|
||||||
"""Install rauc bundle file.
|
"""Install rauc bundle file.
|
||||||
@ -40,14 +74,6 @@ class Rauc(DBusInterface):
|
|||||||
"""
|
"""
|
||||||
return self.dbus.Installer.GetSlotStatus()
|
return self.dbus.Installer.GetSlotStatus()
|
||||||
|
|
||||||
@dbus_connected
|
|
||||||
def get_properties(self):
|
|
||||||
"""Return rauc informations.
|
|
||||||
|
|
||||||
Return a coroutine.
|
|
||||||
"""
|
|
||||||
return self.dbus.get_properties(f"{DBUS_NAME}.Installer")
|
|
||||||
|
|
||||||
@dbus_connected
|
@dbus_connected
|
||||||
def signal_completed(self):
|
def signal_completed(self):
|
||||||
"""Return a signal wrapper for completed signal.
|
"""Return a signal wrapper for completed signal.
|
||||||
@ -55,3 +81,17 @@ class Rauc(DBusInterface):
|
|||||||
Return a coroutine.
|
Return a coroutine.
|
||||||
"""
|
"""
|
||||||
return self.dbus.wait_signal(f"{DBUS_NAME}.Installer.Completed")
|
return self.dbus.wait_signal(f"{DBUS_NAME}.Installer.Completed")
|
||||||
|
|
||||||
|
@dbus_connected
|
||||||
|
async def update(self):
|
||||||
|
"""Update Properties."""
|
||||||
|
data = await self.dbus.get_properties(f"{DBUS_NAME}.Installer")
|
||||||
|
if not data:
|
||||||
|
_LOGGER.warning("Can't get properties for rauc")
|
||||||
|
return
|
||||||
|
|
||||||
|
self._operation = data.get("Operation")
|
||||||
|
self._last_error = data.get("LastError")
|
||||||
|
self._compatible = data.get("Compatible")
|
||||||
|
self._variant = data.get("Variant")
|
||||||
|
self._boot_slot = data.get("BootSlot")
|
||||||
|
@ -128,7 +128,11 @@ class HassOS(CoreSysAttributes):
|
|||||||
self._version = cpe.get_version()[0]
|
self._version = cpe.get_version()[0]
|
||||||
self._board = cpe.get_target_hardware()[0]
|
self._board = cpe.get_target_hardware()[0]
|
||||||
|
|
||||||
_LOGGER.info("Detect HassOS %s on host system", self.version)
|
await self.sys_dbus.rauc.update()
|
||||||
|
|
||||||
|
_LOGGER.info(
|
||||||
|
"Detect HassOS %s / BootSlot %s", self.version, self.sys_dbus.rauc.boot_slot
|
||||||
|
)
|
||||||
with suppress(DockerAPIError):
|
with suppress(DockerAPIError):
|
||||||
await self.instance.attach(tag="latest")
|
await self.instance.attach(tag="latest")
|
||||||
|
|
||||||
@ -174,8 +178,8 @@ class HassOS(CoreSysAttributes):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Update fails
|
# Update fails
|
||||||
rauc_status = await self.sys_dbus.get_properties()
|
await self.sys_dbus.rauc.update()
|
||||||
_LOGGER.error("HassOS update fails with: %s", rauc_status.get("LastError"))
|
_LOGGER.error("HassOS update fails with: %s", self.sys_dbus.rauc.last_error)
|
||||||
raise HassOSUpdateError()
|
raise HassOSUpdateError()
|
||||||
|
|
||||||
async def update_cli(self, version: Optional[str] = None) -> None:
|
async def update_cli(self, version: Optional[str] = None) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user