mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Remove traceback.format_exc()
calls where not needed.
This commit is contained in:
parent
113deeb3c7
commit
ddf2a6d8ff
@ -18,7 +18,6 @@ import datetime
|
||||
import pwd
|
||||
import getpass
|
||||
import resource
|
||||
import traceback
|
||||
import subprocess
|
||||
import multiprocessing
|
||||
import sys
|
||||
@ -1066,7 +1065,7 @@ class AESFuncs(object):
|
||||
id_ = minion.keys()[0]
|
||||
ret[id_] = minion[id_].get('ret', None)
|
||||
return ret
|
||||
|
||||
|
||||
|
||||
def run_func(self, func, load):
|
||||
'''
|
||||
@ -1080,9 +1079,11 @@ class AESFuncs(object):
|
||||
try:
|
||||
ret = getattr(self, func)(load)
|
||||
except Exception:
|
||||
trb = traceback.format_exc()
|
||||
ret = ''
|
||||
log.error('Error in function {0}:\n{1}'.format(func, trb))
|
||||
log.error(
|
||||
'Error in function {0}:\n'.format(func),
|
||||
exc_info=True
|
||||
)
|
||||
else:
|
||||
log.error(
|
||||
'Received function {0} which is unavailable on the master, '
|
||||
@ -1806,11 +1807,10 @@ class ClearFuncs(object):
|
||||
)
|
||||
)
|
||||
except Exception:
|
||||
trb = traceback.format_exc()
|
||||
log.critical(
|
||||
'The specified returner threw a stack trace:\n{0}'
|
||||
''.format(trb)
|
||||
)
|
||||
'The specified returner threw a stack trace:\n',
|
||||
exc_info=True
|
||||
)
|
||||
# Set up the payload
|
||||
payload = {'enc': 'aes'}
|
||||
# Altering the contents of the publish load is serious!! Changes here
|
||||
|
@ -329,11 +329,14 @@ class Minion(object):
|
||||
#if data['fun'] not in self.functions:
|
||||
# return
|
||||
if 'user' in data:
|
||||
log.info(('User {0[user]} Executing command {0[fun]} with jid '
|
||||
'{0[jid]}'.format(data)))
|
||||
log.info(
|
||||
'User {0[user]} Executing command {0[fun]} with jid '
|
||||
'{0[jid]}'.format(data)
|
||||
)
|
||||
else:
|
||||
log.info(('Executing command {0[fun]} with jid {0[jid]}'
|
||||
.format(data)))
|
||||
log.info(
|
||||
'Executing command {0[fun]} with jid {0[jid]}'.format(data)
|
||||
)
|
||||
log.debug('Command details {0}'.format(data))
|
||||
self._handle_decoded_payload(data)
|
||||
|
||||
@ -514,7 +517,7 @@ class Minion(object):
|
||||
trb = traceback.format_exc()
|
||||
log.warning(
|
||||
'The minion function caused an exception: {0}'.format(
|
||||
exc
|
||||
exc
|
||||
)
|
||||
)
|
||||
ret['return'][data['fun'][ind]] = trb
|
||||
@ -828,7 +831,10 @@ class Minion(object):
|
||||
# again
|
||||
continue
|
||||
except Exception:
|
||||
log.critical(traceback.format_exc())
|
||||
log.critical(
|
||||
'An exception occurred while polling the minion',
|
||||
exc_info=True
|
||||
)
|
||||
|
||||
def destroy(self):
|
||||
if hasattr(self, 'poller'):
|
||||
@ -1016,7 +1022,10 @@ class Syndic(Minion):
|
||||
# again
|
||||
continue
|
||||
except Exception:
|
||||
log.critical(traceback.format_exc())
|
||||
log.critical(
|
||||
'An exception occurred while polling the syndic',
|
||||
exc_info=True
|
||||
)
|
||||
|
||||
|
||||
class Matcher(object):
|
||||
|
@ -12,6 +12,7 @@ import logging
|
||||
import copy
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
from salt._compat import string_types
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -22,15 +23,20 @@ def __virtual__():
|
||||
Set the user module if the kernel is Linux or OpenBSD
|
||||
and remove some of the functionality on OS X
|
||||
'''
|
||||
# XXX: Why are these imports in __virtual__?
|
||||
import sys
|
||||
from salt._compat import callable
|
||||
if __grains__['kernel'] == 'Darwin':
|
||||
mod = sys.modules[__name__]
|
||||
for attr in dir(mod):
|
||||
if callable(getattr(mod, attr)):
|
||||
if not attr in ('_format_info', 'getent', 'info', 'list_groups', 'list_users', '__virtual__'):
|
||||
if not attr in ('_format_info', 'getent', 'info',
|
||||
'list_groups', 'list_users', '__virtual__'):
|
||||
delattr(mod, attr)
|
||||
return 'user' if __grains__['kernel'] in ('Linux', 'Darwin', 'OpenBSD') else False
|
||||
return (
|
||||
'user' if __grains__['kernel'] in ('Linux', 'Darwin', 'OpenBSD')
|
||||
else False
|
||||
)
|
||||
|
||||
|
||||
def _get_gecos(name):
|
||||
@ -91,14 +97,12 @@ def add(name,
|
||||
def usergroups():
|
||||
retval = False
|
||||
try:
|
||||
for line in open("/etc/login.defs"):
|
||||
if "USERGROUPS_ENAB" in line[:15]:
|
||||
for line in salt.utils.fopen('/etc/login.defs'):
|
||||
if 'USERGROUPS_ENAB' in line[:15]:
|
||||
if "yes" in line:
|
||||
retval = True
|
||||
except Exception:
|
||||
import traceback
|
||||
log.debug("Error reading /etc/login.defs")
|
||||
log.debug(traceback.format_exc())
|
||||
log.debug('Error reading /etc/login.defs', exc_info=True)
|
||||
return retval
|
||||
if usergroups():
|
||||
cmd += '-g {0} '.format(__salt__['file.group_to_gid'](name))
|
||||
|
@ -4,7 +4,6 @@ The JSON output module converts the return data into JSON.
|
||||
|
||||
# Import python libs
|
||||
import json
|
||||
import traceback
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -28,6 +27,6 @@ def output(data):
|
||||
return json.dumps(data)
|
||||
return json.dumps(data, indent=4)
|
||||
except TypeError:
|
||||
log.debug(traceback.format_exc())
|
||||
log.debug('An error occurred while outputting JSON', exc_info=True)
|
||||
# Return valid json for unserializable objects
|
||||
return json.dumps({})
|
||||
|
@ -9,7 +9,6 @@ The final result set is merged with the pillar data.
|
||||
# Import python libs
|
||||
import os
|
||||
import logging
|
||||
import traceback
|
||||
|
||||
# Import salt libs
|
||||
from salt.exceptions import SaltInvocationError
|
||||
@ -139,11 +138,8 @@ def _do_search(conf):
|
||||
except IndexError: # we got no results for this search
|
||||
result = {}
|
||||
except Exception:
|
||||
trace = traceback.format_exc()
|
||||
log.critical(
|
||||
'Failed to retrieve pillar data from LDAP: {0}'.format(
|
||||
trace
|
||||
)
|
||||
'Failed to retrieve pillar data from LDAP:\n', exc_info=True
|
||||
)
|
||||
return {}
|
||||
return result
|
||||
|
@ -1222,7 +1222,7 @@ class State(object):
|
||||
'result': False,
|
||||
'name': cdata['args'][0],
|
||||
'changes': {},
|
||||
'comment': 'An exception occured in this state: {0}'.format(
|
||||
'comment': 'An exception occurred in this state: {0}'.format(
|
||||
trb)
|
||||
}
|
||||
ret['__run_num__'] = self.__run_num
|
||||
@ -1784,16 +1784,21 @@ class BaseHighState(object):
|
||||
state = None
|
||||
try:
|
||||
state = compile_template(
|
||||
fn_, self.state.rend, self.state.opts['renderer'], env, sls, rendered_sls=mods)
|
||||
fn_, self.state.rend, self.state.opts['renderer'], env, sls,
|
||||
rendered_sls=mods
|
||||
)
|
||||
except Exception as exc:
|
||||
import traceback
|
||||
errors.append(('Rendering SLS {0} failed, render error:\n{1}\n{2}'
|
||||
.format(sls, traceback.format_exc(), exc)))
|
||||
errors.append(
|
||||
'Rendering SLS {0} failed, render error:\n{1}\n{2}'.format(
|
||||
sls, traceback.format_exc(), exc
|
||||
)
|
||||
)
|
||||
mods.add(sls)
|
||||
if state:
|
||||
if not isinstance(state, dict):
|
||||
errors.append(('SLS {0} does not render to a dictionary'
|
||||
.format(sls)))
|
||||
errors.append(
|
||||
'SLS {0} does not render to a dictionary'.format(sls)
|
||||
)
|
||||
else:
|
||||
include = []
|
||||
if 'include' in state:
|
||||
|
@ -130,9 +130,11 @@ class OptionParser(optparse.OptionParser):
|
||||
try:
|
||||
process_option_func()
|
||||
except Exception, err:
|
||||
self.error('Error while processing {0}: {1}'.format(
|
||||
process_option_func, traceback.format_exc(err)
|
||||
))
|
||||
self.error(
|
||||
'Error while processing {0}: {1}'.format(
|
||||
process_option_func, traceback.format_exc(err)
|
||||
)
|
||||
)
|
||||
|
||||
# Run the functions on self._mixin_after_parsed_funcs
|
||||
for mixin_after_parsed_func in self._mixin_after_parsed_funcs:
|
||||
|
Loading…
Reference in New Issue
Block a user