summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-07-20 01:43:00 +0000
committerZac Medico <zmedico@gentoo.org>2006-07-20 01:43:00 +0000
commitcfc7ab00ea2309ddbca5949a42d433011f3651a6 (patch)
treec585321593d17c6ff97eba823c4bfbb390ed578f
parent79db99700016a81cdcf3bbab20b8800314da39cc (diff)
downloadportage-cfc7ab00ea2309ddbca5949a42d433011f3651a6.tar.gz
portage-cfc7ab00ea2309ddbca5949a42d433011f3651a6.tar.bz2
portage-cfc7ab00ea2309ddbca5949a42d433011f3651a6.zip
Handle a potential ValueError when parsing the number of terminal columns.
svn path=/main/trunk/; revision=3954
-rw-r--r--pym/output.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/pym/output.py b/pym/output.py
index ee5a7bf62..f9d4fccb0 100644
--- a/pym/output.py
+++ b/pym/output.py
@@ -257,11 +257,20 @@ class EOutput:
self.__last_e_cmd = ""
self.__last_e_len = 0
self.quiet = False
- self.term_columns = int(os.getenv("COLUMNS", 0))
- if self.term_columns == 0:
- self.term_columns = int(commands.getoutput('set -- `stty size 2>/dev/null` ; echo "$2"'))
- if self.term_columns == 0:
- self.term_columns = 80
+ columns = 0
+ try:
+ columns = int(os.getenv("COLUMNS", 0))
+ except ValueError:
+ pass
+ if columns <= 0:
+ try:
+ columns = int(commands.getoutput(
+ 'set -- `stty size 2>/dev/null` ; echo "$2"'))
+ except ValueError:
+ pass
+ if columns <= 0:
+ columns = 80
+ self.term_columns = columns
def __eend(self, caller, errno, msg):
if errno == 0: