Add encoding to run_program and popen_program

This commit is contained in:
2Shirt 2019-03-20 12:57:56 -06:00
parent 877db91cb6
commit 95338f1df7
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -437,6 +437,9 @@ def ping(addr='google.com'):
def popen_program(cmd, pipe=False, minimized=False, shell=False, **kwargs):
"""Run program and return a subprocess.Popen object."""
cmd_kwargs = {'args': cmd, 'shell': shell}
for kw in ('encoding', 'errors'):
if kw in kwargs:
cmd_kwargs[kw] = kwargs[kw]
if minimized:
startupinfo = subprocess.STARTUPINFO()
@ -506,6 +509,9 @@ def run_program(cmd, check=True, pipe=True, shell=False, **kwargs):
cmd = ' '.join(cmd)
cmd_kwargs = {'args': cmd, 'check': check, 'shell': shell}
for kw in ('encoding', 'errors'):
if kw in kwargs:
cmd_kwargs[kw] = kwargs[kw]
if pipe:
cmd_kwargs.update({