Merge pull request #25714 from cachedout/issue_25435

Display warning when progressbar can't be loaded
This commit is contained in:
Justin Findlay 2015-07-24 18:10:13 -06:00
commit ad8456eeed
2 changed files with 10 additions and 3 deletions

View File

@ -179,7 +179,10 @@ class SaltCMD(parsers.SaltCMDOptionParser):
ret = {}
for progress in cmd_func(**kwargs):
out = 'progress'
self._progress_ret(progress, out)
try:
self._progress_ret(progress, out)
except salt.exceptions.LoaderError as exc:
raise salt.exceptions.SaltSystemExit(exc)
if 'return_count' not in progress:
ret.update(progress)
self._progress_end(out)
@ -272,7 +275,11 @@ class SaltCMD(parsers.SaltCMDOptionParser):
import salt.output
# Get the progress bar
if not hasattr(self, 'progress_bar'):
self.progress_bar = salt.output.get_progress(self.config, out, progress)
try:
self.progress_bar = salt.output.get_progress(self.config, out, progress)
except Exception as exc:
raise salt.exceptions.LoaderError('\nWARNING: Install the `progressbar` python package. '
'Requested job was still run but output cannot be displayed.\n')
salt.output.update_progress(self.config, progress, self.progress_bar, out)
def _output_ret(self, ret, out):

View File

@ -1485,7 +1485,7 @@ class SaltCMDOptionParser(OptionParser, ConfigDirMixIn, MergeConfigMixIn,
'-p', '--progress',
default=False,
action='store_true',
help=('Display a progress graph')
help=('Display a progress graph. [Requires `progressbar` python package.]')
)
self.add_option(
'--failhard',