From 6ccca6d4c02c1f1d65c1b948cc3d4e0436e24a2c Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Thu, 7 May 2015 12:02:03 +0100 Subject: [PATCH] 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. --- wlauto/commands/show.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wlauto/commands/show.py b/wlauto/commands/show.py index e173fc08..c02554ac 100644 --- a/wlauto/commands/show.py +++ b/wlauto/commands/show.py @@ -48,10 +48,15 @@ class ShowCommand(Command): text = out.getvalue() pager = get_pager() if len(text.split('\n')) > term_height and pager: - sp = subprocess.Popen(pager, stdin=subprocess.PIPE) - sp.communicate(text) + try: + 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: sys.stdout.write(text) + sys.stdout.write(text) def format_extension(extension, out, width):