On Tue, 2010-01-19 at 10:00 +0000, Christopher Larson wrote:
> Provides oe_popen, which is a subprocess.Popen wrapper that automatically
> provides our exported variables in the environment, including the PATH, and
> oe_system, which is just a wrapper that acts like system.
> 
> Signed-off-by: Chris Larson <[email protected]>

Acked-by: Tom Rini <[email protected]>


> ---
> classes/base.bbclass |   37 +++++++++++++++++++++++++++++++------
>  1 files changed, 31 insertions(+), 6 deletions(-)
> 
> diff --git a/classes/base.bbclass b/classes/base.bbclass
> index f67773a..edda75b 100644
> --- a/classes/base.bbclass
> +++ b/classes/base.bbclass
> @@ -1,5 +1,36 @@
>  BB_DEFAULT_TASK ?= "build"
>  
> +python () {
> +    env = {}
> +    for v in d.keys():
> +        if d.getVarFlag(v, "export"):
> +            env[v] = d.getVar(v, True) or ""
> +    d.setVar("__oe_popen_env", env)
> +}
> +
> +def subprocess_setup():
> +   import signal
> +   # Python installs a SIGPIPE handler by default. This is usually not what
> +   # non-Python subprocesses expect.
> +   signal.signal(signal.SIGPIPE, signal.SIG_DFL)
> +
> +def oe_popen(d, cmd, **kwargs):
> +    """ Convenience function to call out processes with our exported
> +    variables in the environment.
> +    """
> +    from subprocess import Popen
> +
> +    if kwargs.get("env") is None:
> +        kwargs["env"] = d.getVar("__oe_popen_env", 0)
> +
> +    kwargs["preexec_fn"] = subprocess_setup
> +
> +    return Popen(cmd, **kwargs)
> +
> +def oe_system(d, cmd):
> +    """ Popen based version of os.system. """
> +    return oe_popen(d, cmd, shell=True).wait()
> +
>  # like os.path.join but doesn't treat absolute RHS specially
>  def base_path_join(a, *p):
>      path = a
> @@ -750,12 +781,6 @@ base_do_buildall() {
>       :
>  }
>  
> -def subprocess_setup():
> -     import signal
> -     # Python installs a SIGPIPE handler by default. This is usually not what
> -     # non-Python subprocesses expect.
> -     signal.signal(signal.SIGPIPE, signal.SIG_DFL)
> -
>  def oe_unpack_file(file, data, url = None):
>       import subprocess
>       if not url:


-- 
Tom Rini <[email protected]>
Mentor Graphics Corporation

_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

Reply via email to