mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 23:26:29 +00:00
cleanup things
This commit is contained in:
parent
efd30f9460
commit
cd13ecf6d9
@ -38,8 +38,8 @@ class HassIO(object):
|
||||
"""Start HassIO."""
|
||||
await self.supervisor.attach()
|
||||
_LOGGER.info(
|
||||
"Attach to supervisor image %s tag %s", self.supervisor.image,
|
||||
self.supervisor.tag)
|
||||
"Attach to supervisor image %s version %s", self.supervisor.image,
|
||||
self.supervisor.version)
|
||||
|
||||
host_info = await self.host_controll.info()
|
||||
if host_info:
|
||||
|
@ -82,26 +82,13 @@ class DockerBase(object):
|
||||
"""
|
||||
try:
|
||||
self.container = self.dock.containers.get(self.docker_name)
|
||||
self.image, self.tag = self.image = extract_image_name(
|
||||
self.container.attrs['Config']['Image'])
|
||||
self.image = self.container.attrs['Config']['Image']
|
||||
self.version = get_version_from_env(
|
||||
self.container.attrs['Config']['Env'])
|
||||
except (docker.errors.DockerException, KeyError):
|
||||
_LOGGER.fatal(
|
||||
"Can't attach to %s docker container!", self.docker_name)
|
||||
|
||||
async def get_version(self):
|
||||
"""Read VERSION tag from ENV docker.
|
||||
|
||||
Is a coroutine.
|
||||
"""
|
||||
if self.container:
|
||||
try:
|
||||
self.version = get_version_from_env(
|
||||
self.container.attrs['Config']['Env'])
|
||||
except KeyError:
|
||||
_LOGGER.error("Can't read VERSION from docker env.")
|
||||
|
||||
return None
|
||||
|
||||
def run(self):
|
||||
"""Run docker image.
|
||||
|
||||
|
@ -40,11 +40,11 @@ class HostControll(object):
|
||||
try:
|
||||
# send
|
||||
_LOGGER.info("Send '%s' to HostControll.", command)
|
||||
writer.write("{}\n".format(command).encode())
|
||||
|
||||
# receive
|
||||
with async_timeout.timeout(TIMEOUT, loop=self.loop):
|
||||
writer.write("{}\n".format(command).encode())
|
||||
data = await reader.readline()
|
||||
|
||||
response = data.decode().Upper()
|
||||
_LOGGER.info("Receive from HostControll: %s.", response)
|
||||
|
||||
|
@ -9,7 +9,6 @@ from .const import URL_HASSIO_VERSION
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
_RE_VERSION = re.compile(r"VERSION=(.*)")
|
||||
_RE_IMAGE = re.compile(r"(.*):(.*)")
|
||||
|
||||
|
||||
async def fetch_current_versions(websession):
|
||||
@ -32,13 +31,3 @@ def get_version_from_env(env_list):
|
||||
|
||||
_LOGGER.error("Can't find VERSION in env")
|
||||
return None
|
||||
|
||||
|
||||
def extract_image_name(image):
|
||||
"""Extract image name and tag from docker attrs."""
|
||||
data = _RE_IMAGE.match(image)
|
||||
if not data:
|
||||
_LOGGER.error("Invalid docker information: %s", image)
|
||||
return (None, None)
|
||||
|
||||
return (data.group(1), data.group(2))
|
||||
|
Loading…
x
Reference in New Issue
Block a user