diff mbox

[U-Boot,04/30] patman: Adjust command.Output() to raise an error by default

Message ID 1469494766-26601-5-git-send-email-sjg@chromium.org
State Accepted
Commit 785f1548a9e74cf4796c96e6f32ed67b25f79b81
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass July 26, 2016, 12:59 a.m. UTC
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>
---

 tools/buildman/control.py  | 2 +-
 tools/patman/checkpatch.py | 3 ++-
 tools/patman/command.py    | 5 +++--
 tools/patman/gitutil.py    | 3 ++-
 4 files changed, 8 insertions(+), 5 deletions(-)

Comments

Simon Glass Aug. 27, 2016, 4:05 p.m. UTC | #1
On 25 July 2016 at 18:59, Simon Glass <sjg@chromium.org> wrote:
> 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>
> ---
>
>  tools/buildman/control.py  | 2 +-
>  tools/patman/checkpatch.py | 3 ++-
>  tools/patman/command.py    | 5 +++--
>  tools/patman/gitutil.py    | 3 ++-
>  4 files changed, 8 insertions(+), 5 deletions(-)

Applied to u-boot-dm/next.
diff mbox

Patch

diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index aeb128a..51262fe 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -231,7 +231,7 @@  def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
         options.step = len(series.commits) - 1
 
     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:
         sys.exit('GNU Make not found')
 
diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
index 34a3bd2..3eef6de 100644
--- a/tools/patman/checkpatch.py
+++ b/tools/patman/checkpatch.py
@@ -63,7 +63,8 @@  def CheckPatch(fname, verbose=False):
     result.problems = []
     chk = FindCheckPatch()
     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)
     #stdout, stderr = pipe.communicate()
 
diff --git a/tools/patman/command.py b/tools/patman/command.py
index d586f11..d1f0ca5 100644
--- a/tools/patman/command.py
+++ b/tools/patman/command.py
@@ -104,8 +104,9 @@  def RunPipe(pipe_list, infile=None, outfile=None,
         raise Exception("Error running '%s'" % user_pipestr)
     return result
 
-def Output(*cmd):
-    return RunPipe([cmd], capture=True, raise_on_error=False).stdout
+def Output(*cmd, **kwargs):
+    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):
     raise_on_error = kwargs.pop('raise_on_error', True)
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index e088bae..bb7c9e0 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -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)
     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:
             print ("No recipient.\n"
                    "Please add something like this to a commit\n"