mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-01 02:28:28 +02: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:
committed by
Otto Winter
parent
6ccab2bef9
commit
ced28ad006
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user