mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #32291 from twangboy/fix_14277
Fix bad output for chocolatey.version (fixes #14277)
This commit is contained in:
commit
5fb90a1040
1 changed files with 5 additions and 22 deletions
|
@ -786,13 +786,7 @@ def version(name, check_remote=False, source=None, pre_versions=False):
|
|||
log.error(err)
|
||||
raise CommandExecutionError(err)
|
||||
|
||||
use_list = _LooseVersion(chocolatey_version()) >= _LooseVersion('0.9.9')
|
||||
if use_list:
|
||||
choco_cmd = "list"
|
||||
else:
|
||||
choco_cmd = "version"
|
||||
|
||||
cmd = [choc_path, choco_cmd, name]
|
||||
cmd = [choc_path, 'list', name]
|
||||
if not salt.utils.is_true(check_remote):
|
||||
cmd.append('-LocalOnly')
|
||||
if salt.utils.is_true(pre_versions):
|
||||
|
@ -810,22 +804,11 @@ def version(name, check_remote=False, source=None, pre_versions=False):
|
|||
ret = {}
|
||||
|
||||
res = result['stdout'].split('\n')
|
||||
if use_list:
|
||||
res = res[:-1]
|
||||
|
||||
# the next bit is to deal with the stupid default PowerShell formatting.
|
||||
# printing two value pairs is shown in columns, whereas printing six
|
||||
# pairs is shown in rows...
|
||||
if not salt.utils.is_true(check_remote):
|
||||
ver_re = re.compile(r'(\S+)\s+(.+)')
|
||||
for line in res:
|
||||
ver_re = re.compile(r'(\S+)\s+(.+)')
|
||||
for line in res:
|
||||
if 'packages found' not in line and 'packages installed' not in line:
|
||||
for name, ver in ver_re.findall(line):
|
||||
ret['name'] = name
|
||||
ret['found'] = ver
|
||||
else:
|
||||
ver_re = re.compile(r'(\S+)\s+:\s*(.*)')
|
||||
for line in res:
|
||||
for key, value in ver_re.findall(line):
|
||||
ret[key] = value
|
||||
ret[name] = ver
|
||||
|
||||
return ret
|
||||
|
|
Loading…
Add table
Reference in a new issue