From 7417a6024c7fe093a54f07a1ea4f24bdd0fcc3e6 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Fri, 15 Feb 2013 10:46:18 -0500 Subject: returncode for Popen is valid only after communicate call Found when testing a bug in cinder (1125416), code relying on throw_on_error won't work because returncode is None if checked before the communicate() method is called Change-Id: I8c9dd00396346ec3ad7bbe1dc17643c385da8d6f --- openstack/common/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'openstack/common') diff --git a/openstack/common/setup.py b/openstack/common/setup.py index 35680b3..2a971e7 100644 --- a/openstack/common/setup.py +++ b/openstack/common/setup.py @@ -117,9 +117,9 @@ def _run_shell_command(cmd, throw_on_error=False): output = subprocess.Popen(["/bin/sh", "-c", cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out = output.communicate() if output.returncode and throw_on_error: raise Exception("%s returned %d" % cmd, output.returncode) - out = output.communicate() if len(out) == 0: return None if len(out[0].strip()) == 0: -- cgit