From: Robert Yang <liezhi.yang@windriver.com>
To: Patches and discussions about the oe-core layer
<openembedded-core@lists.openembedded.org>
Cc: Chris Larson <clarson@kergoth.com>, Zhenfeng.Zhao@windriver.com
Subject: Re: [PATCH 4/4] scripts: replace os.popen with subprocess.Popen
Date: Wed, 30 May 2012 17:27:29 +0800 [thread overview]
Message-ID: <4FC5E801.7090303@windriver.com> (raw)
In-Reply-To: <CABcZANmqC4JZgJ6bMq+JNfQAoirngBxY_bSch+Ae=s4o48pqqQ@mail.gmail.com>
On 05/30/2012 01:30 AM, Chris Larson wrote:
> On Tue, May 29, 2012 at 7:53 AM, Robert Yang<liezhi.yang@windriver.com> wrote:
>> Replace os.popen with subprocess.Popen since the older function would
>> fail (more or less) silently if the executed program cannot be found
>>
>> More info:
>> http://docs.python.org/library/subprocess.html#subprocess-replacements
>>
>> [YOCTO #2454]
>>
>> Signed-off-by: Robert Yang<liezhi.yang@windriver.com>
>> ---
>> scripts/contrib/python/generate-manifest-2.7.py | 3 ++-
>> 1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/scripts/contrib/python/generate-manifest-2.7.py b/scripts/contrib/python/generate-manifest-2.7.py
>> index 7b43137..d139ab1 100755
>> --- a/scripts/contrib/python/generate-manifest-2.7.py
>> +++ b/scripts/contrib/python/generate-manifest-2.7.py
>> @@ -13,6 +13,7 @@
>> import os
>> import sys
>> import time
>> +import subprocess
>>
>> VERSION = "2.7.2"
>>
>> @@ -149,7 +150,7 @@ class MakefileMaker:
>> if __name__ == "__main__":
>>
>> if len( sys.argv )> 1:
>> - os.popen( "rm -f ./%s" % sys.argv[1] )
>> + subprocess.Popen("rm -f ./%s" % sys.argv[1], shell=True, stdout=subprocess.PIPE).stdout
>> outfile = file( sys.argv[1], "w" )
>> else:
>> outfile = sys.stdout
>
> This seems like a candidate for subprocess.call, not subprocess.Popen,
> as the output isn't used. Better yet, just use os.unlink() and ignore
> exceptions from it.
Thanks, Chris, I will send the V2 sooner.
// Robert
next prev parent reply other threads:[~2012-05-30 9:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-29 14:53 [PATCH 0/4] replace os.system/popen with subprocess module Robert Yang
2012-05-29 14:53 ` [PATCH 1/4] meta: replace os.system with subprocess.call Robert Yang
2012-05-29 14:53 ` [PATCH 2/4] scripts: " Robert Yang
2012-05-29 14:53 ` [PATCH 3/4] meta: replace os.popen with subprocess.Popen Robert Yang
2012-05-29 14:53 ` [PATCH 4/4] scripts: " Robert Yang
2012-05-29 17:30 ` Chris Larson
2012-05-30 9:27 ` Robert Yang [this message]
2012-05-30 11:59 ` [PATCH 0/4] replace os.system/popen with subprocess module Richard Purdie
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=4FC5E801.7090303@windriver.com \
--to=liezhi.yang@windriver.com \
--cc=Zhenfeng.Zhao@windriver.com \
--cc=clarson@kergoth.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.