From aaa94d05aabd81bee0874f4b596b71fded3033ad Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sun, 30 Aug 2009 21:01:31 -0400 Subject: Allow capturing stderr from a run git command If _return_error=True is added to git.() then a tuple of captured output from stderr, stdout is returned. We'll need this to parse the output of 'git push' which goes to stderr. --- git-bz | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/git-bz b/git-bz index af986c6..7950ff5 100755 --- a/git-bz +++ b/git-bz @@ -242,6 +242,7 @@ global_options = None # _quiet: Discard all output even if an error occurs # _interactive: Don't capture stdout and stderr # _input=: Feed to stdinin of the command +# _return_error: Return tuple of captured (stdout,stderr) # def git_run(command, *args, **kwargs): to_run = ['git', command.replace("_", "-")] @@ -250,11 +251,14 @@ def git_run(command, *args, **kwargs): quiet = False input = None interactive = False + return_stderr = False for (k,v) in kwargs.iteritems(): if k == '_quiet': quiet = True elif k == '_interactive': interactive = True + elif k == '_return_stderr': + return_stderr = True elif k == '_input': input = v elif v is True: @@ -280,6 +284,8 @@ def git_run(command, *args, **kwargs): if interactive: return None + elif return_stderr: + return output.strip(), error.strip() else: return output.strip() -- cgit v1.2.3