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)
|
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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user