Cleanup pkgin isatty mess

This commit is contained in:
Mike Zeller 2015-10-15 15:11:11 -07:00 committed by rallytime
parent 07cac0b434
commit ddf8a8d2bb

View file

@ -75,15 +75,6 @@ def _supports_regex():
return tuple([int(i) for i in _get_version()]) > (0, 5)
@decorators.memoize
def _supports_parsing():
'''
Check support of parsing
'''
return tuple([int(i) for i in _get_version()]) > (0, 7)
def __virtual__():
'''
Set the virtual pkg module if the os is supported by pkgin
@ -263,10 +254,9 @@ def list_pkgs(versions_as_list=False, **kwargs):
out = __salt__['cmd.run'](pkg_command, output_loglevel='trace')
for line in out.splitlines():
try:
if _supports_parsing():
pkg, ver = line.split(';', 1)[0].rsplit('-', 1)
else:
pkg, ver = line.split(' ', 1)[0].rsplit('-', 1)
# Some versions of pkgin check isatty unfortunately
# this results in cases where a ' ' or ';' can be used
pkg, ver = re.split('[; ]', line, 1)[0].rsplit('-', 1)
except ValueError:
continue
__salt__['pkg_resource.add_pkg'](ret, pkg, ver)