diff --git a/hassio_api/hassio/bootstrap.py b/hassio_api/hassio/bootstrap.py index 1583ee214..b48589ce9 100644 --- a/hassio_api/hassio/bootstrap.py +++ b/hassio_api/hassio/bootstrap.py @@ -2,6 +2,7 @@ import json import logging import os +import stat from colorlog import ColoredFormatter @@ -69,7 +70,8 @@ def check_environment(): _LOGGER.fatal("Can't find %s in env!", key) return False - if not os.path.isfile(SOCKET_DOCKER): + mode = os.stat(SOCKET_DOCKER)[stat.ST_MODE] + if not stat.S_ISSOCK(mode): _LOGGER.fatal("Can't find docker socket!") return False diff --git a/hassio_api/hassio/host_controll.py b/hassio_api/hassio/host_controll.py index 44feb4077..c3bc31dd0 100644 --- a/hassio_api/hassio/host_controll.py +++ b/hassio_api/hassio/host_controll.py @@ -2,6 +2,7 @@ import json import logging import os +import stat from .const import SOCKET_HC @@ -14,13 +15,18 @@ class HostControll(object): def __init__(self, loop): """Initialize HostControll socket client.""" self.loop = loop + self.active = False + + mode = os.stat(SOCKET_HC)[stat.ST_MODE] + if stat.S_ISSOCK(mode): + self.active = True async def _send_command(self, command): """Send command to host. Is a coroutine. """ - if not os.path.isfile(SOCKET_HC): + if not self.active: return reader, writer = await self.loop.create_unix_connection(SOCKET_HC)