mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-17 22:51:45 +00:00
[compat] Rename shlex_quote and remove unused subprocess_check_output
This commit is contained in:
parent
28b4f73620
commit
702ccf2dc0
@ -341,9 +341,9 @@ except ImportError: # Python 2
|
|||||||
return parsed_result
|
return parsed_result
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from shlex import quote as shlex_quote
|
from shlex import quote as compat_shlex_quote
|
||||||
except ImportError: # Python < 3.3
|
except ImportError: # Python < 3.3
|
||||||
def shlex_quote(s):
|
def compat_shlex_quote(s):
|
||||||
if re.match(r'^[-_\w./]+$', s):
|
if re.match(r'^[-_\w./]+$', s):
|
||||||
return s
|
return s
|
||||||
else:
|
else:
|
||||||
@ -466,18 +466,6 @@ else:
|
|||||||
print(s)
|
print(s)
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
subprocess_check_output = subprocess.check_output
|
|
||||||
except AttributeError:
|
|
||||||
def subprocess_check_output(*args, **kwargs):
|
|
||||||
assert 'input' not in kwargs
|
|
||||||
p = subprocess.Popen(*args, stdout=subprocess.PIPE, **kwargs)
|
|
||||||
output, _ = p.communicate()
|
|
||||||
ret = p.poll()
|
|
||||||
if ret:
|
|
||||||
raise subprocess.CalledProcessError(ret, p.args, output=output)
|
|
||||||
return output
|
|
||||||
|
|
||||||
if sys.version_info < (3, 0) and sys.platform == 'win32':
|
if sys.version_info < (3, 0) and sys.platform == 'win32':
|
||||||
def compat_getpass(prompt, *args, **kwargs):
|
def compat_getpass(prompt, *args, **kwargs):
|
||||||
if isinstance(prompt, compat_str):
|
if isinstance(prompt, compat_str):
|
||||||
@ -635,6 +623,7 @@ __all__ = [
|
|||||||
'compat_parse_qs',
|
'compat_parse_qs',
|
||||||
'compat_print',
|
'compat_print',
|
||||||
'compat_setenv',
|
'compat_setenv',
|
||||||
|
'compat_shlex_quote',
|
||||||
'compat_shlex_split',
|
'compat_shlex_split',
|
||||||
'compat_socket_create_connection',
|
'compat_socket_create_connection',
|
||||||
'compat_str',
|
'compat_str',
|
||||||
@ -656,7 +645,5 @@ __all__ = [
|
|||||||
'compat_urlretrieve',
|
'compat_urlretrieve',
|
||||||
'compat_xml_parse_error',
|
'compat_xml_parse_error',
|
||||||
'compat_xpath',
|
'compat_xpath',
|
||||||
'shlex_quote',
|
|
||||||
'subprocess_check_output',
|
|
||||||
'workaround_optparse_bug9161',
|
'workaround_optparse_bug9161',
|
||||||
]
|
]
|
||||||
|
@ -3,7 +3,7 @@ from __future__ import unicode_literals
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from .common import PostProcessor
|
from .common import PostProcessor
|
||||||
from ..compat import shlex_quote
|
from ..compat import compat_shlex_quote
|
||||||
from ..utils import PostProcessingError
|
from ..utils import PostProcessingError
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ class ExecAfterDownloadPP(PostProcessor):
|
|||||||
if '{}' not in cmd:
|
if '{}' not in cmd:
|
||||||
cmd += ' {}'
|
cmd += ' {}'
|
||||||
|
|
||||||
cmd = cmd.replace('{}', shlex_quote(information['filepath']))
|
cmd = cmd.replace('{}', compat_shlex_quote(information['filepath']))
|
||||||
|
|
||||||
self._downloader.to_screen('[exec] Executing command: %s' % cmd)
|
self._downloader.to_screen('[exec] Executing command: %s' % cmd)
|
||||||
retCode = subprocess.call(cmd, shell=True)
|
retCode = subprocess.call(cmd, shell=True)
|
||||||
|
@ -42,6 +42,7 @@ from .compat import (
|
|||||||
compat_http_client,
|
compat_http_client,
|
||||||
compat_kwargs,
|
compat_kwargs,
|
||||||
compat_parse_qs,
|
compat_parse_qs,
|
||||||
|
compat_shlex_quote,
|
||||||
compat_socket_create_connection,
|
compat_socket_create_connection,
|
||||||
compat_str,
|
compat_str,
|
||||||
compat_struct_pack,
|
compat_struct_pack,
|
||||||
@ -52,7 +53,6 @@ from .compat import (
|
|||||||
compat_urllib_request,
|
compat_urllib_request,
|
||||||
compat_urlparse,
|
compat_urlparse,
|
||||||
compat_xpath,
|
compat_xpath,
|
||||||
shlex_quote,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from .socks import (
|
from .socks import (
|
||||||
@ -1977,7 +1977,7 @@ def ytdl_is_updateable():
|
|||||||
|
|
||||||
def args_to_str(args):
|
def args_to_str(args):
|
||||||
# Get a short string representation for a subprocess command
|
# Get a short string representation for a subprocess command
|
||||||
return ' '.join(shlex_quote(a) for a in args)
|
return ' '.join(compat_shlex_quote(a) for a in args)
|
||||||
|
|
||||||
|
|
||||||
def error_to_compat_str(err):
|
def error_to_compat_str(err):
|
||||||
|
Loading…
Reference in New Issue
Block a user