Patch for an Issue #910

This commit is contained in:
Miroslav Stampar 2014-11-08 21:22:03 +01:00
parent 8fdf9ff746
commit 3b06665c9f

View File

@ -1693,13 +1693,16 @@ def getConsoleWidth(default=80):
width = int(os.getenv("COLUMNS")) width = int(os.getenv("COLUMNS"))
else: else:
try: try:
with open(os.devnull, 'w') as FNULL: try:
process = execute("stty size", shell=True, stdout=PIPE, stderr=FNULL) FNULL = open(os.devnull, 'w')
stdout, _ = process.communicate() except IOError:
items = stdout.split() FNULL = None
process = execute("stty size", shell=True, stdout=PIPE, stderr=FNULL or PIPE)
stdout, _ = process.communicate()
items = stdout.split()
if len(items) == 2 and items[1].isdigit(): if len(items) == 2 and items[1].isdigit():
width = int(items[1]) width = int(items[1])
except OSError: except OSError:
pass pass