From 094742bed2fc01d55f572da946fcfa7a48521401 Mon Sep 17 00:00:00 2001 From: Robert Yang Date: Sun, 20 May 2012 20:36:06 +0800 Subject: replace os.popen with subprocess.Popen Replace os.popen with subprocess.Popen since the older function would fail (more or less) silently if the executed program cannot be found There is a bb.process.run() which will invoke the Popen to run command, use it for simplify the code. For the: p4file = os.popen("%s%s files %s" % (p4cmd, p4opt, depot)) ... for file in p4file: list = file.split() in bitbake/lib/bb/fetch2/perforce.py, it should be an error in the past, since it didn't use readline() to read the pipe, but directly used the split() for the pipe. Use the bb.process.run would fix the problem since bb.process.run will return strings. More info: http://docs.python.org/library/subprocess.html#subprocess-replacements [YOCTO #2075] (Bitbake rev: 8d6700255a6d4dda403c89b171a6d4a1883e5aae) Signed-off-by: Robert Yang Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/crumbs/hig.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'bitbake/lib/bb/ui/crumbs/hig.py') diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py index 1bc155d008..38f890b9f1 100644 --- a/bitbake/lib/bb/ui/crumbs/hig.py +++ b/bitbake/lib/bb/ui/crumbs/hig.py @@ -25,12 +25,12 @@ import gobject import hashlib import os import re -import subprocess import shlex from bb.ui.crumbs.hobcolor import HobColors from bb.ui.crumbs.hobwidget import hcc, hic, HobViewTable, HobInfoButton, HobButton, HobAltButton, HobIconChecker from bb.ui.crumbs.progressbar import HobProgressBar import bb.ui.crumbs.utils +import bb.process """ The following are convenience classes for implementing GNOME HIG compliant @@ -799,7 +799,8 @@ class DeployImageDialog (CrumbsDialog): self.progress_bar.hide() def popen_read(self, cmd): - return os.popen("%s 2>/dev/null" % cmd).read().strip() + tmpout, errors = bb.process.run("%s" % cmd) + return tmpout.strip() def find_all_usb_devices(self): usb_devs = [ os.readlink(u) @@ -828,7 +829,7 @@ class DeployImageDialog (CrumbsDialog): cmdline = bb.ui.crumbs.utils.which_terminal() if cmdline: cmdline += "\"sudo dd if=" + self.image_path + " of=" + combo_item + "\"" - subprocess.Popen(args=shlex.split(cmdline)) + bb.process.run(shlex.split(cmdline)) def update_progress_bar(self, title, fraction, status=None): self.progress_bar.update(fraction) -- cgit v1.2.3-54-g00ecf