patman: Adjust command.Output() to raise an error by default

It is more useful to have this method raise an error when something goes
wrong. Make this the default and adjust the few callers that don't want to
use it this way.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2016-07-25 18:59:00 -06:00
parent 49afb37988
commit 785f1548a9
4 changed files with 8 additions and 5 deletions

View File

@ -237,7 +237,7 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
options.step = len(series.commits) - 1 options.step = len(series.commits) - 1
gnu_make = command.Output(os.path.join(options.git, gnu_make = command.Output(os.path.join(options.git,
'scripts/show-gnu-make')).rstrip() 'scripts/show-gnu-make'), raise_on_error=False).rstrip()
if not gnu_make: if not gnu_make:
sys.exit('GNU Make not found') sys.exit('GNU Make not found')

View File

@ -63,7 +63,8 @@ def CheckPatch(fname, verbose=False):
result.problems = [] result.problems = []
chk = FindCheckPatch() chk = FindCheckPatch()
item = {} item = {}
result.stdout = command.Output(chk, '--no-tree', fname) result.stdout = command.Output(chk, '--no-tree', fname,
raise_on_error=False)
#pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE) #pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE)
#stdout, stderr = pipe.communicate() #stdout, stderr = pipe.communicate()

View File

@ -104,8 +104,9 @@ def RunPipe(pipe_list, infile=None, outfile=None,
raise Exception("Error running '%s'" % user_pipestr) raise Exception("Error running '%s'" % user_pipestr)
return result return result
def Output(*cmd): def Output(*cmd, **kwargs):
return RunPipe([cmd], capture=True, raise_on_error=False).stdout raise_on_error = kwargs.get('raise_on_error', True)
return RunPipe([cmd], capture=True, raise_on_error=raise_on_error).stdout
def OutputOneLine(*cmd, **kwargs): def OutputOneLine(*cmd, **kwargs):
raise_on_error = kwargs.pop('raise_on_error', True) raise_on_error = kwargs.pop('raise_on_error', True)

View File

@ -391,7 +391,8 @@ def EmailPatches(series, cover_fname, args, dry_run, raise_on_error, cc_fname,
""" """
to = BuildEmailList(series.get('to'), '--to', alias, raise_on_error) to = BuildEmailList(series.get('to'), '--to', alias, raise_on_error)
if not to: if not to:
git_config_to = command.Output('git', 'config', 'sendemail.to') git_config_to = command.Output('git', 'config', 'sendemail.to',
raise_on_error=False)
if not git_config_to: if not git_config_to:
print ("No recipient.\n" print ("No recipient.\n"
"Please add something like this to a commit\n" "Please add something like this to a commit\n"