| Submitter | Robert Yang |
|---|---|
| Date | May 29, 2012, 2:53 p.m. |
| Message ID | <17015f5456a8216f84817ef9183b83779537347d.1338302685.git.liezhi.yang@windriver.com> |
| Download | mbox | patch |
| Permalink | /patch/28887/ |
| State | New |
| Headers | show |
Comments
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.
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
Patch
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
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(-)