mirror of https://github.com/pypa/pip
better parameter style for call_subprocess()
This commit is contained in:
parent
52556056c4
commit
98ee8761bc
|
@ -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))
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 "
|
||||
|
|
Loading…
Reference in New Issue