Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
To: Martin Jansa <martin.jansa@gmail.com>,
	openembedded-core@lists.openembedded.org
Subject: Re: [PATCH] icecc.bbclass: replace os.popen with subprocess.check_output
Date: Tue, 14 Jun 2016 09:59:22 -0500	[thread overview]
Message-ID: <3308ab50-4cd1-c480-0fbb-c189159973a8@linux.intel.com> (raw)
In-Reply-To: <20160614140357.6145-1-Martin.Jansa@gmail.com>



On 06/14/2016 09:03 AM, Martin Jansa wrote:
> * otherwise there is a lot of warnings about missing close on file descriptor
>
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> ---
>   meta/classes/icecc.bbclass | 14 ++++++++++----
>   1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/meta/classes/icecc.bbclass b/meta/classes/icecc.bbclass
> index e1c06c4..cb44007 100644
> --- a/meta/classes/icecc.bbclass
> +++ b/meta/classes/icecc.bbclass
> @@ -47,7 +47,8 @@ def get_cross_kernel_cc(bb,d):
>   
>       # evaluate the expression by the shell if necessary
>       if '`' in kernel_cc or '$(' in kernel_cc:
> -        kernel_cc = os.popen("echo %s" % kernel_cc).read()[:-1]
> +        import subprocess
There are two imports like this, would it make sense to place just once 
on top?

Also, now that we switch to subprocess.check_output, I wonder if we need 
to convert it to string (the output of this method) before proceeding.
> +        kernel_cc = subprocess.check_output("echo %s" % kernel_cc, shell=True)
>   
>       kernel_cc = d.expand(kernel_cc)
>       kernel_cc = kernel_cc.replace('ccache', '').strip()
> @@ -220,9 +221,14 @@ def icecc_get_and_check_tool(bb, d, tool):
>       # PATH or icecc-create-env script will silently create an invalid
>       # compiler environment package.
>       t = icecc_get_tool(bb, d, tool)
> -    if t and os.popen("readlink -f %s" % t).read()[:-1] == get_icecc(d):
> -        bb.error("%s is a symlink to %s in PATH and this prevents icecc from working" % (t, get_icecc(d)))
> -        return ""
> +    if t:
> +        import subprocess
> +        link_path = subprocess.check_output("readlink -f %s" % t, shell=True)
> +        if link_path == get_icecc(d):
> +            bb.error("%s is a symlink to %s in PATH and this prevents icecc from working" % (t, get_icecc(d)))
> +            return ""
> +        else:
> +            return t
>       else:
>           return t
>   



  reply	other threads:[~2016-06-14 14:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-14 14:03 [PATCH] icecc.bbclass: replace os.popen with subprocess.check_output Martin Jansa
2016-06-14 14:59 ` Leonardo Sandoval [this message]
2016-06-14 15:06   ` Burton, Ross
2016-10-05 20:53 ` [PATCHv2] " Martin Jansa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3308ab50-4cd1-c480-0fbb-c189159973a8@linux.intel.com \
    --to=leonardo.sandoval.gonzalez@linux.intel.com \
    --cc=martin.jansa@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox