shell_command: enable stderr if a callback is set

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-03-07 09:11:11 -05:00
parent 15890b9e87
commit d20631e69f
1 changed files with 4 additions and 2 deletions

View File

@ -161,8 +161,10 @@ class ShellCommand:
return asyncio.subprocess.SubprocessStreamProtocol( return asyncio.subprocess.SubprocessStreamProtocol(
limit=2**20, loop=loop) limit=2**20, loop=loop)
try: try:
errpipe = asyncio.subprocess.PIPE if self.log_stderr \ if self.std_err_cb is not None or self.log_stderr:
else asyncio.subprocess.STDOUT errpipe = asyncio.subprocess.PIPE
else:
errpipe = asyncio.subprocess.STDOUT
transport, protocol = await loop.subprocess_exec( transport, protocol = await loop.subprocess_exec(
protocol_factory, *self.command, protocol_factory, *self.command,
stdout=asyncio.subprocess.PIPE, stdout=asyncio.subprocess.PIPE,