From 44a46d2b10d7c2bbfaef39411bc165b3ed525c11 Mon Sep 17 00:00:00 2001 From: stamparm Date: Fri, 22 Feb 2013 10:18:22 +0100 Subject: [PATCH] Fix for an Issue #409 --- lib/core/common.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index f4c926b30..153750fa8 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -1510,6 +1510,7 @@ def isHexEncodedString(subject): return re.match(r"\A[0-9a-fA-Fx]+\Z", subject) is not None +@cachedmethod def getConsoleWidth(default=80): """ Returns console width @@ -1520,11 +1521,15 @@ def getConsoleWidth(default=80): if os.getenv("COLUMNS", "").isdigit(): width = int(os.getenv("COLUMNS")) else: - output = execute("stty size", shell=True, stdout=PIPE, stderr=PIPE).stdout.read() - items = output.split() + try: + process = execute("stty size", shell=True, stdout=PIPE, stderr=PIPE) + stdout, _ = process.communicate() + items = stdout.split() - if len(items) == 2 and items[1].isdigit(): - width = int(items[1]) + if len(items) == 2 and items[1].isdigit(): + width = int(items[1]) + except OSError: + pass if width is None: try: