From f49287cf09b6d837cdbc72a8613b8603a7b308d4 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Mon, 1 Jun 2015 10:05:23 +0100 Subject: [PATCH] Fixes for Emacs - Do not try to use a pager if it explicitly disabled with PAGER='' in the environment. - If terminal size is identified as (0, 0), fall back to default (80, 25). --- wlauto/utils/misc.py | 4 ++-- wlauto/utils/terminalsize.py | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/wlauto/utils/misc.py b/wlauto/utils/misc.py index 121fac68..ac770d59 100644 --- a/wlauto/utils/misc.py +++ b/wlauto/utils/misc.py @@ -523,9 +523,9 @@ def load_class(classpath): def get_pager(): """Returns the name of the system pager program.""" pager = os.getenv('PAGER') - if not pager: + if pager is None: pager = find_executable('less') - if not pager: + if pager is None: pager = find_executable('more') return pager diff --git a/wlauto/utils/terminalsize.py b/wlauto/utils/terminalsize.py index c9fc430f..828ca3e6 100644 --- a/wlauto/utils/terminalsize.py +++ b/wlauto/utils/terminalsize.py @@ -20,13 +20,12 @@ def get_terminal_size(): if current_os == 'Windows': tuple_xy = _get_terminal_size_windows() if tuple_xy is None: + # needed for window's python in cygwin's xterm tuple_xy = _get_terminal_size_tput() - # needed for window's python in cygwin's xterm! if current_os in ['Linux', 'Darwin'] or current_os.startswith('CYGWIN'): tuple_xy = _get_terminal_size_linux() - if tuple_xy is None: - print "default" - tuple_xy = (80, 25) # default value + if tuple_xy is None or tuple_xy == (0, 0): + tuple_xy = (80, 25) # assume "standard" terminal return tuple_xy