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:
Mike Place 2015-08-06 12:50:10 -06:00
commit aa023f25b8

View File

@ -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