Use {} instead of dict() in error returns

This commit is contained in:
rallytime 2017-09-05 18:07:03 -04:00
parent 79c4ff7741
commit f438e707b8
2 changed files with 23 additions and 23 deletions

View File

@ -1020,7 +1020,7 @@ class LocalFuncs(object):
if error:
# Authentication error occurred: do not continue.
return dict(error=error)
return {'error': error}
# Authorize
runner_check = self.ckminions.runner_check(
@ -1030,9 +1030,9 @@ class LocalFuncs(object):
)
username = auth_check.get('username')
if not runner_check:
return dict(error=dict(name=err_name,
message=('Authentication failure of type "{0}" occurred '
'for user {1}.').format(auth_type, username)))
return {'error': {'name': err_name,
'message': 'Authentication failure of type "{0}" occurred '
'for user {1}.'.format(auth_type, username)}}
elif isinstance(runner_check, dict) and 'error' in runner_check:
# A dictionary with an error name/message was handled by ckminions.runner_check
return runner_check
@ -1047,9 +1047,9 @@ class LocalFuncs(object):
except Exception as exc:
log.error('Exception occurred while '
'introspecting {0}: {1}'.format(fun, exc))
return dict(error=dict(name=exc.__class__.__name__,
args=exc.args,
message=str(exc)))
return {'error': {'name': exc.__class__.__name__,
'args': exc.args,
'message': str(exc)}}
def wheel(self, load):
'''
@ -1069,7 +1069,7 @@ class LocalFuncs(object):
if error:
# Authentication error occurred: do not continue.
return dict(error=error)
return {'error': error}
# Authorize
username = auth_check.get('username')
@ -1080,9 +1080,9 @@ class LocalFuncs(object):
load['kwarg']
)
if not wheel_check:
return dict(error=dict(name=err_name,
message=('Authentication failure of type "{0}" occurred for '
'user {1}.').format(auth_type, username)))
return {'error': {'name': err_name,
'message': 'Authentication failure of type "{0}" occurred for '
'user {1}.'.format(auth_type, username)}}
elif isinstance(wheel_check, dict) and 'error' in wheel_check:
# A dictionary with an error name/message was handled by ckminions.wheel_check
return wheel_check

View File

@ -1675,7 +1675,7 @@ class ClearFuncs(object):
if error:
# Authentication error occurred: do not continue.
return dict(error=error)
return {'error': error}
# Authorize
username = auth_check.get('username')
@ -1686,9 +1686,9 @@ class ClearFuncs(object):
clear_load.get(u'kwarg', {})
)
if not runner_check:
return dict(error=dict(name=err_name,
message=(u'Authentication failure of type "{0}" occurred for '
u'user {1}.').format(auth_type, username)))
return {'error': {'name': err_name,
'message': u'Authentication failure of type "{0}" occurred for '
u'user {1}.'.format(auth_type, username)}}
elif isinstance(runner_check, dict) and u'error' in runner_check:
# A dictionary with an error name/message was handled by ckminions.runner_check
return runner_check
@ -1713,9 +1713,9 @@ class ClearFuncs(object):
username)
except Exception as exc:
log.error(u'Exception occurred while introspecting %s: %s', fun, exc)
return dict(error=dict(name=exc.__class__.__name__,
args=exc.args,
message=str(exc)))
return {'error': {'name': exc.__class__.__name__,
'args': exc.args,
'message': str(exc)}}
def wheel(self, clear_load):
'''
@ -1730,7 +1730,7 @@ class ClearFuncs(object):
if error:
# Authentication error occurred: do not continue.
return dict(error=error)
return {'error': error}
# Authorize
username = auth_check.get('username')
@ -1741,9 +1741,9 @@ class ClearFuncs(object):
clear_load.get(u'kwarg', {})
)
if not wheel_check:
return dict(error=dict(name=err_name,
message=(u'Authentication failure of type "{0}" occurred for '
u'user {1}.').format(auth_type, username)))
return {'error': {'name': err_name,
'message': u'Authentication failure of type "{0}" occurred for '
u'user {1}.'.format(auth_type, username)}}
elif isinstance(wheel_check, dict) and u'error' in wheel_check:
# A dictionary with an error name/message was handled by ckminions.wheel_check
return wheel_check