1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-24 12:29:08 +00:00

Add support for logo

This commit is contained in:
Pascal Vizeli
2017-07-20 22:04:44 +02:00
parent 8aec943a5c
commit cd5a09938f
7 changed files with 51 additions and 18 deletions

View File

@@ -11,7 +11,7 @@ from ..const import (
ATTR_URL, ATTR_DESCRIPTON, ATTR_DETACHED, ATTR_NAME, ATTR_REPOSITORY,
ATTR_BUILD, ATTR_AUTO_UPDATE, ATTR_NETWORK, ATTR_HOST_NETWORK, ATTR_SLUG,
ATTR_SOURCE, ATTR_REPOSITORIES, ATTR_ADDONS, ATTR_ARCH, ATTR_MAINTAINER,
ATTR_INSTALLED, BOOT_AUTO, BOOT_MANUAL)
ATTR_INSTALLED, ATTR_LOGO, BOOT_AUTO, BOOT_MANUAL, CONTENT_TYPE_PNG)
from ..validate import DOCKER_PORTS
_LOGGER = logging.getLogger(__name__)
@@ -64,6 +64,7 @@ class APIAddons(object):
ATTR_REPOSITORY: addon.repository,
ATTR_BUILD: addon.need_build,
ATTR_URL: addon.url,
ATTR_LOGO: addon.with_logo,
})
data_repositories = []
@@ -187,3 +188,13 @@ class APIAddons(object):
"""Return logs from addon."""
addon = self._extract_addon(request)
return addon.logs()
@api_process_raw(CONTENT_TYPE_PNG)
def png(self, request):
"""Return logo from addon."""
addon = self._extract_addon(request)
if addon.with_logo:
raise RuntimeError("No image found!")
with addon.path_logo.open('rb') as png:
return png.read()