[pycopia] r739 committed - Dont fail when stdin is not a tty.

1 view
Skip to first unread message

pyc...@googlecode.com

unread,
Sep 4, 2013, 8:01:44 PM9/4/13
to pyc...@googlegroups.com
Revision: 739
Author: keith.dart
Date: Thu Sep 5 00:01:22 2013 UTC
Log: Dont fail when stdin is not a tty.

http://code.google.com/p/pycopia/source/detail?r=739

Modified:
/trunk/core/pycopia/cliutils.py

=======================================
--- /trunk/core/pycopia/cliutils.py Mon Apr 22 09:41:06 2013 UTC
+++ /trunk/core/pycopia/cliutils.py Thu Sep 5 00:01:22 2013 UTC
@@ -38,11 +38,14 @@


def _get_winsize(fd):
- import fcntl, struct, termios
- WINSIZEFMT = b"HHHH"
- winsize = fcntl.ioctl(fd, termios.TIOCGWINSZ,
b"\0"*struct.calcsize(WINSIZEFMT))
- l, c = struct.unpack(WINSIZEFMT, winsize)[:2] # row, col, xpix, ypix
- return max(l, 24), max(c, 80)
+ if os.isatty(fd):
+ import fcntl, struct, termios
+ WINSIZEFMT = b"HHHH"
+ winsize = fcntl.ioctl(fd, termios.TIOCGWINSZ,
b"\0"*struct.calcsize(WINSIZEFMT))
+ l, c = struct.unpack(WINSIZEFMT, winsize)[:2] # row, col, xpix,
ypix
+ return max(l, 24), max(c, 80)
+ else:
+ return 24, 80

LINES, COLUMNS = _get_winsize(0)
del _get_winsize
Reply all
Reply to author
Forward
0 new messages