Merge pull request #49 from home-assistant/dev

Release 0.26
This commit is contained in:
Pascal Vizeli 2017-05-15 00:26:30 +02:00 committed by GitHub
commit 7cb72b55a8
12 changed files with 57 additions and 32 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "home-assistant-polymer"]
path = home-assistant-polymer
url = https://github.com/home-assistant/home-assistant-polymer

View File

@ -13,8 +13,8 @@ from .validate import (
from ..const import ( from ..const import (
FILE_HASSIO_ADDONS, ATTR_NAME, ATTR_VERSION, ATTR_SLUG, ATTR_DESCRIPTON, FILE_HASSIO_ADDONS, ATTR_NAME, ATTR_VERSION, ATTR_SLUG, ATTR_DESCRIPTON,
ATTR_STARTUP, ATTR_BOOT, ATTR_MAP, ATTR_OPTIONS, ATTR_PORTS, BOOT_AUTO, ATTR_STARTUP, ATTR_BOOT, ATTR_MAP, ATTR_OPTIONS, ATTR_PORTS, BOOT_AUTO,
DOCKER_REPO, ATTR_SCHEMA, ATTR_IMAGE, MAP_CONFIG, MAP_SSL, MAP_ADDONS, ATTR_SCHEMA, ATTR_IMAGE, MAP_CONFIG, MAP_SSL, MAP_ADDONS, MAP_BACKUP,
MAP_BACKUP, ATTR_REPOSITORY, ATTR_URL, ATTR_ARCH, ATTR_LOCATON) ATTR_REPOSITORY, ATTR_URL, ATTR_ARCH, ATTR_LOCATON)
from ..config import Config from ..config import Config
from ..tools import read_json_file, write_json_file from ..tools import read_json_file, write_json_file
@ -308,28 +308,20 @@ class AddonsData(Config):
addon, self._addons_cache.get(addon) addon, self._addons_cache.get(addon)
) )
# core repository
if addon_data[ATTR_REPOSITORY] == REPOSITORY_CORE:
return "{}/{}-addon-{}".format(
DOCKER_REPO, self.arch, addon_data[ATTR_SLUG])
# Repository with dockerhub images # Repository with dockerhub images
if ATTR_IMAGE in addon_data: if ATTR_IMAGE in addon_data:
return addon_data[ATTR_IMAGE].format(arch=self.arch) return addon_data[ATTR_IMAGE].format(arch=self.arch)
# Local build addon # local build
if addon_data[ATTR_REPOSITORY] == REPOSITORY_LOCAL: return "{}/{}-addon-{}".format(
return "local/{}-addon-{}".format(self.arch, addon_data[ATTR_SLUG]) addon_data[ATTR_REPOSITORY], self.arch, addon_data[ATTR_SLUG])
_LOGGER.error("No image for %s", addon)
def need_build(self, addon): def need_build(self, addon):
"""Return True if this addon need a local build.""" """Return True if this addon need a local build."""
addon_data = self._system_data.get( addon_data = self._system_data.get(
addon, self._addons_cache.get(addon) addon, self._addons_cache.get(addon)
) )
return addon_data[ATTR_REPOSITORY] == REPOSITORY_LOCAL \ return ATTR_IMAGE not in addon_data
and not addon_data.get(ATTR_IMAGE)
def map_config(self, addon): def map_config(self, addon):
"""Return True if config map is needed.""" """Return True if config map is needed."""

View File

@ -70,10 +70,10 @@ def validate_options(raw_schema):
try: try:
if isinstance(typ, list): if isinstance(typ, list):
# nested value # nested value
options[key] = _nested_validate(typ[0], value) options[key] = _nested_validate(typ[0], value, key)
else: else:
# normal value # normal value
options[key] = _single_validate(typ, value) options[key] = _single_validate(typ, value, key)
except (IndexError, KeyError): except (IndexError, KeyError):
raise vol.Invalid( raise vol.Invalid(
"Type error for {}.".format(key)) from None "Type error for {}.".format(key)) from None
@ -84,12 +84,12 @@ def validate_options(raw_schema):
# pylint: disable=no-value-for-parameter # pylint: disable=no-value-for-parameter
def _single_validate(typ, value): def _single_validate(typ, value, key):
"""Validate a single element.""" """Validate a single element."""
try: try:
# if required argument # if required argument
if value is None: if value is None:
raise vol.Invalid("A required argument is not set!") raise vol.Invalid("Missing required option '{}'.".format(key))
if typ == V_STR: if typ == V_STR:
return str(value) return str(value)
@ -104,13 +104,13 @@ def _single_validate(typ, value):
elif typ == V_URL: elif typ == V_URL:
return vol.Url()(value) return vol.Url()(value)
raise vol.Invalid("Fatal error for {}.".format(value)) raise vol.Invalid("Fatal error for {} type {}.".format(key, typ))
except ValueError: except ValueError:
raise vol.Invalid( raise vol.Invalid(
"Type {} error for {}.".format(typ, value)) from None "Type {} error for '{}' on {}.".format(typ, value, key)) from None
def _nested_validate(typ, data_list): def _nested_validate(typ, data_list, key):
"""Validate nested items.""" """Validate nested items."""
options = [] options = []
@ -123,10 +123,10 @@ def _nested_validate(typ, data_list):
raise vol.Invalid( raise vol.Invalid(
"Unknown nested options {}.".format(c_key)) "Unknown nested options {}.".format(c_key))
c_options[c_key] = _single_validate(typ[c_key], c_value) c_options[c_key] = _single_validate(typ[c_key], c_value, c_key)
options.append(c_options) options.append(c_options)
# normal list # normal list
else: else:
options.append(_single_validate(typ, element)) options.append(_single_validate(typ, element, key))
return options return options

