PEP8 fixes from PyLint

This commit is contained in:
Erik Johnson 2013-01-23 23:15:20 -06:00
parent bc5ec217a7
commit 8cbd3b39f4

View File

@ -118,11 +118,11 @@ class SMinion(object):
Load all of the modules for the minion
'''
self.opts['pillar'] = salt.pillar.get_pillar(
self.opts,
self.opts['grains'],
self.opts['id'],
self.opts['environment'],
).compile_pillar()
self.opts,
self.opts['grains'],
self.opts['id'],
self.opts['environment'],
).compile_pillar()
self.functions = salt.loader.minion_mods(self.opts)
self.returners = salt.loader.returners(self.opts, self.functions)
self.states = salt.loader.states(self.opts, self.functions)
@ -160,8 +160,8 @@ class MasterMinion(object):
Load all of the modules for the minion
'''
self.functions = salt.loader.minion_mods(
self.opts,
whitelist=self.whitelist)
self.opts,
whitelist=self.whitelist)
if self.mk_returners:
self.returners = salt.loader.returners(self.opts, self.functions)
if self.mk_states:
@ -192,16 +192,16 @@ class Minion(object):
opts['grains'],
opts['id'],
opts['environment'],
).compile_pillar()
).compile_pillar()
self.serial = salt.payload.Serial(self.opts)
self.mod_opts = self.__prep_mod_opts()
self.functions, self.returners = self.__load_modules()
self.matcher = Matcher(self.opts, self.functions)
self.proc_dir = get_proc_dir(opts['cachedir'])
self.schedule = salt.utils.schedule.Schedule(
self.opts,
self.functions,
self.returners)
self.opts,
self.functions,
self.returners)
def __prep_mod_opts(self):
'''
@ -276,10 +276,10 @@ class Minion(object):
# return
if 'user' in data:
log.info(('User {0[user]} Executing command {0[fun]} with jid '
'{0[jid]}'.format(data)))
'{0[jid]}'.format(data)))
else:
log.info(('Executing command {0[fun]} with jid {0[jid]}'
.format(data)))
.format(data)))
log.debug('Command details {0}'.format(data))
self._handle_decoded_payload(data)
@ -396,14 +396,14 @@ class Minion(object):
try:
minion_instance.returners['{0}.returner'.format(
returner
)](ret)
)](ret)
except Exception as exc:
log.error(
'The return failed for job {0} {1}'.format(
data['jid'],
exc
)
)
'The return failed for job {0} {1}'.format(
data['jid'],
exc
)
)
@classmethod
def _thread_multi_return(class_, minion_instance, opts, data):
@ -416,9 +416,9 @@ class Minion(object):
if not minion_instance:
minion_instance = class_(opts)
ret = {
'return': {},
'success': {},
}
'return': {},
'success': {},
}
for ind in range(0, len(data['fun'])):
for index in range(0, len(data['arg'][ind])):
try:
@ -441,10 +441,10 @@ class Minion(object):
except Exception as exc:
trb = traceback.format_exc()
log.warning(
'The minion function caused an exception: {0}'.format(
exc
)
)
'The minion function caused an exception: {0}'.format(
exc
)
)
ret['return'][data['fun'][ind]] = trb
ret['jid'] = data['jid']
minion_instance._return_pub(ret)
@ -454,14 +454,14 @@ class Minion(object):
try:
minion_instance.returners['{0}.returner'.format(
returner
)](ret)
)](ret)
except Exception as exc:
log.error(
'The return failed for job {0} {1}'.format(
data['jid'],
exc
)
)
'The return failed for job {0} {1}'.format(
data['jid'],
exc
)
)
def _return_pub(self, ret, ret_cmd='_return'):
'''
@ -509,10 +509,10 @@ class Minion(object):
if self.opts['cache_jobs']:
# Local job cache has been enabled
fn_ = os.path.join(
self.opts['cachedir'],
'minion_jobs',
load['jid'],
'return.p')
self.opts['cachedir'],
'minion_jobs',
load['jid'],
'return.p')
jdir = os.path.dirname(fn_)
if not os.path.isdir(jdir):
os.makedirs(jdir)
@ -580,7 +580,7 @@ class Minion(object):
self.opts['grains'],
self.opts['id'],
self.opts['environment'],
).compile_pillar()
).compile_pillar()
try:
os.remove(fn_)
except OSError:
@ -607,21 +607,21 @@ class Minion(object):
# Start with the publish socket
id_hash = hashlib.md5(self.opts['id']).hexdigest()
epub_sock_path = os.path.join(
self.opts['sock_dir'],
'minion_event_{0}_pub.ipc'.format(id_hash)
)
self.opts['sock_dir'],
'minion_event_{0}_pub.ipc'.format(id_hash)
)
epull_sock_path = os.path.join(
self.opts['sock_dir'],
'minion_event_{0}_pull.ipc'.format(id_hash)
)
self.opts['sock_dir'],
'minion_event_{0}_pull.ipc'.format(id_hash)
)
self.epub_sock = self.context.socket(zmq.PUB)
if self.opts.get('ipc_mode', '') == 'tcp':
epub_uri = 'tcp://127.0.0.1:{0}'.format(
self.opts['tcp_pub_port']
)
self.opts['tcp_pub_port']
)
epull_uri = 'tcp://127.0.0.1:{0}'.format(
self.opts['tcp_pull_port']
)
self.opts['tcp_pull_port']
)
else:
epub_uri = 'ipc://{0}'.format(epub_sock_path)
epull_uri = 'ipc://{0}'.format(epull_sock_path)
@ -662,13 +662,13 @@ class Minion(object):
# Restrict access to the sockets
if not self.opts.get('ipc_mode', '') == 'tcp':
os.chmod(
epub_sock_path,
448
)
epub_sock_path,
448
)
os.chmod(
epull_sock_path,
448
)
epull_sock_path,
448
)
self.poller = zmq.Poller()
self.epoller = zmq.Poller()
@ -697,12 +697,12 @@ class Minion(object):
self.epoller.register(self.epull_sock, zmq.POLLIN)
# Send an event to the master that the minion is live
self._fire_master(
'Minion {0} started at {1}'.format(
self.opts['id'],
time.asctime()
),
'minion_start'
)
'Minion {0} started at {1}'.format(
self.opts['id'],
time.asctime()
),
'minion_start'
)
# Make sure to gracefully handle SIGUSR1
enable_sigusr1_handler()
@ -715,7 +715,7 @@ class Minion(object):
self.schedule.eval()
socks = dict(self.poller.poll(
self.opts['loop_interval'] * 1000)
)
)
if self.socket in socks and socks[self.socket] == zmq.POLLIN:
payload = self.serial.loads(self.socket.recv())
self._handle_payload(payload)
@ -826,20 +826,20 @@ class Syndic(Minion):
data['tgt_type'] = 'glob'
# Send out the publication
pub_data = self.local.pub(
data['tgt'],
data['fun'],
data['arg'],
data['tgt_type'],
data['ret'],
data['jid'],
data['to']
)
data['tgt'],
data['fun'],
data['arg'],
data['tgt_type'],
data['ret'],
data['jid'],
data['to']
)
# Gather the return data
ret = self.local.get_full_returns(
pub_data['jid'],
pub_data['minions'],
data['to']
)
pub_data['jid'],
pub_data['minions'],
data['to']
)
for minion in ret:
ret[minion] = ret[minion]['ret']
ret['jid'] = data['jid']
@ -880,7 +880,7 @@ class Matcher(object):
else:
log.error('Attempting to match with unknown matcher: {0}'.format(
matcher
))
))
return False
def glob_match(self, tgt):
@ -923,7 +923,7 @@ class Matcher(object):
return bool(fnmatch.fnmatch(
str(self.opts['grains'][comps[0]]).lower(),
comps[1].lower(),
))
))
def grain_pcre_match(self, tgt):
'''
@ -943,11 +943,11 @@ class Matcher(object):
return True
return False
return bool(
re.match(
comps[1].lower(),
str(self.opts['grains'][comps[0]]).lower()
)
)
re.match(
comps[1].lower(),
str(self.opts['grains'][comps[0]]).lower()
)
)
def data_match(self, tgt):
'''
@ -969,7 +969,7 @@ class Matcher(object):
return bool(fnmatch.fnmatch(
val,
comps[1],
))
))
def exsel_match(self, tgt):
'''
@ -1007,7 +1007,7 @@ class Matcher(object):
return bool(fnmatch.fnmatch(
str(self.opts['pillar'][comps[0]]).lower(),
comps[1].lower(),
))
))
def ipcidr_match(self, tgt):
'''
@ -1037,7 +1037,6 @@ class Matcher(object):
return self.opts['grains']['fqdn'] in range.expand(tgt)
return
def compound_match(self, tgt):
'''
Runs the compound target check
@ -1090,6 +1089,6 @@ class Matcher(object):
'''
if tgt in nodegroups:
return self.compound_match(
salt.utils.minions.nodegroup_comp(tgt, nodegroups)
)
salt.utils.minions.nodegroup_comp(tgt, nodegroups)
)
return False