mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-09 10:59:43 +00:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user