[OE-core] [PATCH 4/4] scripts: replace os.popen with subprocess.Popen
Chris Larson
clarson at kergoth.com
Tue May 29 17:30:34 UTC 2012
On Tue, May 29, 2012 at 7:53 AM, Robert Yang <liezhi.yang at 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 at 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.
--
Christopher Larson
More information about the Openembedded-core
mailing list