Raise a PR to fix 2016 issues commited here, fixed issues with merge.

This commit is contained in:
Damon Atkins 2017-12-07 01:48:01 +11:00
parent 32ef1e12ae
commit b46f818a57

View file

@ -195,7 +195,6 @@ def upgrade_available(name, **kwargs):
# Refresh before looking for the latest version available,
# same default as latest_version
refresh = salt.utils.is_true(kwargs.get('refresh', True))
# if latest_version returns blank, the latest version is already installed or
# their is no package definition. This is a salt standard which could be improved.
return latest_version(name, saltenv=saltenv, refresh=refresh) != ''
@ -315,9 +314,10 @@ def version(*names, **kwargs):
refresh (bool): Refresh package metadata. Default ``False``.
Returns:
str: version string when a single package is specified.
str: version string when a single packge is specified.
dict: The package name(s) with the installed versions.
.. code-block:: cfg
{['<version>', '<version>', ]} OR
{'<package name>': ['<version>', '<version>', ]}
@ -331,13 +331,13 @@ def version(*names, **kwargs):
'''
# Standard is return empty string even if not a valid name
# TODO: Look at returning an error across all platforms with
# TODO: Look at returning an error accross all platforms with
# CommandExecutionError(msg,info={'errors': errors })
# available_pkgs = get_repo_data(saltenv).get('repo')
# for name in names:
# if name in available_pkgs:
# ret[name] = installed_pkgs.get(name, '')
#
saltenv = kwargs.get('saltenv', 'base')
installed_pkgs = list_pkgs(saltenv=saltenv, refresh=kwargs.get('refresh', False))
@ -355,6 +355,7 @@ def list_pkgs(versions_as_list=False, **kwargs):
List the packages currently installed
Args:
version_as_list (bool): Returns the versions as a list
Kwargs:
saltenv (str): The salt environment to use. Default ``base``.
@ -632,17 +633,6 @@ def _get_repo_details(saltenv):
if contextkey in __context__:
(winrepo_source_dir, local_dest, winrepo_file) = __context__[contextkey]
else:
### Remove these warning lines in 2017.7
###if 'win_repo_source_dir' in __opts__:
### salt.utils.warn_until(
### 'Nitrogen',
### 'The \'win_repo_source_dir\' config option is deprecated, '
### 'please use \'winrepo_source_dir\' instead.'
### )
### winrepo_source_dir = __opts__['win_repo_source_dir']
###else:
### winrepo_source_dir = __opts__['winrepo_source_dir']
winrepo_source_dir = __opts__['winrepo_source_dir']
winrepo_source_dir = __opts__['winrepo_source_dir']
dirs = [__opts__['cachedir'], 'files', saltenv]
url_parts = _urlparse(winrepo_source_dir)
@ -1341,12 +1331,11 @@ def install(name=None, refresh=False, pkgs=None, **kwargs):
ret[pkg_name] = {'install status': 'failed'}
else:
# Launch the command
result = __salt__['cmd.run_all'](
'"{0}" /s /c "{1}"'.format(cmd_shell, arguments),
cache_path,
output_loglevel='trace',
python_shell=False,
redirect_stderr=True)
result = __salt__['cmd.run_all']('"{0}" /s /c "{1}"'.format(cmd_shell, arguments),
cache_path,
output_loglevel='trace',
python_shell=False,
redirect_stderr=True)
if not result['retcode']:
ret[pkg_name] = {'install status': 'success'}
changed.append(pkg_name)
@ -1594,10 +1583,6 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
cached_pkg = cached_pkg.replace('/', '\\')
cache_path, _ = os.path.split(cached_pkg)
# Get parameters for cmd
expanded_cached_pkg = str(os.path.expandvars(cached_pkg))
expanded_cache_path = str(os.path.expandvars(cache_path))
# Get uninstall flags
uninstall_flags = pkginfo[target].get('uninstall_flags', '')
@ -1608,13 +1593,13 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
# Compute msiexec string
use_msiexec, msiexec = _get_msiexec(pkginfo[target].get('msiexec', False))
cmd_shell = os.getenv('ComSpec', '{0}\\system32\\cmd.exe'.format(os.getenv('WINDIR')))
# Build cmd and arguments
# cmd and arguments must be separated for use with the task scheduler
# Build Scheduled Task Parameters
if use_msiexec:
arguments = '"{0}" /X "{1}"'.format(msiexec, uninstaller if uninstaller else expanded_cached_pkg)
# Check if uninstaller is set to {guid}, if not we assume its a remote msi file.
# which has already been downloaded.
arguments = '"{0}" /X "{1}"'.format(msiexec, cached_pkg)
else:
arguments = '"{0}"'.format(expanded_cached_pkg)
arguments = '"{0}"'.format(cached_pkg)
if uninstall_flags:
arguments = '{0} {1}'.format(arguments, uninstall_flags)
@ -1629,7 +1614,7 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
action_type='Execute',
cmd=cmd_shell,
arguments='/s /c "{0}"'.format(arguments),
start_in=expanded_cache_path,
start_in=cache_path,
trigger_type='Once',
start_date='1975-01-01',
start_time='01:00',
@ -1644,7 +1629,6 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
# Launch the command
result = __salt__['cmd.run_all'](
'"{0}" /s /c "{1}"'.format(cmd_shell, arguments),
expanded_cache_path,
output_loglevel='trace',
python_shell=False,
redirect_stderr=True)