diff options
author | Simon Glass <sjg@chromium.org> | 2012-12-15 10:42:05 +0000 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2013-04-04 14:04:33 -0700 |
commit | dc191505b903220a8581303efef0a1ead0e06532 (patch) | |
tree | 3d2592eb91de9c254757800be9cea7330a36540a /tools | |
parent | a10fd93cbc2ddf1da1f8b6d915f4bc3276ff7731 (diff) | |
download | u-boot-imx-dc191505b903220a8581303efef0a1ead0e06532.zip u-boot-imx-dc191505b903220a8581303efef0a1ead0e06532.tar.gz u-boot-imx-dc191505b903220a8581303efef0a1ead0e06532.tar.bz2 |
patman: Allow commands to raise on error, or not
Make raise_on_error a parameter so that we can control which commands
raise and which do not. If we get an error reading the alias file, just
continue.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/patman/command.py | 17 | ||||
-rw-r--r-- | tools/patman/gitutil.py | 3 |
2 files changed, 13 insertions, 7 deletions
diff --git a/tools/patman/command.py b/tools/patman/command.py index fc085f2..e6af6ed 100644 --- a/tools/patman/command.py +++ b/tools/patman/command.py @@ -42,7 +42,7 @@ class CommandResult: def RunPipe(pipe_list, infile=None, outfile=None, capture=False, capture_stderr=False, oneline=False, - cwd=None, **kwargs): + raise_on_error=True, cwd=None, **kwargs): """ Perform a command pipeline, with optional input/output filenames. @@ -63,6 +63,7 @@ def RunPipe(pipe_list, infile=None, outfile=None, result = CommandResult() last_pipe = None pipeline = list(pipe_list) + user_pipestr = '|'.join([' '.join(pipe) for pipe in pipe_list]) while pipeline: cmd = pipeline.pop(0) if last_pipe is not None: @@ -80,8 +81,10 @@ def RunPipe(pipe_list, infile=None, outfile=None, last_pipe = cros_subprocess.Popen(cmd, cwd=cwd, **kwargs) except Exception, err: result.exception = err - print 'exception', pipe_list, err - raise Exception("Error running '%s': %s" % (pipe_list, str)) + if raise_on_error: + raise Exception("Error running '%s': %s" % (user_pipestr, str)) + result.return_code = 255 + return result if capture: result.stdout, result.stderr, result.combined = ( @@ -91,15 +94,17 @@ def RunPipe(pipe_list, infile=None, outfile=None, result.return_code = last_pipe.wait() else: result.return_code = os.waitpid(last_pipe.pid, 0)[1] - if result.return_code: - raise Exception("Error running '%s'" % pipe_list) + if raise_on_error and result.return_code: + raise Exception("Error running '%s'" % user_pipestr) return result def Output(*cmd): - return RunPipe([cmd], capture=True).stdout + return RunPipe([cmd], capture=True, raise_on_error=False).stdout def OutputOneLine(*cmd, **kwargs): + raise_on_error = kwargs.pop('raise_on_error', True) return (RunPipe([cmd], capture=True, oneline=True, + raise_on_error=raise_on_error, **kwargs).stdout.strip()) def Run(*cmd, **kwargs): diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index 77907c1..33743dd 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -359,7 +359,8 @@ def GetAliasFile(): Returns: Filename of git alias file, or None if none """ - fname = command.OutputOneLine('git', 'config', 'sendemail.aliasesfile') + fname = command.OutputOneLine('git', 'config', 'sendemail.aliasesfile', + raise_on_error=False) if fname: fname = os.path.join(GetTopLevel(), fname.strip()) return fname |