Rebase: p/opnfv-fuel: Allow Fuel commit override.
[armband.git] / patches / opnfv-fuel / 0011-common.py-catch-stderr-in-exec_cmd.patch
1 From: Josep Puigdemont <josep.puigdemont@enea.com>
2 Date: Wed, 4 May 2016 14:27:23 +0200
3 Subject: [PATCH] common.py: catch stderr in exec_cmd
4
5 Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
6 ---
7  deploy/common.py | 12 ++++++------
8  1 file changed, 6 insertions(+), 6 deletions(-)
9
10 diff --git a/deploy/common.py b/deploy/common.py
11 index 787a21a..41b4e27 100644
12 --- a/deploy/common.py
13 +++ b/deploy/common.py
14 @@ -38,20 +38,20 @@ LOG.addHandler(out_handler)
15  os.chmod(LOGFILE, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
16  
17  def exec_cmd(cmd, check=True):
18 -    nul_f = open(os.devnull, 'w')
19      process = subprocess.Popen(cmd,
20                                 stdout=subprocess.PIPE,
21 -                               stderr=nul_f,
22 +                               stderr=subprocess.PIPE,
23                                 shell=True)
24 -    nul_f.close()
25 -    response = process.communicate()[0].strip()
26 +    (response, stderr) = process.communicate()
27      return_code = process.returncode
28 +    response = response.strip()
29      if check:
30          if return_code > 0:
31 +            stderr = stderr.strip()
32              print "Failed command: " + str(cmd)
33 -            print "Command returned response: " + str(response)
34 +            print "Command returned response: " + str(stderr)
35              print "Command return code: " + str(return_code)
36 -            raise Exception(response)
37 +            raise Exception(stderr)
38          else:
39              print "Command: " + str(cmd)
40              print str(response)