Add more addons functions. (#91)

* Add more addons functions.

* fix lint

* fix lint p2

* Allow more customable network settings

* fix lint

* change point of validate

* fix lint

* fix handling

* fix lint & validate data before write
This commit is contained in:
Pascal Vizeli
2017-07-06 23:40:49 +02:00
committed by GitHub
parent f52d1c4509
commit 7186f5a8c0
14 changed files with 175 additions and 62 deletions

View File

@@ -1,5 +1,4 @@
"""Init file for HassIO addon docker object."""
from contextlib import suppress
import logging
from pathlib import Path
import shutil
@@ -21,7 +20,7 @@ class DockerAddon(DockerBase):
def __init__(self, config, loop, dock, addon):
"""Initialize docker homeassistant wrapper."""
super().__init__(
config, loop, dock, image=addon.image)
config, loop, dock, image=addon.image, timeout=addon.timeout)
self.addon = addon
@property
@@ -249,17 +248,5 @@ class DockerAddon(DockerBase):
Addons prepare some thing on start and that is normaly not repeatable.
Need run inside executor.
"""
try:
container = self.dock.containers.get(self.name)
except docker.errors.DockerException:
return False
# for restart it need to run!
if container.status != 'running':
return False
_LOGGER.info("Restart %s", self.image)
with suppress(docker.errors.DockerException):
container.stop(timeout=15)
self._stop()
return self._run()