summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2019-03-16 11:56:51 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2019-03-18 03:27:28 +0530
commita26947aefbdeaf0e2373ae8a8f7554641a2208dd (patch)
tree163b54e5e6ca25a7630e2712e271f3560e5f0c25
parentbbd4fede9fad48feb6edf42abfe772aff3f95060 (diff)
cerbero/shell: Don't copy env when it's None
The default is to use the current env in that case, which is fine. We only need to copy the env when we need to edit it.
-rw-r--r--cerbero/utils/shell.py14
1 files changed, 3 insertions, 11 deletions
diff --git a/cerbero/utils/shell.py b/cerbero/utils/shell.py
index 237f060d..3e3e1beb 100644
--- a/cerbero/utils/shell.py
+++ b/cerbero/utils/shell.py
@@ -153,13 +153,8 @@ def call(cmd, cmd_dir='.', fail=True, verbose=False, logfile=None, env=None):
def check_call(cmd, cmd_dir=None, shell=False, split=True, fail=False, env=None):
- if env is None:
- if CALL_ENV is not None:
- env = CALL_ENV.copy()
- elif env is not None:
- env = env.copy()
- else:
- env = os.environ.copy()
+ if env is None and CALL_ENV is not None:
+ env = CALL_ENV.copy()
if split and isinstance(cmd, str):
cmd = shlex.split(cmd)
try:
@@ -200,8 +195,7 @@ async def async_call(cmd, cmd_dir='.', logfile=None, env=None):
m.error("cd %s && %s && cd %s" % (cmd_dir, cmd, os.getcwd()))
return
- if env is None:
- env = os.environ.copy()
+ env = os.environ.copy() if env is None else env.copy()
# Force python scripts to print their output on newlines instead
# of on exit. Ensures that we get continuous output in log files.
env['PYTHONUNBUFFERED'] = '1'
@@ -222,8 +216,6 @@ async def async_call_output(cmd, cmd_dir=None, logfile=None, env=None):
@param cmd_dir: directory where the command will be run
@param cmd_dir: str
'''
- if env is None:
- env = os.environ.copy()
cmd = _cmd_string_to_array(cmd)
if PLATFORM == Platform.WINDOWS: