[PATCH v2 2/3] git-p4: add option to system() to return subshell status
- From
Luke Diamand <luke@diamand.org>
- Date
- Nov 21, 2015, 09:54 UTC
- Message-ID
- <1448099681-20183-3-git-send-email-luke@diamand.org>
- In-Reply-To
- <1448099681-20183-1-git-send-email-luke@diamand.org>
Add an optional parameter ignore_error to the git-p4 system() function. If used, it will return the subshell exit status rather than throwing an exception.
Signed-off-by: Luke Diamand <luke@diamand.org> --- git-p4.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/git-p4.py b/git-p4.py index 0093fa3..9d55f9c 100755 --- a/git-p4.py +++ b/git-p4.py @@ -192,14 +192,16 @@ def p4_has_move_command(): # assume it failed because @... was invalid changelist return True -def system(cmd): +def system(cmd, ignore_error=False): expand = isinstance(cmd,basestring) if verbose: sys.stderr.write("executing %s\n" % str(cmd)) retcode = subprocess.call(cmd, shell=expand) - if retcode: + if retcode and not ignore_error: raise CalledProcessError(retcode, cmd) + return retcode + def p4_system(cmd): """Specifically invoke p4 as the system command. """ real_cmd = p4_build_cmd(cmd)
-- 2.6.0.rc3.238.gc07a1e8