|
|
@ -2272,6 +2272,20 @@ def process_communicate_or_kill(p, *args, **kwargs):
|
|
|
|
raise
|
|
|
|
raise
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Popen(subprocess.Popen):
|
|
|
|
|
|
|
|
if sys.platform == 'win32':
|
|
|
|
|
|
|
|
_startupinfo = subprocess.STARTUPINFO()
|
|
|
|
|
|
|
|
_startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
_startupinfo = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
|
|
|
|
super(Popen, self).__init__(*args, **kwargs, startupinfo=self._startupinfo)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def communicate_or_kill(self, *args, **kwargs):
|
|
|
|
|
|
|
|
return process_communicate_or_kill(self, *args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_subprocess_encoding():
|
|
|
|
def get_subprocess_encoding():
|
|
|
|
if sys.platform == 'win32' and sys.getwindowsversion()[0] >= 5:
|
|
|
|
if sys.platform == 'win32' and sys.getwindowsversion()[0] >= 5:
|
|
|
|
# For subprocess calls, encode with locale encoding
|
|
|
|
# For subprocess calls, encode with locale encoding
|
|
|
@ -3977,8 +3991,7 @@ def check_executable(exe, args=[]):
|
|
|
|
""" Checks if the given binary is installed somewhere in PATH, and returns its name.
|
|
|
|
""" Checks if the given binary is installed somewhere in PATH, and returns its name.
|
|
|
|
args can be a list of arguments for a short output (like -version) """
|
|
|
|
args can be a list of arguments for a short output (like -version) """
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
process_communicate_or_kill(subprocess.Popen(
|
|
|
|
Popen([exe] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate_or_kill()
|
|
|
|
[exe] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE))
|
|
|
|
|
|
|
|
except OSError:
|
|
|
|
except OSError:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
return exe
|
|
|
|
return exe
|
|
|
@ -3992,10 +4005,9 @@ def get_exe_version(exe, args=['--version'],
|
|
|
|
# STDIN should be redirected too. On UNIX-like systems, ffmpeg triggers
|
|
|
|
# STDIN should be redirected too. On UNIX-like systems, ffmpeg triggers
|
|
|
|
# SIGTTOU if yt-dlp is run in the background.
|
|
|
|
# SIGTTOU if yt-dlp is run in the background.
|
|
|
|
# See https://github.com/ytdl-org/youtube-dl/issues/955#issuecomment-209789656
|
|
|
|
# See https://github.com/ytdl-org/youtube-dl/issues/955#issuecomment-209789656
|
|
|
|
out, _ = process_communicate_or_kill(subprocess.Popen(
|
|
|
|
out, _ = Popen(
|
|
|
|
[encodeArgument(exe)] + args,
|
|
|
|
[encodeArgument(exe)] + args, stdin=subprocess.PIPE,
|
|
|
|
stdin=subprocess.PIPE,
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate_or_kill()
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
|
|
|
|
|
|
|
except OSError:
|
|
|
|
except OSError:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
if isinstance(out, bytes): # Python 2.x
|
|
|
|
if isinstance(out, bytes): # Python 2.x
|
|
|
@ -6155,11 +6167,11 @@ def write_xattr(path, key, value):
|
|
|
|
+ [encodeFilename(path, True)])
|
|
|
|
+ [encodeFilename(path, True)])
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
p = subprocess.Popen(
|
|
|
|
p = Popen(
|
|
|
|
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
|
|
|
|
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
|
|
|
|
except EnvironmentError as e:
|
|
|
|
except EnvironmentError as e:
|
|
|
|
raise XAttrMetadataError(e.errno, e.strerror)
|
|
|
|
raise XAttrMetadataError(e.errno, e.strerror)
|
|
|
|
stdout, stderr = process_communicate_or_kill(p)
|
|
|
|
stdout, stderr = p.communicate_or_kill()
|
|
|
|
stderr = stderr.decode('utf-8', 'replace')
|
|
|
|
stderr = stderr.decode('utf-8', 'replace')
|
|
|
|
if p.returncode != 0:
|
|
|
|
if p.returncode != 0:
|
|
|
|
raise XAttrMetadataError(p.returncode, stderr)
|
|
|
|
raise XAttrMetadataError(p.returncode, stderr)
|
|
|
|