Handle a potential ValueError when parsing the number of terminal columns.
authorZac Medico <zmedico@gentoo.org>
Thu, 20 Jul 2006 01:43:00 +0000 (01:43 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 20 Jul 2006 01:43:00 +0000 (01:43 -0000)
svn path=/main/trunk/; revision=3954

pym/output.py

index ee5a7bf6202d16f5a392401fae0b2cada1afe8ce..f9d4fccb0079dbbe9691d9c7d235d555b3448669 100644 (file)
@@ -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: