1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-02-21 20:38:57 +00:00

show command: handle bad PAGER

If show command finds a PAGER defined in the user's environment but is
unable to use it, fall back to dumping output directly to STDOUT.
This commit is contained in:
Sergei Trofimov 2015-05-07 12:02:03 +01:00
parent 57972a56af
commit 6ccca6d4c0

View File

@ -48,10 +48,15 @@ class ShowCommand(Command):
text = out.getvalue() text = out.getvalue()
pager = get_pager() pager = get_pager()
if len(text.split('\n')) > term_height and pager: if len(text.split('\n')) > term_height and pager:
sp = subprocess.Popen(pager, stdin=subprocess.PIPE) try:
sp.communicate(text) sp = subprocess.Popen(pager, stdin=subprocess.PIPE)
sp.communicate(text)
except OSError:
self.logger.warning('Could not use PAGER "{}"'.format(pager))
sys.stdout.write(text)
else: else:
sys.stdout.write(text) sys.stdout.write(text)
sys.stdout.write(text)
def format_extension(extension, out, width): def format_extension(extension, out, width):