View File

@ -1,5 +1,6 @@
"""Init file for HassIO rest api.""" """Init file for HassIO rest api."""
import logging import logging
from pathlib import Path
from aiohttp import web from aiohttp import web
@ -96,6 +97,13 @@ class RestAPI(object):
self.webapp.router.add_post('/security/totp', api_security.totp) self.webapp.router.add_post('/security/totp', api_security.totp)
self.webapp.router.add_post('/security/session', api_security.session) self.webapp.router.add_post('/security/session', api_security.session)
def register_panel(self):
"""Register panel for homeassistant."""
panel_dir = Path(__file__).parents[1].joinpath('panel')
self.webapp.router.register_resource(
web.StaticResource('/panel', str(panel_dir)))
async def start(self): async def start(self):
"""Run rest api webserver.""" """Run rest api webserver."""
self._handler = self.webapp.make_handler(loop=self.loop) self._handler = self.webapp.make_handler(loop=self.loop)

View File

@ -1,7 +1,7 @@
"""Const file for HassIO.""" """Const file for HassIO."""
from pathlib import Path from pathlib import Path
HASSIO_VERSION = '0.25' HASSIO_VERSION = '0.26'
URL_HASSIO_VERSION = ('https://raw.githubusercontent.com/home-assistant/' URL_HASSIO_VERSION = ('https://raw.githubusercontent.com/home-assistant/'
'hassio/master/version.json') 'hassio/master/version.json')
@ -10,8 +10,6 @@ URL_HASSIO_VERSION_BETA = ('https://raw.githubusercontent.com/home-assistant/'
URL_HASSIO_ADDONS = 'https://github.com/home-assistant/hassio-addons' URL_HASSIO_ADDONS = 'https://github.com/home-assistant/hassio-addons'
DOCKER_REPO = "homeassistant"
HASSIO_SHARE = Path("/data") HASSIO_SHARE = Path("/data")
RUN_UPDATE_INFO_TASKS = 28800 RUN_UPDATE_INFO_TASKS = 28800

View File

@ -74,6 +74,7 @@ class HassIO(object):
self.api.register_homeassistant(self.homeassistant) self.api.register_homeassistant(self.homeassistant)
self.api.register_addons(self.addons) self.api.register_addons(self.addons)
self.api.register_security() self.api.register_security()
self.api.register_panel()
# schedule api session cleanup # schedule api session cleanup
self.scheduler.register_task( self.scheduler.register_task(

View File

@ -51,13 +51,13 @@ class DockerBase(object):
_LOGGER.info("Pull image %s tag %s.", self.image, tag) _LOGGER.info("Pull image %s tag %s.", self.image, tag)
image = self.dock.images.pull("{}:{}".format(self.image, tag)) image = self.dock.images.pull("{}:{}".format(self.image, tag))
self.version = tag
image.tag(self.image, tag='latest') image.tag(self.image, tag='latest')
self.version = get_version_from_env(image.attrs['Config']['Env'])
_LOGGER.info("Tag image %s with version %s as latest",
self.image, self.version)
except docker.errors.APIError as err: except docker.errors.APIError as err:
_LOGGER.error("Can't install %s:%s -> %s.", self.image, tag, err) _LOGGER.error("Can't install %s:%s -> %s.", self.image, tag, err)
return False return False
_LOGGER.info("Tag image %s with version %s as latest", self.image, tag)
return True return True
def exists(self): def exists(self):

View File

@ -159,12 +159,14 @@ class DockerAddon(DockerBase):
image = self.dock.images.build( image = self.dock.images.build(
path=str(build_dir), tag=build_tag, pull=True) path=str(build_dir), tag=build_tag, pull=True)
_LOGGER.info("Build %s done", build_tag) self.version = tag
image.tag(self.image, tag='latest') image.tag(self.image, tag='latest')
except (docker.errors.DockerException, TypeError) as err: except (docker.errors.DockerException, TypeError) as err:
_LOGGER.error("Can't build %s -> %s", build_tag, err) _LOGGER.error("Can't build %s -> %s", build_tag, err)
return False return False
_LOGGER.info("Build %s done", build_tag)
return True return True
finally: finally:

File diff suppressed because one or more lines are too long

Binary file not shown.

@ -0,0 +1 @@
Subproject commit a341ccf9440fc2028dff54d569e7f5897bf42b2f

View File

@ -1,5 +1,5 @@
{ {
"hassio": "0.25", "hassio": "0.26",
"homeassistant": "0.44.2", "homeassistant": "0.44.2",
"resinos": "0.7", "resinos": "0.7",
"resinhup": "0.1", "resinhup": "0.1",