[Kimchi-devel] [PATCH 1/3] Add the env parameter to run_command.

Crístian Viana cristiandeives at gmail.com
Mon Apr 27 14:48:23 UTC 2015


The patch looks nice, but could you provide us a scenario where this patch
is needed? In which situation are you trying to run a command and you need
to specify a different set of environment variables other than the default
ones (i.e. the env inherited by the main process)? I couldn't figure this
out by reading the patch's description.

On Fri, Apr 17, 2015 at 4:29 PM Jose Ricardo Ziviani <
joserz at linux.vnet.ibm.com> wrote:

>  - The called may want to pass a custom environment variable to
>    run_command and now this is possible with this new parameter.
>
> Signed-off-by: Jose Ricardo Ziviani <joserz at linux.vnet.ibm.com>
> ---
>  src/kimchi/utils.py | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/kimchi/utils.py b/src/kimchi/utils.py
> index d71338a..2017cbe 100644
> --- a/src/kimchi/utils.py
> +++ b/src/kimchi/utils.py
> @@ -165,11 +165,12 @@ def check_url_path(path):
>      return True
>
>
> -def run_command(cmd, timeout=None):
> +def run_command(cmd, timeout=None, env=None):
>      """
>      cmd is a sequence of command arguments.
>      timeout is a float number in seconds.
>      timeout default value is None, means command run without timeout.
> +    env is the environment variable passed to the command.
>      """
>      # subprocess.kill() can leave descendants running
>      # and halting the execution. Using psutil to
> @@ -193,7 +194,8 @@ def run_command(cmd, timeout=None):
>
>      try:
>          proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
> -                                stderr=subprocess.PIPE)
> +                                stderr=subprocess.PIPE,
> +                                env=env)
>          if timeout is not None:
>              timer = Timer(timeout, kill_proc, [proc, timeout_flag])
>              timer.setDaemon(True)
> --
> 1.9.1
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/kimchi-devel/attachments/20150427/283104a1/attachment.html>


More information about the Kimchi-devel mailing list