mirror of
https://github.com/yt-dlp/yt-dlp
synced 2025-12-16 22:25:40 +07:00
[utils] Fix bug in 0b9c08b47b
* Cache of `supports_terminal_sequences` must be reset after enabling VT mode * and move `windows_enable_vt_mode` to utils to avoid cyclic imports
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import contextlib
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import warnings
|
||||
import xml.etree.ElementTree as etree
|
||||
@@ -74,17 +72,3 @@ def compat_expanduser(path):
|
||||
return userhome + path[i:]
|
||||
else:
|
||||
compat_expanduser = os.path.expanduser
|
||||
|
||||
|
||||
WINDOWS_VT_MODE = False if compat_os_name == 'nt' else None
|
||||
|
||||
|
||||
def windows_enable_vt_mode(): # TODO: Do this the proper way https://bugs.python.org/issue30075
|
||||
if compat_os_name != 'nt':
|
||||
return
|
||||
global WINDOWS_VT_MODE
|
||||
startupinfo = subprocess.STARTUPINFO()
|
||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
with contextlib.suppress(Exception):
|
||||
subprocess.Popen('', shell=True, startupinfo=startupinfo).wait()
|
||||
WINDOWS_VT_MODE = True
|
||||
|
||||
@@ -55,3 +55,10 @@ def compat_ctypes_WINFUNCTYPE(*args, **kwargs):
|
||||
compat_xpath = lambda xpath: xpath
|
||||
compat_zip = zip
|
||||
workaround_optparse_bug9161 = lambda: None
|
||||
|
||||
|
||||
def __getattr__(name):
|
||||
if name in ('WINDOWS_VT_MODE', 'windows_enable_vt_mode'):
|
||||
from .. import utils
|
||||
return getattr(utils, name)
|
||||
raise AttributeError(name)
|
||||
|
||||
Reference in New Issue
Block a user