Return a error on update with own version (#124)

Return a error on update with own version
This commit is contained in:
Pascal Vizeli
2017-08-02 16:59:38 +02:00
committed by GitHub
parent 3809f20c6a
commit 8afde1e881
7 changed files with 92 additions and 51 deletions

View File

@@ -65,20 +65,19 @@ class APIHomeAssistant(object):
body = await api_validate(SCHEMA_VERSION, request)
version = body.get(ATTR_VERSION, self.config.last_homeassistant)
if self.homeassistant.in_progress:
raise RuntimeError("Other task is in progress")
if version == self.homeassistant.version:
raise RuntimeError("Version {} is already in use".format(version))
return await asyncio.shield(
self.homeassistant.update(version), loop=self.loop)
@api_process
async def restart(self, request):
"""Restart homeassistant."""
if self.homeassistant.in_progress:
raise RuntimeError("Other task is in progress")
def restart(self, request):
"""Restart homeassistant.
return await asyncio.shield(
self.homeassistant.restart(), loop=self.loop)
Return a coroutine.
"""
return asyncio.shield(self.homeassistant.restart(), loop=self.loop)
@api_process_raw(CONTENT_TYPE_BINARY)
def logs(self, request):