diff options
| -rw-r--r-- | apt/progress/text.py | 14 | ||||
| -rw-r--r-- | debian/changelog | 7 | ||||
| -rw-r--r-- | tests/test_apt_cache.py | 6 |
3 files changed, 18 insertions, 9 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 17c6abc3..718d45dd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.7.100.1) UNRELEASED; urgency=low + + * 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 + python-apt (0.7.100ubuntu2) natty; urgency=low * python/generic.h: diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index 0b33a2e3..cfb3ab99 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -59,13 +59,13 @@ class TestAptCache(unittest.TestCase): self.assertTrue(len(l) > 0) self.assertTrue("postfix" in [p.name for p in l]) # this is a not virtual (transitional) package provided by another - l = cache.get_providing_packages("scrollkeeper") + l = cache.get_providing_packages("git-core") self.assertEqual(l, []) # now inlcude nonvirtual packages in the search (rarian-compat # provides scrollkeeper) - l = cache.get_providing_packages("scrollkeeper", + l = cache.get_providing_packages("git-core", include_nonvirtual=True) - self.assertTrue(len(l), 1) + self.assertEqual([p.name for p in l], ["git"]) self.assertTrue("mail-transport-agent" in cache["postfix"].candidate.provides) def test_low_level_pkg_provides(self): |
