xolox/python-executor

Environment variable can not be set

rafaelpivato opened this issue · 1 comments

If you need to customize environment variable on a per-call basis of execute, you will need to manage that outside on the caller.

Allow environment variable to be set when calling execute method as a named argument like in the following example:

from executor import execute
execute(
    'somescript.sh',
    env=dict(
        CONF='/etc/someconf.ini',
    ),
)

Hi Rafael and thanks for the feedback, your suggestion makes sense!

The version of executor that I just published to GitHub and PyPI allows callers to override environment variables for single calls to execute().

I went with the more verbose environment name instead of env. I know that subprocess.Popen() calls it just env, but I'm trying to stay consistent with other argument names like directory for execute() (instead of cwd for subprocess.Popen()).

I'm closing this issue now because I think I implemented your suggestion properly (I also added a test), but if you find an issue with this then feel free to reopen this issue or report a new one.