mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-10-22 10:09:36 +00:00
Extend API to view logs from docker (#11)
* Extend API to view logs from docker * Pump version * Fix lint * Change to raw api output * Fix aiohttp response * Fix aiohttp response p2 * Fix body convert * Add attach to docker addon
This commit is contained in:
@@ -4,7 +4,7 @@ import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from .util import api_process, api_validate
|
||||
from .util import api_process, api_process_raw, api_validate
|
||||
from ..const import ATTR_VERSION, ATTR_CURRENT
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -17,17 +17,17 @@ SCHEMA_VERSION = vol.Schema({
|
||||
class APIHomeAssistant(object):
|
||||
"""Handle rest api for homeassistant functions."""
|
||||
|
||||
def __init__(self, config, loop, dock_hass):
|
||||
def __init__(self, config, loop, homeassistant):
|
||||
"""Initialize homeassistant rest api part."""
|
||||
self.config = config
|
||||
self.loop = loop
|
||||
self.dock_hass = dock_hass
|
||||
self.homeassistant = homeassistant
|
||||
|
||||
@api_process
|
||||
async def info(self, request):
|
||||
"""Return host information."""
|
||||
info = {
|
||||
ATTR_VERSION: self.dock_hass.version,
|
||||
ATTR_VERSION: self.homeassistant.version,
|
||||
ATTR_CURRENT: self.config.current_homeassistant,
|
||||
}
|
||||
|
||||
@@ -39,11 +39,19 @@ class APIHomeAssistant(object):
|
||||
body = await api_validate(SCHEMA_VERSION, request)
|
||||
version = body.get(ATTR_VERSION, self.config.current_homeassistant)
|
||||
|
||||
if self.dock_hass.in_progress:
|
||||
if self.homeassistant.in_progress:
|
||||
raise RuntimeError("Other task is in progress")
|
||||
|
||||
if version == self.dock_hass.version:
|
||||
if version == self.homeassistant.version:
|
||||
raise RuntimeError("Version is already in use")
|
||||
|
||||
return await asyncio.shield(
|
||||
self.dock_hass.update(version), loop=self.loop)
|
||||
self.homeassistant.update(version), loop=self.loop)
|
||||
|
||||
@api_process_raw
|
||||
def logs(self, request):
|
||||
"""Return homeassistant docker logs.
|
||||
|
||||
Return a coroutine.
|
||||
"""
|
||||
return self.homeassistant.logs()
|
||||
|
Reference in New Issue
Block a user