execute subcommands in parent enviornment (resepect http_proxy and

similar)
This commit is contained in:
Fredrik Eriksson 2019-10-25 19:57:50 +02:00
parent 04cbedb9c0
commit 79dd24809d
No known key found for this signature in database
GPG Key ID: 8825C73A0FD1502A

View File

@ -1,17 +1,21 @@
import logging
import os
import subprocess
import time
import sau
def exec_cmd(cmd, timeout=900, env = None):
my_env = os.environ.copy()
if env:
my_env.update(env)
log = logging.getLogger(sau.LOGNAME)
log.debug('Executing "{}"'.format(' '.join(cmd)))
proc = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env = env)
env = my_env)
out = b""
err = b""