1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-10 07:12:21 +01:00

Better symlink support under Windows (#487)

* Better symlink support under Windows

* Conditional loading of ctypes wintypes module

* Shortening comment line for pylint

* Adding plint bypass for Python 3
This commit is contained in:
Guillermo Ruffino
2019-03-23 18:58:25 -03:00
committed by Otto Winter
parent 67c56ab97b
commit d27b01f02c
3 changed files with 171 additions and 19 deletions

View File

@@ -140,16 +140,3 @@ def get_bool_env(var, default=False):
def is_hassio():
return get_bool_env('ESPHOME_IS_HASSIO')
def symlink(src, dst):
if hasattr(os, 'symlink'):
os.symlink(src, dst)
else:
import ctypes
csl = ctypes.windll.kernel32.CreateSymbolicLinkW
csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
csl.restype = ctypes.c_ubyte
flags = 1 if os.path.isdir(src) else 0
if csl(dst, src, flags) == 0:
raise ctypes.WinError()