Docs string and exception message improvements (#1767)

This commit is contained in:
Franck Nijhof 2020-06-02 11:26:33 +02:00 committed by GitHub
parent e50515a17c
commit 9f7e0ecd55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 13 deletions

View File

@ -81,7 +81,7 @@ class Addon(AddonModel):
@property
def ip_address(self) -> IPv4Address:
"""Return IP of Add-on instance."""
"""Return IP of add-on instance."""
return self.instance.ip_address
@property
@ -366,7 +366,7 @@ class Addon(AddonModel):
write_json_file(self.path_options, options)
except vol.Invalid as ex:
_LOGGER.error(
"Add-on %s have wrong options: %s",
"Add-on %s has invalid options: %s",
self.slug,
humanize_error(options, ex),
)
@ -524,7 +524,7 @@ class Addon(AddonModel):
Return a coroutine.
"""
if not self.with_stdin:
_LOGGER.error("Add-on don't support write to stdin!")
_LOGGER.error("Add-on %s does not support writing to stdin!", self.slug)
raise AddonsNotSupportedError()
try:
@ -622,7 +622,7 @@ class Addon(AddonModel):
# If available
if not self._available(data[ATTR_SYSTEM]):
_LOGGER.error("Add-on %s is not available for this Platform", self.slug)
_LOGGER.error("Add-on %s is not available for this platform", self.slug)
raise AddonsNotSupportedError()
# Restore local add-on information
@ -673,7 +673,9 @@ class Addon(AddonModel):
try:
await self.sys_host.apparmor.load_profile(self.slug, profile_file)
except HostAppArmorError:
_LOGGER.error("Can't restore AppArmor profile")
_LOGGER.error(
"Can't restore AppArmor profile for add-on %s", self.slug
)
raise AddonsError() from None
# Run add-on

View File

@ -137,10 +137,10 @@ class APIAddons(CoreSysAttributes):
addon = self.sys_addons.get(addon_slug)
if not addon:
raise APIError("Addon does not exist")
raise APIError(f"Addon {addon_slug} does not exist", addon_slug)
if check_installed and not addon.is_installed:
raise APIError("Addon is not installed")
raise APIError(f"Addon {addon.slug} is not installed")
return addon
@ -398,7 +398,7 @@ class APIAddons(CoreSysAttributes):
"""Return icon from add-on."""
addon: AnyAddon = self._extract_addon(request, check_installed=False)
if not addon.with_icon:
raise APIError("No icon found!")
raise APIError(f"No icon found for add-on {addon.slug}!")
with addon.path_icon.open("rb") as png:
return png.read()
@ -408,7 +408,7 @@ class APIAddons(CoreSysAttributes):
"""Return logo from add-on."""
addon: AnyAddon = self._extract_addon(request, check_installed=False)
if not addon.with_logo:
raise APIError("No logo found!")
raise APIError(f"No logo found for add-on {addon.slug}!")
with addon.path_logo.open("rb") as png:
return png.read()
@ -418,7 +418,7 @@ class APIAddons(CoreSysAttributes):
"""Return changelog from add-on."""
addon: AnyAddon = self._extract_addon(request, check_installed=False)
if not addon.with_changelog:
raise APIError("No changelog found!")
raise APIError(f"No changelog found for add-on {addon.slug}!")
with addon.path_changelog.open("r") as changelog:
return changelog.read()
@ -428,7 +428,7 @@ class APIAddons(CoreSysAttributes):
"""Return documentation from add-on."""
addon: AnyAddon = self._extract_addon(request, check_installed=False)
if not addon.with_documentation:
raise APIError("No documentation found!")
raise APIError(f"No documentation found for add-on {addon.slug}!")
with addon.path_documentation.open("r") as documentation:
return documentation.read()
@ -438,7 +438,7 @@ class APIAddons(CoreSysAttributes):
"""Write to stdin of add-on."""
addon: AnyAddon = self._extract_addon(request)
if not addon.with_stdin:
raise APIError("STDIN not supported by add-on")
raise APIError(f"STDIN not supported the {addon.slug} add-on")
data = await request.read()
await asyncio.shield(addon.write_stdin(data))

View File

@ -97,7 +97,7 @@ class HassOS(CoreSysAttributes):
if cpe.get_product()[0] != "hassos":
raise NotImplementedError()
except NotImplementedError:
_LOGGER.warning("No Home Assistant Operating-System found!")
_LOGGER.warning("No Home Assistant Operating System found!")
return
else:
self._available = True