From: Tom Rini Date: Wed, 30 Jul 2014 13:51:02 -0400 Subject: [U-Boot] [PATCH] tools/genboardscfg.py: Don't rely on subprocess.check_output In-Reply-To: References: <1406730293-26989-1-git-send-email-trini@ti.com> Message-ID: <20140730175102.GA19374@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Wed, Jul 30, 2014 at 04:46:32PM +0100, Simon Glass wrote: > Hi Tom, > > On 30 July 2014 15:24, Tom Rini wrote: > > The function subprocess.check_output() only exists in Python 2.7 and > > later (and there are long term supported distributions that ship with > > 2.6.x). Replace this with a call to subprocess.Popen() and then checking > > output via communicate() > > > > Signed-off-by: Tom Rini > > Looks fine as it is - see a few optional comments below. > > Acked-by: Simon Glass > > > --- > > tools/genboardscfg.py | 9 ++++++--- > > 1 files changed, 6 insertions(+), 3 deletions(-) > > > > diff --git a/tools/genboardscfg.py b/tools/genboardscfg.py > > index 805e4eb..6588392 100755 > > --- a/tools/genboardscfg.py > > +++ b/tools/genboardscfg.py > > @@ -83,7 +83,8 @@ def check_top_directory(): > > def get_make_cmd(): > > """Get the command name of GNU Make.""" > > try: > > - make_cmd = subprocess.check_output([SHOW_GNU_MAKE]) > > + process = subprocess.Popen([SHOW_GNU_MAKE], stdout=subprocess.PIPE) > > + make_cmd, unused = process.communicate() > > Sometimes people use underscore for unused variables, like: > > make_cmd, _ = process.communicate() > > but in this case you could also do: > > make_cmd = process.communicate()[0] > > > except subprocess.CalledProcessError: > > print >> sys.stderr, 'GNU Make not found' > > sys.exit(1) > > @@ -493,8 +494,10 @@ def main(): > > sys.exit(1) > > else: > > try: > > - jobs = int(subprocess.check_output(['getconf', > > - '_NPROCESSORS_ONLN'])) > > + process = subprocess.Popen(['getconf', '_NPROCESSORS_ONLN'], > > + stdout=subprocess.PIPE) > > + jobstr, unused = process.communicate() > > + jobs = int(jobstr) > > except subprocess.CalledProcessError: > > print 'info: failed to get the number of CPUs. Set jobs to 1' > > jobs = 1 Ah, OK, thanks. I've cleaned up both to just do communicate()[0] (and condensed the jobs part back to a single line). One last sanity check build going on now. -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: