mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-21 08:06:30 +00:00
cleanup things
This commit is contained in:
parent
efd30f9460
commit
cd13ecf6d9
@ -38,8 +38,8 @@ class HassIO(object):
|
|||||||
"""Start HassIO."""
|
"""Start HassIO."""
|
||||||
await self.supervisor.attach()
|
await self.supervisor.attach()
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
"Attach to supervisor image %s tag %s", self.supervisor.image,
|
"Attach to supervisor image %s version %s", self.supervisor.image,
|
||||||
self.supervisor.tag)
|
self.supervisor.version)
|
||||||
|
|
||||||
host_info = await self.host_controll.info()
|
host_info = await self.host_controll.info()
|
||||||
if host_info:
|
if host_info:
|
||||||
|
@ -82,26 +82,13 @@ class DockerBase(object):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.container = self.dock.containers.get(self.docker_name)
|
self.container = self.dock.containers.get(self.docker_name)
|
||||||
self.image, self.tag = self.image = extract_image_name(
|
self.image = self.container.attrs['Config']['Image']
|
||||||
self.container.attrs['Config']['Image'])
|
self.version = get_version_from_env(
|
||||||
|
self.container.attrs['Config']['Env'])
|
||||||
except (docker.errors.DockerException, KeyError):
|
except (docker.errors.DockerException, KeyError):
|
||||||
_LOGGER.fatal(
|
_LOGGER.fatal(
|
||||||
"Can't attach to %s docker container!", self.docker_name)
|
"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):
|
def run(self):
|
||||||
"""Run docker image.
|
"""Run docker image.
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ class HostControll(object):
|
|||||||
try:
|
try:
|
||||||
# send
|
# send
|
||||||
_LOGGER.info("Send '%s' to HostControll.", command)
|
_LOGGER.info("Send '%s' to HostControll.", command)
|
||||||
writer.write("{}\n".format(command).encode())
|
|
||||||
|
|
||||||
# receive
|
|
||||||
with async_timeout.timeout(TIMEOUT, loop=self.loop):
|
with async_timeout.timeout(TIMEOUT, loop=self.loop):
|
||||||
|
writer.write("{}\n".format(command).encode())
|
||||||
data = await reader.readline()
|
data = await reader.readline()
|
||||||
|
|
||||||
response = data.decode().Upper()
|
response = data.decode().Upper()
|
||||||
_LOGGER.info("Receive from HostControll: %s.", response)
|
_LOGGER.info("Receive from HostControll: %s.", response)
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ from .const import URL_HASSIO_VERSION
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
_RE_VERSION = re.compile(r"VERSION=(.*)")
|
_RE_VERSION = re.compile(r"VERSION=(.*)")
|
||||||
_RE_IMAGE = re.compile(r"(.*):(.*)")
|
|
||||||
|
|
||||||
|
|
||||||
async def fetch_current_versions(websession):
|
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")
|
_LOGGER.error("Can't find VERSION in env")
|
||||||
return None
|
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