-
Notifications
You must be signed in to change notification settings - Fork 668
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Capture exception if image is missing on run (#4621)
* Retry run if image missing and handle fixup * Fix lint and run error test * Remove retry and just capture exception
- Loading branch information
Showing
12 changed files
with
189 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"""Helper to fix missing image for addon.""" | ||
|
||
import logging | ||
|
||
from ...coresys import CoreSys | ||
from ..const import ContextType, IssueType, SuggestionType | ||
from .base import FixupBase | ||
|
||
_LOGGER: logging.Logger = logging.getLogger(__name__) | ||
|
||
|
||
def setup(coresys: CoreSys) -> FixupBase: | ||
"""Check setup function.""" | ||
return FixupAddonExecuteRepair(coresys) | ||
|
||
|
||
class FixupAddonExecuteRepair(FixupBase): | ||
"""Storage class for fixup.""" | ||
|
||
async def process_fixup(self, reference: str | None = None) -> None: | ||
"""Pull the addons image.""" | ||
addon = self.sys_addons.get(reference, local_only=True) | ||
if not addon: | ||
_LOGGER.info( | ||
"Cannot repair addon %s as it is not installed, dismissing suggestion", | ||
reference, | ||
) | ||
return | ||
|
||
if await addon.instance.exists(): | ||
_LOGGER.info( | ||
"Addon %s does not need repair, dismissing suggestion", reference | ||
) | ||
return | ||
|
||
_LOGGER.info("Installing image for addon %s") | ||
await addon.instance.install(addon.version) | ||
|
||
@property | ||
def suggestion(self) -> SuggestionType: | ||
"""Return a SuggestionType enum.""" | ||
return SuggestionType.EXECUTE_REPAIR | ||
|
||
@property | ||
def context(self) -> ContextType: | ||
"""Return a ContextType enum.""" | ||
return ContextType.ADDON | ||
|
||
@property | ||
def issues(self) -> list[IssueType]: | ||
"""Return a IssueType enum list.""" | ||
return [IssueType.MISSING_IMAGE] | ||
|
||
@property | ||
def auto(self) -> bool: | ||
"""Return if a fixup can be apply as auto fix.""" | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.