Pylint fixes for PR #29139

This commit is contained in:
Thomas Desrosiers 2015-11-24 14:19:47 -05:00
parent e010f2d3b5
commit 56b3302fe9
2 changed files with 9 additions and 4 deletions

View File

@ -143,6 +143,7 @@ class RosterMatcher(object):
return self.raw[minion]
return False
def _convert_range_to_list(tgt, range_server):
'''
convert a seco.range range into a list target
@ -151,5 +152,5 @@ def _convert_range_to_list(tgt, range_server):
try:
return r.expand(tgt)
except seco.range.RangeException as err:
print('Range server exception: {0}'.format(err))
log.error('Range server exception: %s', err)
return []

View File

@ -11,7 +11,7 @@ When you want to use a range query for target matching, use ``--roster range``.
salt-ssh --roster range '%%%example.range.cluster' test.ping
'''
from __future__ import absolute_import
import fnmatch
import logging
@ -26,9 +26,11 @@ except ImportError:
log.error("Unable to load range library")
# pylint: enable=import-error
def __virtual__():
return HAS_RANGE
def targets(tgt, tgt_type='range', **kwargs):
'''
Return the targets from a range query
@ -62,8 +64,10 @@ def targets(tgt, tgt_type='range', **kwargs):
return targeted_hosts
def target_range(tgt, hosts):
return {host: {'host': host, 'user': __opts__['ssh_user']} for host in hosts}
return dict((host, {'host': host, 'user': __opts__['ssh_user']}) for host in hosts)
def target_glob(tgt, hosts):
return {host: {'host': host, 'user': __opts__['ssh_user']} for host in hosts if fnmatch.fnmatch(tgt, host)}
return dict((host, {'host': host, 'user': __opts__['ssh_user']}) for host in hosts if fnmatch.fnmatch(tgt, host))