mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-27 02:56:31 +00:00
Fix socket detection
This commit is contained in:
parent
9e7b2faac8
commit
3f9f69098b
@ -2,6 +2,7 @@
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import stat
|
||||||
|
|
||||||
from colorlog import ColoredFormatter
|
from colorlog import ColoredFormatter
|
||||||
|
|
||||||
@ -69,7 +70,8 @@ def check_environment():
|
|||||||
_LOGGER.fatal("Can't find %s in env!", key)
|
_LOGGER.fatal("Can't find %s in env!", key)
|
||||||
return False
|
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!")
|
_LOGGER.fatal("Can't find docker socket!")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import stat
|
||||||
|
|
||||||
from .const import SOCKET_HC
|
from .const import SOCKET_HC
|
||||||
|
|
||||||
@ -14,13 +15,18 @@ class HostControll(object):
|
|||||||
def __init__(self, loop):
|
def __init__(self, loop):
|
||||||
"""Initialize HostControll socket client."""
|
"""Initialize HostControll socket client."""
|
||||||
self.loop = loop
|
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):
|
async def _send_command(self, command):
|
||||||
"""Send command to host.
|
"""Send command to host.
|
||||||
|
|
||||||
Is a coroutine.
|
Is a coroutine.
|
||||||
"""
|
"""
|
||||||
if not os.path.isfile(SOCKET_HC):
|
if not self.active:
|
||||||
return
|
return
|
||||||
|
|
||||||
reader, writer = await self.loop.create_unix_connection(SOCKET_HC)
|
reader, writer = await self.loop.create_unix_connection(SOCKET_HC)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user