1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-20 18:38:59 +00:00

Split build stuff to new repo

This commit is contained in:
pvizeli
2017-04-06 11:52:28 +02:00
parent 4399888ce7
commit 2f47f9aa9b
64 changed files with 0 additions and 1638 deletions

View File

@@ -0,0 +1,42 @@
"""Init file for HassIO homeassistant rest api."""
import asyncio
import logging
from .util import api_process, json_loads
from ..const import ATTR_VERSION, ATTR_CURRENT
_LOGGER = logging.getLogger(__name__)
class APIHomeAssistant(object):
"""Handle rest api for homeassistant functions."""
def __init__(self, config, loop, dock_hass):
"""Initialize homeassistant rest api part."""
self.config = config
self.loop = loop
self.dock_hass = dock_hass
@api_process
async def info(self, request):
"""Return host information."""
info = {
ATTR_VERSION: self.dock_hass.version,
ATTR_CURRENT: self.config.current_homeassistant,
}
return info
@api_process
async def update(self, request):
"""Update host OS."""
body = await request.json(loads=json_loads)
version = body.get(ATTR_VERSION, self.config.current_homeassistant)
if self.dock_hass.in_progress:
raise RuntimeError("Other task is in progress.")
if version == self.dock_hass.version:
raise RuntimeError("%s is already in use.", version)
return await asyncio.shield(self.dock_hass.update(version))