Skip to content

Commit

Permalink
s/kwargs/other_popen_kwargs/
Browse files Browse the repository at this point in the history
  • Loading branch information
cottsay committed Dec 10, 2021
1 parent 5c6f2ee commit a93eb41
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions colcon_core/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def run(
stderr_callback: Callable[[bytes], None],
*,
use_pty: Optional[bool] = None,
**kwargs: Mapping[str, Any]
**other_popen_kwargs: Mapping[str, Any]
) -> subprocess.CompletedProcess:
"""
Run the command described by args.
Expand Down Expand Up @@ -80,13 +80,13 @@ async def run(

rc, _, _ = await _async_check_call(
args, stdout_callback, stderr_callback,
use_pty=use_pty, **kwargs)
use_pty=use_pty, **other_popen_kwargs)
return subprocess.CompletedProcess(args, rc)


async def check_output(
args: Sequence[str],
**kwargs: Mapping[str, Any]
**other_popen_kwargs: Mapping[str, Any]
) -> subprocess.CompletedProcess:
"""
Get the output of an invoked command.
Expand All @@ -100,7 +100,8 @@ async def check_output(
:rtype: str
"""
rc, stdout_data, stderr_data = await _async_check_call(
args, subprocess.PIPE, subprocess.PIPE, use_pty=False, **kwargs)
args, subprocess.PIPE, subprocess.PIPE, use_pty=False,
**other_popen_kwargs)
if rc:
stderr_data = stderr_data.decode(errors='replace')
assert not rc, \
Expand All @@ -109,11 +110,12 @@ async def check_output(


async def _async_check_call(
args, stdout_callback, stderr_callback, *, use_pty=None, **kwargs
args, stdout_callback, stderr_callback, *, use_pty=None,
**other_popen_kwargs
):
"""Coroutine running the command and invoking the callbacks."""
# choose function to create subprocess
if not kwargs.pop('shell', False):
if not other_popen_kwargs.pop('shell', False):
create_subprocess = asyncio.create_subprocess_exec
else:
args = [' '.join([escape_shell_argument(a) for a in args])]
Expand All @@ -133,7 +135,7 @@ async def _async_check_call(
stderr_descriptor, stderr = pty.openpty()

process = await create_subprocess(
*args, stdout=stdout, stderr=stderr, **kwargs)
*args, stdout=stdout, stderr=stderr, **other_popen_kwargs)

# read pipes concurrently
callbacks = []
Expand Down

0 comments on commit a93eb41

Please sign in to comment.