From 0a19061141de1fb70c5e3dc1a5e47f11f5b068fe Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Thu, 15 Mar 2012 13:28:20 -0400 Subject: [PATCH] Add error checking to get_terminal_size. Adds returncode error checking to get_terminal_size so that it doesn't spew errors to console when running glance commands in a shell without a TTY. Fixes LP Bug #956202. Change-Id: I42e155d168da1f4f25c0dea9ad9768686bd654ce --- glance/common/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/glance/common/utils.py b/glance/common/utils.py index 32ed731fa7..eaebd3a464 100644 --- a/glance/common/utils.py +++ b/glance/common/utils.py @@ -326,7 +326,9 @@ def _get_terminal_size_posix(): p = subprocess.Popen(['stty', 'size'], shell=False, stdout=subprocess.PIPE) - return tuple(int(x) for x in p.communicate()[0].split()) + result = p.communicate() + if p.returncode == 0: + return tuple(int(x) for x in result[0].split()) except: pass