summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt/progress/text.py14
-rw-r--r--debian/changelog2
2 files changed, 10 insertions, 6 deletions
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)."""
diff --git a/debian/changelog b/debian/changelog
index 1d59b94f..97a79f68 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,8 @@ python-apt (0.7.100.1) UNRELEASED; urgency=low
* python/depcache.cc:
- don't run "actiongroup.release()" if the object was already
deallocated
+ * apt/progress/text.py:
+ - only run ioctl for termios.TIOCGWINSZ if the fd is a tty
-- Michael Vogt <michael.vogt@ubuntu.com> Tue, 07 Dec 2010 13:41:07 +0100