Pass command to cmd.run_all as list instead of joining

Also made a number of formatting fixes
This commit is contained in:
Erik Johnson 2015-08-24 23:53:23 -05:00
parent 1c90cdb07e
commit 03250dbd9f

View file

@ -294,92 +294,122 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
pkgs
Comma separated list of packages to install
requirements
Path to requirements
bin_env
Path to pip bin or path to virtualenv. If doing a system install,
and want to use a specific pip bin (pip-2.7, pip-2.6, etc..) just
specify the pip bin you want.
If installing into a virtualenv, just use the path to the virtualenv
(/home/code/path/to/virtualenv/)
.. note::
If installing into a virtualenv, just use the path to the
virtualenv (e.g. ``/home/code/path/to/virtualenv/``)
env
Deprecated, use bin_env now
use_wheel
Prefer wheel archives (requires pip>=1.4)
no_use_wheel
Force to not use wheel archives (requires pip>=1.4)
log
Log file where a complete (maximum verbosity) record will be kept
proxy
Specify a proxy in the form
user:passwd@proxy.server:port. Note that the
user:password@ is optional and required only if you
are behind an authenticated proxy. If you provide
user@proxy.server:port then you will be prompted for a
password.
Specify a proxy in the form ``user:passwd@proxy.server:port``. Note
that the ``user:password@`` is optional and required only if you are
behind an authenticated proxy. If you provide
``user@proxy.server:port`` then you will be prompted for a password.
timeout
Set the socket timeout (default 15 seconds)
editable
install something editable (i.e.
git+https://github.com/worldcompany/djangoembed.git#egg=djangoembed)
install something editable (e.g.
``git+https://github.com/worldcompany/djangoembed.git#egg=djangoembed``)
find_links
URL to look for packages at
URL to search for packages
index_url
Base URL of Python Package Index
extra_index_url
Extra URLs of package indexes to use in addition to ``index_url``
no_index
Ignore package index
mirrors
Specific mirror URL(s) to query (automatically adds --use-mirrors)
build
Unpack packages into ``build`` dir
target
Install packages into ``target`` dir
download
Download packages into ``download`` instead of installing them
download_cache
Cache downloaded packages in ``download_cache`` dir
source
Check out ``editable`` packages into ``source`` dir
upgrade
Upgrade all packages to the newest available version
force_reinstall
When upgrading, reinstall all packages even if they are already
up-to-date.
ignore_installed
Ignore the installed packages (reinstalling instead)
exists_action
Default action when a path already exists: (s)witch, (i)gnore, (w)ipe,
(b)ackup
no_deps
Ignore package dependencies
no_install
Download and unpack all packages, but don't actually install them
no_download
Don't download any packages, just install the ones
already downloaded (completes an install run with
--no-install)
Don't download any packages, just install the ones already downloaded
(completes an install run with ``--no-install``)
install_options
Extra arguments to be supplied to the setup.py install
command (use like --install-option="--install-
scripts=/usr/local/bin"). Use multiple --install-
option options to pass multiple options to setup.py
install. If you are using an option with a directory
path, be sure to use absolute path.
Extra arguments to be supplied to the setup.py install command (e.g.
like ``--install-option='--install-scripts=/usr/local/bin'``). Use
multiple --install-option options to pass multiple options to setup.py
install. If you are using an option with a directory path, be sure to
use absolute path.
global_options
Extra global options to be supplied to the setup.py call before the
install command.
user
The user under which to run pip
no_chown
When user is given, do not attempt to copy and chown
a requirements file
When user is given, do not attempt to copy and chown a requirements
file
cwd
Current working directory to run pip from
activate
Activates the virtual environment, if given via bin_env,
before running install.
Activates the virtual environment, if given via bin_env, before running
install.
.. deprecated:: 2014.7.2
If `bin_env` is given, pip will already be sourced from that
@ -387,18 +417,27 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
pre_releases
Include pre-releases in the available versions
cert
Provide a path to an alternate CA bundle
allow_all_external
Allow the installation of all externally hosted files
allow_external
Allow the installation of externally hosted files (comma separated list)
Allow the installation of externally hosted files (comma separated
list)
allow_unverified
Allow the installation of insecure and unverifiable files (comma separated list)
Allow the installation of insecure and unverifiable files (comma
separated list)
process_dependency_links
Enable the processing of dependency links
use_vt
Use VT terminal emulation (see ouptut while installing)
env_vars
Set environment variables that some builds will depend on. For example,
a Python C-module may have a Makefile that needs INCLUDE_PATH set to
@ -527,7 +566,7 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
raise CommandExecutionError(
'\'{0}\' is not a valid URL or path'.format(link)
)
cmd.append('--find-links={0}'.format(link))
cmd.extend(['--find-links', link])
if no_index and (index_url or extra_index_url):
raise CommandExecutionError(
@ -562,22 +601,22 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
raise CommandExecutionError(
'\'{0}\' is not a valid URL'.format(mirror)
)
cmd.append('--mirrors={0}'.format(mirror))
cmd.extend(['--mirrors', mirror])
if build:
cmd.append('--build={0}'.format(build))
cmd.extend(['--build', build])
if target:
cmd.append('--target={0}'.format(target))
cmd.extend(['--target', target])
if download:
cmd.append('--download={0}'.format(download))
cmd.extend(['--download', download])
if download_cache:
cmd.append('--download-cache={0}'.format(download_cache))
cmd.extend(['--download-cache', download_cache])
if source:
cmd.append('--source={0}'.format(source))
cmd.extend(['--source', source])
if upgrade:
cmd.append('--upgrade')
@ -655,7 +694,7 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
raise CommandExecutionError(
'You must specify an egg for this editable'
)
cmd.append('--editable={0}'.format(entry))
cmd.extend(['--editable', entry])
if allow_all_external:
cmd.append('--allow-all-external')
@ -685,7 +724,7 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
cmd_kwargs = dict(cwd=cwd, saltenv=saltenv, use_vt=use_vt, runas=user)
if bin_env and os.path.isdir(bin_env):
cmd_kwargs['env'] = {'VIRTUAL_ENV': bin_env}
return __salt__['cmd.run_all'](' '.join(cmd),
return __salt__['cmd.run_all'](cmd,
python_shell=False,
**cmd_kwargs)
finally:
@ -823,7 +862,7 @@ def uninstall(pkgs=None,
cmd_kwargs['env'] = {'VIRTUAL_ENV': bin_env}
try:
return __salt__['cmd.run_all'](' '.join(cmd), **cmd_kwargs)
return __salt__['cmd.run_all'](cmd, **cmd_kwargs)
finally:
for requirement in cleanup_requirements:
try:
@ -863,7 +902,7 @@ def freeze(bin_env=None,
cmd_kwargs = dict(runas=user, cwd=cwd, use_vt=use_vt, python_shell=False)
if bin_env and os.path.isdir(bin_env):
cmd_kwargs['env'] = {'VIRTUAL_ENV': bin_env}
result = __salt__['cmd.run_all'](' '.join(cmd), **cmd_kwargs)
result = __salt__['cmd.run_all'](cmd, **cmd_kwargs)
if result['retcode'] > 0:
raise CommandExecutionError(result['stderr'])
@ -898,7 +937,7 @@ def list_(prefix=None,
if not prefix or prefix in ('p', 'pi', 'pip'):
packages['pip'] = version(bin_env)
result = __salt__['cmd.run_all'](' '.join(cmd), **cmd_kwargs)
result = __salt__['cmd.run_all'](cmd, **cmd_kwargs)
if result['retcode'] > 0:
raise CommandExecutionError(result['stderr'])
@ -966,20 +1005,20 @@ def list_upgrades(bin_env=None,
'''
pip_bin = _get_pip_bin(bin_env)
cmd = [pip_bin, "list", "--outdated"]
cmd = [pip_bin, 'list', '--outdated']
cmd_kwargs = dict(cwd=cwd, runas=user)
if bin_env and os.path.isdir(bin_env):
cmd_kwargs['env'] = {'VIRTUAL_ENV': bin_env}
result = __salt__['cmd.run_all'](' '.join(cmd), **cmd_kwargs)
result = __salt__['cmd.run_all'](cmd, **cmd_kwargs)
if result['retcode'] > 0:
logger.error(result['stderr'])
raise CommandExecutionError(result['stderr'])
packages = {}
for line in result['stdout'].splitlines():
match = re.search(r"(\S*)\s+\(.*Latest:\s+(.*)\)", line)
match = re.search(r'(\S*)\s+\(.*Latest:\s+(.*)\)', line)
if match:
name, version_ = match.groups()
else:
@ -1036,13 +1075,13 @@ def upgrade(bin_env=None,
old = list_(bin_env=bin_env, user=user, cwd=cwd)
cmd = [pip_bin, "install", "-U"]
cmd = [pip_bin, 'install', '-U']
cmd_kwargs = dict(cwd=cwd, use_vt=use_vt)
if bin_env and os.path.isdir(bin_env):
cmd_kwargs['env'] = {'VIRTUAL_ENV': bin_env}
errors = False
for pkg in list_upgrades(bin_env=bin_env, user=user, cwd=cwd):
result = __salt__['cmd.run_all'](' '.join(cmd+[pkg]), **cmd_kwargs)
result = __salt__['cmd.run_all'](cmd + [pkg], **cmd_kwargs)
if result['retcode'] != 0:
errors = True
if 'stderr' in result: