get_term_size: handle missing stty command
authorZac Medico <zmedico@gentoo.org>
Fri, 27 Jul 2012 22:46:47 +0000 (15:46 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 27 Jul 2012 22:46:47 +0000 (15:46 -0700)
pym/portage/output.py

index 5129db77ef4fa270272c0abc5375ecc6012313d4..e44375ee38451ba304d14a054a5fd6752027cafe 100644 (file)
@@ -450,8 +450,15 @@ def get_term_size(fd=None):
        except ImportError:
                pass
 
-       proc = subprocess.Popen(["stty", "size"],
-               stdout=subprocess.PIPE, stderr=fd)
+       try:
+               proc = subprocess.Popen(["stty", "size"],
+                       stdout=subprocess.PIPE, stderr=fd)
+       except EnvironmentError as e:
+               if e.errno != errno.ENOENT:
+                       raise
+               # stty command not found
+               return (0, 0)
+
        out = _unicode_decode(proc.communicate()[0])
        if proc.wait() == os.EX_OK:
                out = out.split()