7
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-05-28 11:50:49 +00:00

temp: shim shlex.join for Python 3.7 compatability

This commit is contained in:
Kyle McCormick 2022-07-25 11:34:13 -04:00 committed by Régis Behmo
parent 6a3138152f
commit 8345b7ab93

View File

@ -202,7 +202,7 @@ def is_a_tty() -> bool:
def execute(*command: str) -> int:
click.echo(fmt.command(shlex.join(command)))
click.echo(fmt.command(_shlex_join(*command)))
with subprocess.Popen(command) as p:
try:
result = p.wait(timeout=None)
@ -221,6 +221,19 @@ def execute(*command: str) -> int:
return result
def _shlex_join(*split_command: str) -> str:
"""
Return a shell-escaped string from *split_command.
TODO: REMOVE THIS FUNCTION AFTER 2023-06-27.
This function is a shim for the ``shlex.join`` standard library function,
which becomes available in Python 3.8 The end-of-life date for Python 3.7
is in Jan 2023 (https://endoflife.date/python). After that point, it
would be good to delete this function and just use Py3.8's ``shlex.join``.
"""
return " ".join(shlex.quote(arg) for arg in split_command)
def check_output(*command: str) -> bytes:
literal_command = " ".join(command)
click.echo(fmt.command(literal_command))