Skip to content

Commit

Permalink
Fix passing env vars to CmdAction
Browse files Browse the repository at this point in the history
This fixes issue #171.
  • Loading branch information
onnodb authored and schettino72 committed May 29, 2017
1 parent 0b95924 commit abc754c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions doit/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,14 @@ def execute(self, out=None, err=None):
"CmdAction Error creating command string", exc)

# set environ to change output buffering
subprocess_pkwargs = self.pkwargs.copy()
env = None
if 'env' in subprocess_pkwargs:
env = subprocess_pkwargs['env']
del subprocess_pkwargs['env']
if self.buffering:
env = os.environ.copy()
if not env:
env = os.environ.copy()
env['PYTHONUNBUFFERED'] = '1'

# spawn task process
Expand All @@ -201,7 +206,7 @@ def execute(self, out=None, err=None):
#bufsize=2, # ??? no effect use PYTHONUNBUFFERED instead
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env=env,
**self.pkwargs)
**subprocess_pkwargs)

output = StringIO()
errput = StringIO()
Expand Down

0 comments on commit abc754c

Please sign in to comment.