Skip to content

Commit

Permalink
Merge pull request #35 from home-assistant/dev
Browse files Browse the repository at this point in the history
Release 0.22
  • Loading branch information
pvizeli authored May 8, 2017
2 parents f37589d + 8833845 commit bc6eb5c
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 5 deletions.
1 change: 1 addition & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ Output the raw docker log
- GET `/addons/{addon}/info`
```json
{
"url": "null|url of addon",
"version": "VERSION",
"last_version": "LAST_VERSION",
"state": "started|stopped",
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include LICENSE.md
graft hassio
recursive-exclude * *.py[co]
14 changes: 14 additions & 0 deletions hassio/addons/built-in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"local": {
"slug": "local",
"name": "Local Add-Ons",
"url": "https://home-assistant.io/hassio",
"maintainer": "By our self"
},
"core": {
"slug": "core",
"name": "Built-in Add-Ons",
"url": "https://home-assistant.io/addons",
"maintainer": "Home Assistant authors"
}
}
33 changes: 32 additions & 1 deletion hassio/addons/data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Init file for HassIO addons."""
import copy
import logging
import json
from pathlib import Path, PurePath

import voluptuous as vol
Expand All @@ -13,7 +14,7 @@
FILE_HASSIO_ADDONS, ATTR_NAME, ATTR_VERSION, ATTR_SLUG, ATTR_DESCRIPTON,
ATTR_STARTUP, ATTR_BOOT, ATTR_MAP, ATTR_OPTIONS, ATTR_PORTS, BOOT_AUTO,
DOCKER_REPO, ATTR_SCHEMA, ATTR_IMAGE, MAP_CONFIG, MAP_SSL, MAP_ADDONS,
MAP_BACKUP, ATTR_REPOSITORY)
MAP_BACKUP, ATTR_REPOSITORY, ATTR_URL)
from ..config import Config
from ..tools import read_json_file, write_json_file

Expand Down Expand Up @@ -60,6 +61,9 @@ def read_data_from_repositories(self):
self._read_addons_folder(
self.config.path_addons_local, REPOSITORY_LOCAL)

# add built-in repositories information
self._set_builtin_repositories()

# read custom git repositories
for repository_element in self.config.path_addons_git.iterdir():
if repository_element.is_dir():
Expand Down Expand Up @@ -114,6 +118,29 @@ def _read_addons_folder(self, path, repository):
_LOGGER.warning("Can't read %s -> %s", addon,
humanize_error(addon_config, ex))

def _set_builtin_repositories(self):
"""Add local built-in repository into dataset."""
try:
builtin_file = Path(__file__).parent.joinpath('built-in.json')
builtin_data = read_json_file(builtin_file)
except (OSError, json.JSONDecodeError) as err:
_LOGGER.warning("Can't read built-in.json -> %s", err)
return

# if core addons are available
for data in self._addons_cache.values():
if data[ATTR_REPOSITORY] == REPOSITORY_CORE:
self._repositories_data[REPOSITORY_CORE] = \
builtin_data[REPOSITORY_CORE]
break

# if local addons are available
for data in self._addons_cache.values():
if data[ATTR_REPOSITORY] == REPOSITORY_LOCAL:
self._repositories_data[REPOSITORY_LOCAL] = \
builtin_data[REPOSITORY_LOCAL]
break

def merge_update_config(self):
"""Update local config if they have update.
Expand Down Expand Up @@ -259,6 +286,10 @@ def get_ports(self, addon):
"""Return ports of addon."""
return self._system_data[addon].get(ATTR_PORTS)

def get_url(self, addon):
"""Return url of addon."""
return self._system_data[addon].get(ATTR_URL)

def get_image(self, addon):
"""Return image name of addon."""
addon_data = self._system_data.get(
Expand Down
1 change: 1 addition & 0 deletions hassio/addons/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
vol.Optional(ATTR_MAP, default=[]): [
vol.In([MAP_CONFIG, MAP_SSL, MAP_ADDONS, MAP_BACKUP])
],
vol.Optional(ATTR_URL): vol.Url(),
vol.Required(ATTR_OPTIONS): dict,
vol.Required(ATTR_SCHEMA): {
vol.Coerce(str): vol.Any(ADDON_ELEMENT, [
Expand Down
3 changes: 2 additions & 1 deletion hassio/api/addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .util import api_process, api_process_raw, api_validate
from ..const import (
ATTR_VERSION, ATTR_LAST_VERSION, ATTR_STATE, ATTR_BOOT, ATTR_OPTIONS,
STATE_STOPPED, STATE_STARTED, BOOT_AUTO, BOOT_MANUAL)
ATTR_URL, STATE_STOPPED, STATE_STARTED, BOOT_AUTO, BOOT_MANUAL)

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -53,6 +53,7 @@ async def info(self, request):
ATTR_STATE: await self.addons.state(addon),
ATTR_BOOT: self.addons.get_boot(addon),
ATTR_OPTIONS: self.addons.get_options(addon),
ATTR_URL: self.addons.get_url(addon),
}

@api_process
Expand Down
2 changes: 1 addition & 1 deletion hassio/const.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Const file for HassIO."""
from pathlib import Path

HASSIO_VERSION = '0.21'
HASSIO_VERSION = '0.22'

URL_HASSIO_VERSION = ('https://raw.githubusercontent.com/home-assistant/'
'hassio/master/version.json')
Expand Down
4 changes: 2 additions & 2 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"hassio": "0.21",
"homeassistant": "0.44",
"hassio": "0.22",
"homeassistant": "0.44.1",
"resinos": "0.7",
"resinhup": "0.1",
"generic": "0.3"
Expand Down

0 comments on commit bc6eb5c

Please sign in to comment.