mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-12 11:46:31 +00:00
Protect version controll
This commit is contained in:
parent
6297eb11a1
commit
84d428e7d4
@ -47,4 +47,7 @@ class APIHost(object):
|
||||
body = await request.json(loads=json_loads)
|
||||
version = body.get(ATTR_VERSION)
|
||||
|
||||
if version == self.host_controll.version:
|
||||
raise RuntimeError("%s is already in use.", version)
|
||||
|
||||
return await self.host_controll.host_update(version=version)
|
||||
|
@ -31,4 +31,7 @@ class APISupervisor(object):
|
||||
body = await request.json(loads=json_loads)
|
||||
version = body.get(ATTR_VERSION, self.config.current_hassio)
|
||||
|
||||
if version == HASSIO_VERSION:
|
||||
raise RuntimeError("%s is already in use.", version)
|
||||
|
||||
return await self.host_controll.supervisor_update(version=version)
|
||||
|
@ -44,7 +44,11 @@ def api_process_hostcontroll(method):
|
||||
if not api.host_controll.active:
|
||||
raise HTTPServiceUnavailable()
|
||||
|
||||
answer = await method(api, *args, **kwargs)
|
||||
try:
|
||||
answer = await method(api, *args, **kwargs)
|
||||
except RuntimeError as err:
|
||||
return api_return_error(message=str(err))
|
||||
|
||||
if isinstance(answer, dict):
|
||||
return api_return_ok(data=answer)
|
||||
elif answer is None:
|
||||
|
@ -33,10 +33,10 @@ class CoreConfig(object):
|
||||
except OSError:
|
||||
_LOGGER.warning("Can't read %s", self._filename)
|
||||
|
||||
# init data
|
||||
if not self._data:
|
||||
self._data.update({
|
||||
HOMEASSISTANT_IMAGE: os.environ['HOMEASSISTANT_REPOSITORY'],
|
||||
HOMEASSISTANT_TAG: None,
|
||||
})
|
||||
|
||||
def save(self):
|
||||
|
@ -49,6 +49,7 @@ class HassIO(object):
|
||||
# hostcontroll
|
||||
host_info = await self.host_controll.info()
|
||||
if host_info:
|
||||
self.host_controll.version = host_info.get('version')
|
||||
_LOGGER.info(
|
||||
"Connected to HostControll. OS: %s Version: %s Hostname: %s "
|
||||
"Feature-lvl: %d", host_info.get('os'),
|
||||
|
@ -26,6 +26,7 @@ class HostControll(object):
|
||||
"""Initialize HostControll socket client."""
|
||||
self.loop = loop
|
||||
self.active = False
|
||||
self.version = None
|
||||
|
||||
mode = os.stat(SOCKET_HC)[stat.ST_MODE]
|
||||
if stat.S_ISSOCK(mode):
|
||||
|
Loading…
x
Reference in New Issue
Block a user