allow to pass logger to _subprocess

This commit is contained in:
iLLiCiTiT 2020-10-15 16:03:20 +02:00
parent ffa16729df
commit 63b7a2a244

View file

@ -81,8 +81,7 @@ def get_ffmpeg_tool_path(tool="ffmpeg"):
# Special naming case for subprocess since its a built-in method.
def _subprocess(*args, **kwargs):
"""Convenience method for getting output errors for subprocess."""
def _subprocess(*args, logger=None, **kwargs):
# Get environents from kwarg or use current process environments if were
# not passed.
@ -90,6 +89,10 @@ def _subprocess(*args, **kwargs):
# Make sure environment contains only strings
filtered_env = {k: str(v) for k, v in env.items()}
# Use lib's logger if was not passed with kwargs.
if not logger:
logger = log
# set overrides
kwargs['stdout'] = kwargs.get('stdout', subprocess.PIPE)
kwargs['stderr'] = kwargs.get('stderr', subprocess.STDOUT)