summaryrefslogtreecommitdiff
path: root/apt/progress
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-12-13 13:26:39 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2010-12-13 13:26:39 +0100
commit2d26daec6a58a3f7529b46ada6ce17f8e882408d (patch)
tree33506483cb0b803e74a67aac310ced1eb56c080b /apt/progress
parent6a05a8302c405c4c8d1b59f6be8c2d0974c6ce1e (diff)
downloadpython-apt-2d26daec6a58a3f7529b46ada6ce17f8e882408d.tar.gz
* apt/progress/text.py:
- only run ioctl for termios.TIOCGWINSZ if the fd is a tty
Diffstat (limited to 'apt/progress')
-rw-r--r--apt/progress/text.py14
1 files changed, 8 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)."""