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) log.error(err)
raise CommandExecutionError(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" choco_cmd = "list"
else: else:
choco_cmd = "version" choco_cmd = "version"
@ -687,18 +688,22 @@ def version(name, check_remote=False, source=None, pre_versions=False):
ret = {} ret = {}
res = result['stdout'].split('\n')
if use_list:
res = res[:-1]
# the next bit is to deal with the stupid default PowerShell formatting. # the next bit is to deal with the stupid default PowerShell formatting.
# printing two value pairs is shown in columns, whereas printing six # printing two value pairs is shown in columns, whereas printing six
# pairs is shown in rows... # pairs is shown in rows...
if not salt.utils.is_true(check_remote): if not salt.utils.is_true(check_remote):
ver_re = re.compile(r'(\S+)\s+(.+)') 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): for name, ver in ver_re.findall(line):
ret['name'] = name ret['name'] = name
ret['found'] = ver ret['found'] = ver
else: else:
ver_re = re.compile(r'(\S+)\s+:\s*(.*)') 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): for key, value in ver_re.findall(line):
ret[key] = value ret[key] = value