Update hassio
This commit is contained in:
parent
13a00f5963
commit
285822b951
|
@ -0,0 +1,17 @@
|
|||
sudo: false
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- python: "3.5"
|
||||
env: TOXENV=py35
|
||||
- python: "3.6"
|
||||
env: TOXENV=py36
|
||||
- python: "3.6-dev"
|
||||
env: TOXENV=py36
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.cache/pip
|
||||
install: pip install -U tox
|
||||
language: python
|
||||
script: tox hassio_api
|
Binary file not shown.
|
@ -3,13 +3,12 @@ import asyncio
|
|||
import logging
|
||||
|
||||
import aiohttp
|
||||
from aiohttp import web
|
||||
import docker
|
||||
|
||||
import .bootstrap
|
||||
import .tools
|
||||
from .docker.homeassistant import DockerHomeAssistant
|
||||
from .const import CONF_HOMEASSISTANT_TAG
|
||||
import hassio.bootstrap as bootstrap
|
||||
import hassio.tools as tools
|
||||
from hassio.const import CONF_HOMEASSISTANT_TAG
|
||||
from hassio.docker.homeassistant import DockerHomeAssistant
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -40,9 +39,9 @@ async def main(loop):
|
|||
while True:
|
||||
current = await tools.fetch_current_versions(websession)
|
||||
if current and CONF_HOMEASSISTANT_TAG in current:
|
||||
if await docker_hass.install(current[CONF_SUPERVISOR_TAG]):
|
||||
if await docker_hass.install(current[CONF_HOMEASSISTANT_TAG]):
|
||||
break
|
||||
_LOGGER.waring("Can't fetch info from github. Retry in 60")
|
||||
_LOGGER.warning("Can't fetch info from github. Retry in 60")
|
||||
await asyncio.sleep(60, loop=loop)
|
||||
|
||||
config.homeassistant_tag = current[CONF_HOMEASSISTANT_TAG]
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Bootstrap HassIO."""
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
@ -7,7 +6,7 @@ import os
|
|||
from colorlog import ColoredFormatter
|
||||
|
||||
from .const import FILE_HASSIO_ADDONS
|
||||
from .version import CoreConfig
|
||||
from .config import CoreConfig
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ from .const import (
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CoreConfig(Object):
|
||||
class CoreConfig(object):
|
||||
"""Hold all config data."""
|
||||
|
||||
def __init__(self, config_file=FILE_HASSIO_CONFIG):
|
||||
|
@ -22,10 +22,10 @@ class CoreConfig(Object):
|
|||
# init or load data
|
||||
if os.path.isfile(self._filename):
|
||||
try:
|
||||
with open(self._filename 'r') as cfile:
|
||||
with open(self._filename, 'r') as cfile:
|
||||
self._data = json.loads(cfile.read())
|
||||
except OSError:
|
||||
_LOGGER.waring("Can't read %s", self._filename)
|
||||
_LOGGER.warning("Can't read %s", self._filename)
|
||||
|
||||
if not self._data:
|
||||
self._data.update({
|
||||
|
@ -35,7 +35,7 @@ class CoreConfig(Object):
|
|||
})
|
||||
|
||||
# update version
|
||||
versions.update({
|
||||
self._data.update({
|
||||
CONF_SUPERVISOR_IMAGE: os.environ['SUPERVISOR_IMAGE'],
|
||||
CONF_SUPERVISOR_TAG: os.environ['SUPERVISOR_TAG'],
|
||||
})
|
||||
|
@ -64,7 +64,7 @@ class CoreConfig(Object):
|
|||
def homeassistant_tag(self, value):
|
||||
"""Set docker homeassistant tag."""
|
||||
self._data[CONF_HOMEASSISTANT_TAG] = value
|
||||
self.store()
|
||||
self.save()
|
||||
|
||||
@property
|
||||
def supervisor_image(self):
|
||||
|
|
|
@ -41,7 +41,7 @@ class DockerBase(object):
|
|||
if tag != "latest":
|
||||
image = self.dock.images.get("{}:{}".format(self.image, tag))
|
||||
image.tag(self.image, tag='latest')
|
||||
except docker.errors.APIError as err:
|
||||
except docker.errors.APIError:
|
||||
_LOGGER.error("Can't pull %s:%s", self.image, tag)
|
||||
return False
|
||||
return True
|
||||
|
@ -70,7 +70,7 @@ class DockerBase(object):
|
|||
|
||||
Return a Future.
|
||||
"""
|
||||
return self.loop.run_in_executor(None, self._run, tag)
|
||||
return self.loop.run_in_executor(None, self._run)
|
||||
|
||||
def _run(self):
|
||||
"""Run docker image.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
"""Init file for HassIO docker object."""
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
import docker
|
||||
|
||||
import . from DockerBase
|
||||
from ..const.py import HASSIO_DOCKER
|
||||
from . import DockerBase
|
||||
from ..const import HASSIO_DOCKER
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
HASS_DOCKER_NAME = 'homeassistant'
|
||||
|
@ -29,7 +29,7 @@ class DockerHomeAssistant(DockerBase):
|
|||
try:
|
||||
self.container = self.dock.containers.run(
|
||||
self.image,
|
||||
name=self.docker_nme,
|
||||
name=self.docker_name,
|
||||
remove=True,
|
||||
network_mode='host',
|
||||
restart_policy={
|
||||
|
@ -43,7 +43,7 @@ class DockerHomeAssistant(DockerBase):
|
|||
self.config.path_ssl_docker:
|
||||
{'bind': '/ssl', 'mode': 'rw'},
|
||||
})
|
||||
except docker.errors.DockerException as err:
|
||||
except docker.errors.DockerException:
|
||||
_LOGGER.error("Can't run %s", self.image)
|
||||
return False
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
"""Tools file for HassIO."""
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
import aiohttp
|
||||
import async_timeout
|
||||
|
||||
from .const import URL_SUPERVISOR_VERSION
|
||||
|
@ -15,8 +13,7 @@ async def fetch_current_versions(websession):
|
|||
try:
|
||||
with async_timeout.timeout(10, loop=websession.loop):
|
||||
async with websession.get(URL_SUPERVISOR_VERSION) as request:
|
||||
return (await request.json())
|
||||
return await request.json()
|
||||
|
||||
except Exception as err: # pylint: disable=broad-except
|
||||
_LOGGER.warning("Can't fetch versions from github! %s", err)
|
||||
return None
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
[MASTER]
|
||||
reports=no
|
||||
|
||||
# Reasons disabled:
|
||||
# locally-disabled - it spams too much
|
||||
# duplicate-code - unavoidable
|
||||
# cyclic-import - doesn't test if both import on load
|
||||
# abstract-class-little-used - prevents from setting right foundation
|
||||
# abstract-class-not-used - is flaky, should not show up but does
|
||||
# unused-argument - generic callbacks and setup methods create a lot of warnings
|
||||
# global-statement - used for the on-demand requirement installation
|
||||
# redefined-variable-type - this is Python, we're duck typing!
|
||||
# too-many-* - are not enforced for the sake of readability
|
||||
# too-few-* - same as too-many-*
|
||||
# abstract-method - with intro of async there are always methods missing
|
||||
|
||||
disable=
|
||||
locally-disabled,
|
||||
duplicate-code,
|
||||
cyclic-import,
|
||||
abstract-class-little-used,
|
||||
abstract-class-not-used,
|
||||
unused-argument,
|
||||
global-statement,
|
||||
redefined-variable-type,
|
||||
too-many-arguments,
|
||||
too-many-branches,
|
||||
too-many-instance-attributes,
|
||||
too-many-locals,
|
||||
too-many-public-methods,
|
||||
too-many-return-statements,
|
||||
too-many-statements,
|
||||
too-many-lines,
|
||||
too-few-public-methods,
|
||||
abstract-method
|
||||
|
||||
[EXCEPTIONS]
|
||||
overgeneral-exceptions=Exception,HomeAssistantError
|
|
@ -34,6 +34,6 @@ setup(
|
|||
'async_timeout',
|
||||
'aiohttp',
|
||||
'docker-py',
|
||||
'colorlog'
|
||||
'colorlog',
|
||||
]
|
||||
)
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
[tox]
|
||||
envlist = lint
|
||||
|
||||
[testenv]
|
||||
setenv =
|
||||
PYTHONPATH = {toxinidir}:{toxinidir}/hassio
|
||||
deps =
|
||||
flake8
|
||||
pylint
|
||||
|
||||
[testenv:lint]
|
||||
basepython = python3
|
||||
ignore_errors = True
|
||||
commands =
|
||||
flake8 hassio
|
||||
pylint hassio
|
Loading…
Reference in New Issue