From 2d26daec6a58a3f7529b46ada6ce17f8e882408d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 13 Dec 2010 13:26:39 +0100 Subject: * apt/progress/text.py: - only run ioctl for termios.TIOCGWINSZ if the fd is a tty --- apt/progress/text.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'apt/progress') diff --git a/apt/progress/text.py b/apt/progress/text.py index 95f18831..d777837c 100644 --- a/apt/progress/text.py +++ b/apt/progress/text.py @@ -15,6 +15,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA """Progress reporting for text interfaces.""" +import os import sys import apt_pkg @@ -107,12 +108,13 @@ class AcquireProgress(base.AcquireProgress, TextProgress): def _winch(self, *dummy): """Signal handler for window resize signals.""" - import fcntl - import termios - import struct - buf = fcntl.ioctl(self._file, termios.TIOCGWINSZ, 8 * ' ') - dummy, col, dummy, dummy = struct.unpack('hhhh', buf) - self._width = col - 1 # 1 for the cursor + if hasattr(self._file, "fileno") and os.isatty(self._file.fileno()): + import fcntl + import termios + import struct + buf = fcntl.ioctl(self._file, termios.TIOCGWINSZ, 8 * ' ') + dummy, col, dummy, dummy = struct.unpack('hhhh', buf) + self._width = col - 1 # 1 for the cursor def ims_hit(self, item): """Called when an item is update (e.g. not modified on the server).""" -- cgit v1.2.3