Commit 6eace398072a62e74f10f412ffadfe51b7402395

Authored by Simon Glass
1 parent 3b1c0b09c9

patman: Update command.Run() to handle failure better

At present tools are not expected to fail. If they do an exception is
raised but there is no detail about what went wrong. This makes it hard
to debug if something does actually go wrong.

Fix this by outputting both stderr and stdout on failure.

Signed-off-by: Simon Glass <sjg@chromium.org>

Showing 1 changed file with 8 additions and 2 deletions Side-by-side Diff

tools/patman/tools.py
... ... @@ -205,8 +205,14 @@
205 205 if tool_search_paths:
206 206 env = dict(os.environ)
207 207 env['PATH'] = ':'.join(tool_search_paths) + ':' + env['PATH']
208   - return command.Run(name, *args, capture=True, capture_stderr=True,
209   - env=env)
  208 + all_args = (name,) + args
  209 + result = command.RunPipe([all_args], capture=True, capture_stderr=True,
  210 + env=env, raise_on_error=False)
  211 + if result.return_code:
  212 + raise Exception("Error %d running '%s': %s" %
  213 + (result.return_code,' '.join(all_args),
  214 + result.stderr))
  215 + return result.stdout
210 216 except:
211 217 if env and not PathHasFile(env['PATH'], name):
212 218 msg = "Please install tool '%s'" % name