mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #26058 from Unity-Technologies/hotfix/fix-choco-pkg-version-2015-5
Fix choco version on chocolatey versions below 0.9.9
This commit is contained in:
commit
aa023f25b8
@ -665,7 +665,8 @@ def version(name, check_remote=False, source=None, pre_versions=False):
|
||||
log.error(err)
|
||||
raise CommandExecutionError(err)
|
||||
|
||||
if _LooseVersion(chocolatey_version()) >= _LooseVersion('0.9.9'):
|
||||
use_list = _LooseVersion(chocolatey_version()) >= _LooseVersion('0.9.9')
|
||||
if use_list:
|
||||
choco_cmd = "list"
|
||||
else:
|
||||
choco_cmd = "version"
|
||||
@ -687,18 +688,22 @@ 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 result['stdout'].split('\n')[:-1]:
|
||||
for line in res:
|
||||
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 result['stdout'].split('\n')[:-1]:
|
||||
for line in res:
|
||||
for key, value in ver_re.findall(line):
|
||||
ret[key] = value
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user