diff --git a/otaclient/app/boot_control/_cboot.py b/otaclient/app/boot_control/_cboot.py index 7a2041eed..512789b3b 100644 --- a/otaclient/app/boot_control/_cboot.py +++ b/otaclient/app/boot_control/_cboot.py @@ -21,7 +21,7 @@ from typing import Generator, Optional -from .. import log_setting +from .. import log_setting, errors as ota_errors from ..common import ( copytree_identical, read_str_from_file, @@ -30,14 +30,6 @@ write_str_to_file_sync, ) -from ..errors import ( - BootControlStartupFailed, - BootControlPlatformUnsupported, - BootControlPostRollbackFailed, - BootControlPostUpdateFailed, - BootControlPreRollbackFailed, - BootControlPreUpdateFailed, -) from ..proto import wrapper from ._common import ( @@ -339,9 +331,9 @@ def __init__(self) -> None: # init ota-status self._init_boot_control() except NotImplementedError as e: - raise BootControlPlatformUnsupported(module=__name__) from e + raise ota_errors.BootControlPlatformUnsupported(module=__name__) from e except Exception as e: - raise BootControlStartupFailed( + raise ota_errors.BootControlStartupFailed( f"unspecific boot controller startup failure: {e!r}", module=__name__ ) from e @@ -514,7 +506,9 @@ def pre_update(self, version: str, *, standby_as_ref: bool, erase_standby=False) except Exception as e: _err_msg = f"failed on pre_update: {e!r}" logger.exception(_err_msg) - raise BootControlPreUpdateFailed(f"{e!r}", module=__name__) from e + raise ota_errors.BootControlPreUpdateFailed( + f"{e!r}", module=__name__ + ) from e def post_update(self) -> Generator[None, None, None]: try: @@ -554,7 +548,9 @@ def post_update(self) -> Generator[None, None, None]: except Exception as e: _err_msg = f"failed on post_update: {e!r}" logger.exception(_err_msg) - raise BootControlPostUpdateFailed(_err_msg, module=__name__) from e + raise ota_errors.BootControlPostUpdateFailed( + _err_msg, module=__name__ + ) from e def pre_rollback(self): try: @@ -568,7 +564,9 @@ def pre_rollback(self): except Exception as e: _err_msg = f"failed on pre_rollback: {e!r}" logger.exception(_err_msg) - raise BootControlPreRollbackFailed(_err_msg, module=__name__) from e + raise ota_errors.BootControlPreRollbackFailed( + _err_msg, module=__name__ + ) from e def post_rollback(self): try: @@ -577,4 +575,6 @@ def post_rollback(self): except Exception as e: _err_msg = f"failed on post_rollback: {e!r}" logger.exception(_err_msg) - raise BootControlPostRollbackFailed(_err_msg, module=__name__) from e + raise ota_errors.BootControlPostRollbackFailed( + _err_msg, module=__name__ + ) from e diff --git a/otaclient/app/boot_control/_grub.py b/otaclient/app/boot_control/_grub.py index 578f36126..c2a74ee14 100644 --- a/otaclient/app/boot_control/_grub.py +++ b/otaclient/app/boot_control/_grub.py @@ -39,7 +39,7 @@ from pathlib import Path from pprint import pformat -from .. import log_setting +from .. import log_setting, errors as ota_errors from ..common import ( re_symlink_atomic, read_str_from_file, @@ -47,13 +47,6 @@ subprocess_check_output, write_str_to_file_sync, ) -from ..errors import ( - BootControlStartupFailed, - BootControlPostRollbackFailed, - BootControlPostUpdateFailed, - BootControlPreRollbackFailed, - BootControlPreUpdateFailed, -) from ..proto import wrapper from ._common import ( @@ -772,7 +765,7 @@ def __init__(self) -> None: except Exception as e: _err_msg = f"failed on start grub boot controller: {e!r}" logger.error(_err_msg) - raise BootControlStartupFailed(_err_msg, module=__name__) from e + raise ota_errors.BootControlStartupFailed(_err_msg, module=__name__) from e def _update_fstab(self, *, active_slot_fstab: Path, standby_slot_fstab: Path): """Update standby fstab based on active slot's fstab and just installed new stanby fstab. @@ -891,7 +884,9 @@ def pre_update(self, version: str, *, standby_as_ref: bool, erase_standby=False) except Exception as e: _err_msg = f"failed on pre_update: {e!r}" logger.error(_err_msg) - raise BootControlPreUpdateFailed(_err_msg, module=__name__) from e + raise ota_errors.BootControlPreUpdateFailed( + _err_msg, module=__name__ + ) from e def post_update(self) -> Generator[None, None, None]: try: @@ -920,7 +915,9 @@ def post_update(self) -> Generator[None, None, None]: except Exception as e: _err_msg = f"failed on post_update: {e!r}" logger.error(_err_msg) - raise BootControlPostUpdateFailed(_err_msg, module=__name__) from e + raise ota_errors.BootControlPostUpdateFailed( + _err_msg, module=__name__ + ) from e def pre_rollback(self): try: @@ -931,7 +928,9 @@ def pre_rollback(self): except Exception as e: _err_msg = f"failed on pre_rollback: {e!r}" logger.error(_err_msg) - raise BootControlPreRollbackFailed(_err_msg, module=__name__) from e + raise ota_errors.BootControlPreRollbackFailed( + _err_msg, module=__name__ + ) from e def post_rollback(self): try: @@ -942,4 +941,6 @@ def post_rollback(self): except Exception as e: _err_msg = f"failed on pre_rollback: {e!r}" logger.error(_err_msg) - raise BootControlPostRollbackFailed(_err_msg, module=__name__) from e + raise ota_errors.BootControlPostRollbackFailed( + _err_msg, module=__name__ + ) from e diff --git a/otaclient/app/boot_control/_rpi_boot.py b/otaclient/app/boot_control/_rpi_boot.py index f9f4c536e..7317a48de 100644 --- a/otaclient/app/boot_control/_rpi_boot.py +++ b/otaclient/app/boot_control/_rpi_boot.py @@ -20,14 +20,7 @@ from pathlib import Path from typing import Generator -from .. import log_setting -from ..errors import ( - BootControlStartupFailed, - BootControlPostRollbackFailed, - BootControlPostUpdateFailed, - BootControlPreRollbackFailed, - BootControlPreUpdateFailed, -) +from .. import log_setting, errors as ota_errors from ..proto import wrapper from ..common import replace_atomic, subprocess_call @@ -419,7 +412,7 @@ def __init__(self) -> None: except Exception as e: _err_msg = f"failed to start rpi boot controller: {e!r}" logger.error(_err_msg) - raise BootControlStartupFailed(_err_msg, module=__name__) from e + raise ota_errors.BootControlStartupFailed(_err_msg, module=__name__) from e def _copy_kernel_for_standby_slot(self): """Copy the kernel and initrd_img files from current slot /boot @@ -519,7 +512,9 @@ def pre_update(self, version: str, *, standby_as_ref: bool, erase_standby: bool) except Exception as e: _err_msg = f"failed on pre_update: {e!r}" logger.error(_err_msg) - raise BootControlPreUpdateFailed(_err_msg, module=__name__) from e + raise ota_errors.BootControlPreUpdateFailed( + _err_msg, module=__name__ + ) from e def pre_rollback(self): try: @@ -530,7 +525,9 @@ def pre_rollback(self): except Exception as e: _err_msg = f"failed on pre_rollback: {e!r}" logger.error(_err_msg) - raise BootControlPreRollbackFailed(_err_msg, module=__name__) from e + raise ota_errors.BootControlPreRollbackFailed( + _err_msg, module=__name__ + ) from e def post_rollback(self): try: @@ -541,7 +538,9 @@ def post_rollback(self): except Exception as e: _err_msg = f"failed on post_rollback: {e!r}" logger.error(_err_msg) - raise BootControlPostRollbackFailed(_err_msg, module=__name__) from e + raise ota_errors.BootControlPostRollbackFailed( + _err_msg, module=__name__ + ) from e def post_update(self) -> Generator[None, None, None]: try: @@ -556,7 +555,9 @@ def post_update(self) -> Generator[None, None, None]: except Exception as e: _err_msg = f"failed on post_update: {e!r}" logger.error(_err_msg) - raise BootControlPostUpdateFailed(_err_msg, module=__name__) from e + raise ota_errors.BootControlPostUpdateFailed( + _err_msg, module=__name__ + ) from e def on_operation_failure(self): """Failure registering and cleanup at failure."""