run_cmd: Default to environment from global context

If env is not provided, use the global context environment. Then drop
all every passing of that parameter.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Jan Kiszka
2018-08-24 19:18:00 +02:00
committed by Daniel Wagner
parent f5cea27269
commit 86dc584284
3 changed files with 6 additions and 9 deletions

View File

@@ -31,6 +31,7 @@ import tempfile
import asyncio
import errno
from subprocess import Popen, PIPE
from .context import get_context
__license__ = 'MIT'
__copyright__ = 'Copyright (c) Siemens AG, 2017'
@@ -92,7 +93,7 @@ def run_cmd_async(cmd, cwd, env=None, fail=True, shell=False, liveupdate=True):
# https://github.com/PyCQA/pylint/issues/996.
# pylint: disable=not-an-iterable
env = env or {}
env = env or get_context().environ
cmdstr = cmd
if not shell:
cmdstr = ' '.join(cmd)