mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-24 09:36:31 +00:00
Fix socket detection
This commit is contained in:
parent
9e7b2faac8
commit
3f9f69098b
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user