diff --git a/pip/utils/__init__.py b/pip/utils/__init__.py index 862767156..87653ee61 100644 --- a/pip/utils/__init__.py +++ b/pip/utils/__init__.py @@ -621,9 +621,9 @@ def remove_tracebacks(output): def call_subprocess(cmd, show_stdout=True, cwd=None, - raise_on_returncode=True, + on_returncode='raise', command_level=std_logging.DEBUG, command_desc=None, - extra_environ=None, spinner=None, warn_on_returncode=True): + extra_environ=None, spinner=None): if command_desc is None: cmd_parts = [] for part in cmd: @@ -662,7 +662,7 @@ def call_subprocess(cmd, show_stdout=True, cwd=None, else: spinner.finish("done") if proc.returncode: - if raise_on_returncode: + if on_returncode == 'raise': if all_output: logger.info( 'Complete output from command %s:', command_desc, @@ -674,12 +674,16 @@ def call_subprocess(cmd, show_stdout=True, cwd=None, raise InstallationError( 'Command "%s" failed with error code %s in %s' % (command_desc, proc.returncode, cwd)) + elif on_returncode == 'warn': + logger.warning( + 'Command "%s" had error code %s in %s', + command_desc, proc.returncode, cwd, + ) + elif on_returncode == 'ignore': + pass else: - if warn_on_returncode: - logger.warning( - 'Command "%s" had error code %s in %s', - command_desc, proc.returncode, cwd, - ) + raise ValueError('Invalid value: on_returncode=%s' % + repr(on_returncode)) if not show_stdout: return remove_tracebacks(''.join(all_output)) diff --git a/pip/vcs/__init__.py b/pip/vcs/__init__.py index 721dda188..b0e52cc74 100644 --- a/pip/vcs/__init__.py +++ b/pip/vcs/__init__.py @@ -307,9 +307,9 @@ class VersionControl(object): raise NotImplementedError def run_command(self, cmd, show_stdout=True, cwd=None, - raise_on_returncode=True, + on_returncode='raise', command_level=logging.DEBUG, command_desc=None, - extra_environ=None, spinner=None, warn_on_returncode=True): + extra_environ=None, spinner=None): """ Run a VCS subcommand This is simply a wrapper around call_subprocess that adds the VCS @@ -318,9 +318,9 @@ class VersionControl(object): cmd = [self.name] + cmd try: return call_subprocess(cmd, show_stdout, cwd, - raise_on_returncode, command_level, + on_returncode, command_level, command_desc, extra_environ, - spinner, warn_on_returncode) + spinner) except OSError as e: # errno.ENOENT = no such file or directory # In other words, the VCS executable isn't available diff --git a/pip/vcs/git.py b/pip/vcs/git.py index ce92b5090..8fa543bd5 100644 --- a/pip/vcs/git.py +++ b/pip/vcs/git.py @@ -280,8 +280,7 @@ class Git(VersionControl): r = cls().run_command(['rev-parse'], cwd=location, show_stdout=False, - raise_on_returncode=False, - warn_on_returncode=False) + on_returncode='ignore') return not r except BadCommand: logger.debug("could not determine if %s is under git control "