mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #19966 from rallytime/merge_forward_develop
Merge 2015.2 forward to develop
This commit is contained in:
commit
c851b9825c
@ -30,6 +30,23 @@ import salt.ext.six as six
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def try_printout(data, out, opts):
|
||||
'''
|
||||
Safely get the string to print out, try the configured outputter, then
|
||||
fall back to nested and then to raw
|
||||
'''
|
||||
try:
|
||||
return get_printout(out, opts)(data).rstrip()
|
||||
except (KeyError, AttributeError):
|
||||
log.debug(traceback.format_exc())
|
||||
opts.pop('output', None)
|
||||
try:
|
||||
return get_printout('nested', opts)(data).rstrip()
|
||||
except (KeyError, AttributeError):
|
||||
log.error('Nested output failed: ', exec_info=True)
|
||||
return get_printout('raw', opts)(data).rstrip()
|
||||
|
||||
|
||||
def get_progress(opts, out, progress):
|
||||
'''
|
||||
Get the progress bar from the given outputter
|
||||
@ -67,12 +84,7 @@ def display_output(data, out=None, opts=None):
|
||||
'''
|
||||
if opts is None:
|
||||
opts = {}
|
||||
try:
|
||||
display_data = get_printout(out, opts)(data).rstrip()
|
||||
except (KeyError, AttributeError):
|
||||
log.debug(traceback.format_exc())
|
||||
opts.pop('output', None)
|
||||
display_data = get_printout('nested', opts)(data).rstrip()
|
||||
display_data = try_printout(data, out, opts)
|
||||
|
||||
output_filename = opts.get('output_file', None)
|
||||
log.trace('data = {0}'.format(data))
|
||||
@ -137,8 +149,8 @@ def get_printout(out, opts=None, **kwargs):
|
||||
opts['color'] = True
|
||||
|
||||
outputters = salt.loader.outputters(opts)
|
||||
# TODO: raise an exception? This means if you do --out foobar you get nested
|
||||
if out not in outputters:
|
||||
log.error('Invalid outputter {0} specified, fall back to nested'.format(out))
|
||||
return outputters['nested']
|
||||
return outputters[out]
|
||||
|
||||
@ -147,7 +159,7 @@ def out_format(data, out, opts=None):
|
||||
'''
|
||||
Return the formatted outputter string for the passed data
|
||||
'''
|
||||
return get_printout(out, opts)(data).rstrip()
|
||||
return try_printout(data, out, opts)
|
||||
|
||||
|
||||
def strip_esc_sequence(txt):
|
||||
|
@ -186,7 +186,7 @@ class LinuxLVMTestCase(TestCase):
|
||||
for which physical volume to be used
|
||||
'''
|
||||
self.assertEqual(linux_lvm.lvcreate(None, None, 1, 1),
|
||||
'Error: Please specify only size or extents')
|
||||
'Error: Please specify only one of size or extents')
|
||||
|
||||
self.assertEqual(linux_lvm.lvcreate(None, None, None, None),
|
||||
'Error: Either size or extents must be specified')
|
||||
|
Loading…
Reference in New Issue
Block a user