mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-13 04:06:33 +00:00
fix lint
This commit is contained in:
parent
7437480379
commit
ce920d3e5e
@ -22,7 +22,7 @@ class RestAPI(object):
|
||||
self._handler = None
|
||||
self.server = None
|
||||
|
||||
def registerHost(self, host_controll):
|
||||
def register_host(self, host_controll):
|
||||
"""Register hostcontroll function."""
|
||||
api_host = APIHost(self.config, self.loop, host_controll)
|
||||
|
||||
@ -35,14 +35,14 @@ class RestAPI(object):
|
||||
self.webapp.router.add_get(
|
||||
'/host/network/update', api_host.network_update)
|
||||
|
||||
def registerSupervisor(self, host_controll):
|
||||
def register_supervisor(self, host_controll):
|
||||
"""Register supervisor function."""
|
||||
api_supervisor = APISupervisor(self.config, self.loop, host_controll)
|
||||
|
||||
self.webapp.router.add_get('/supervisor/info', api_supervisor.info)
|
||||
self.webapp.router.add_get('/supervisor/update', api_supervisor.update)
|
||||
|
||||
def registerHomeAssistant(self, dock_homeassistant):
|
||||
def register_homeassistant(self, dock_homeassistant):
|
||||
"""Register homeassistant function."""
|
||||
api_hass = APIHomeAssistant(self.config, self.loop, dock_homeassistant)
|
||||
|
||||
@ -57,7 +57,8 @@ class RestAPI(object):
|
||||
self.server = await self.loop.create_server(
|
||||
self._handler, "0.0.0.0", "80")
|
||||
except OSError as err:
|
||||
_LOGGER.fatal("Failed to create HTTP server at 0.0.0.0:80")
|
||||
_LOGGER.fatal(
|
||||
"Failed to create HTTP server at 0.0.0.0:80 -> %s", err)
|
||||
|
||||
async def stop(self):
|
||||
"""Stop rest api webserver."""
|
||||
|
@ -2,7 +2,7 @@
|
||||
import logging
|
||||
|
||||
from aiohttp import web
|
||||
from aiohttp.web_exceptions import HTTPMethodNotAllowed
|
||||
from aiohttp.web_exceptions import HTTPNotAcceptable
|
||||
|
||||
from ..const import ATTR_VERSION
|
||||
|
||||
@ -16,7 +16,7 @@ class APIHomeAssistant(object):
|
||||
"""Initialize homeassistant rest api part."""
|
||||
self.config = config
|
||||
self.loop = loop
|
||||
self.dock_hass = hass
|
||||
self.dock_hass = dock_hass
|
||||
|
||||
async def info(self, request):
|
||||
"""Return host information."""
|
||||
@ -26,4 +26,4 @@ class APIHomeAssistant(object):
|
||||
|
||||
async def update(self, request):
|
||||
"""Update host OS."""
|
||||
raise HTTPMethodNotAllowed()
|
||||
raise HTTPNotAcceptable()
|
||||
|
@ -2,7 +2,7 @@
|
||||
import logging
|
||||
|
||||
from aiohttp import web
|
||||
from aiohttp.web_exceptions import HTTPOk, HTTPMethodNotAllowed
|
||||
from aiohttp.web_exceptions import HTTPOk, HTTPNotAcceptable
|
||||
|
||||
from ..const import ATTR_VERSION
|
||||
|
||||
@ -23,31 +23,31 @@ class APIHost(object):
|
||||
host_info = await self.host_controll.info()
|
||||
if host_info:
|
||||
return web.json_response(host_info)
|
||||
raise HTTPMethodNotAllowed()
|
||||
raise HTTPNotAcceptable()
|
||||
|
||||
async def reboot(self, request):
|
||||
"""Reboot host."""
|
||||
if await self.host_controll.reboot():
|
||||
raise HTTPOk()
|
||||
raise HTTPMethodNotAllowed()
|
||||
raise HTTPNotAcceptable()
|
||||
|
||||
async def shutdown(self, request):
|
||||
"""Poweroff host."""
|
||||
if await self.host_controll.shutdown():
|
||||
raise HTTPOk()
|
||||
raise HTTPMethodNotAllowed()
|
||||
raise HTTPNotAcceptable()
|
||||
|
||||
async def network_info(self, request):
|
||||
"""Edit network settings."""
|
||||
raise HTTPMethodNotAllowed()
|
||||
raise HTTPNotAcceptable()
|
||||
|
||||
async def network_update(self, request):
|
||||
"""Edit network settings."""
|
||||
raise HTTPMethodNotAllowed()
|
||||
raise HTTPNotAcceptable()
|
||||
|
||||
async def update(self, request):
|
||||
"""Update host OS."""
|
||||
body = await request.json() or {}
|
||||
if await self.host_controll.host_update(body.get(ATTR_VERSION)):
|
||||
raise HTTPOk()
|
||||
raise HTTPMethodNotAllowed()
|
||||
raise HTTPNotAcceptable()
|
||||
|
@ -2,7 +2,7 @@
|
||||
import logging
|
||||
|
||||
from aiohttp import web
|
||||
from aiohttp.web_exceptions import HTTPOk, HTTPMethodNotAllowed
|
||||
from aiohttp.web_exceptions import HTTPOk, HTTPNotAcceptable
|
||||
|
||||
from ..const import ATTR_VERSION, HASSIO_VERSION
|
||||
|
||||
@ -21,7 +21,7 @@ class APISupervisor(object):
|
||||
async def info(self, request):
|
||||
"""Return host information."""
|
||||
return web.json_response({
|
||||
ATTR_VERSION: HASSIO_DOCKER,
|
||||
ATTR_VERSION: HASSIO_VERSION,
|
||||
})
|
||||
|
||||
async def update(self, request):
|
||||
@ -29,4 +29,4 @@ class APISupervisor(object):
|
||||
body = await request.json() or {}
|
||||
if await self.host_controll.supervisor_update(body.get(ATTR_VERSION)):
|
||||
raise HTTPOk()
|
||||
raise HTTPMethodNotAllowed()
|
||||
raise HTTPNotAcceptable()
|
||||
|
@ -54,9 +54,9 @@ class HassIO(object):
|
||||
host_info.get('level'))
|
||||
|
||||
# rest api views
|
||||
self.api.registerHost(self.host_controll)
|
||||
self.api.registerSupervisor(self.host_controll)
|
||||
self.api.registerHomeAssistant(self.homeassistant)
|
||||
self.api.register_host(self.host_controll)
|
||||
self.api.register_supervisor(self.host_controll)
|
||||
self.api.register_homeassistant(self.homeassistant)
|
||||
|
||||
# first start of supervisor?
|
||||
if self.config.homeassistant_tag is None:
|
||||
|
@ -46,7 +46,7 @@ class DockerHomeAssistant(DockerBase):
|
||||
},
|
||||
environment={
|
||||
'HASSIO': api_endpoint,
|
||||
}
|
||||
},
|
||||
volumes={
|
||||
self.config.path_config_docker:
|
||||
{'bind': '/config', 'mode': 'rw'},
|
||||
|
@ -40,6 +40,7 @@ def get_version_from_env(env_list):
|
||||
_LOGGER.error("Can't find VERSION in env")
|
||||
return None
|
||||
|
||||
|
||||
def get_local_ip(loop):
|
||||
"""Retrieve local IP address.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user