~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Vincent Ladeuil
  • Date: 2009-12-09 14:24:07 UTC
  • mto: (4901.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4902.
  • Revision ID: v.ladeuil+lp@free.fr-20091209142407-qqdaebna2fyz9vam
catch SIGWINCH, but that means soem IO can be interrupted and the code
base is not ready for that.

* bzrlib/ui/text.py:
(TextProgressView._show_line): Refresh width in case a SIGWINCH
was received.

* bzrlib/osutils.py:
(_terminal_size_changed): Trivial implementation

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import stat
20
20
from stat import (S_ISREG, S_ISDIR, S_ISLNK, ST_MODE, ST_SIZE,
21
21
                  S_ISCHR, S_ISBLK, S_ISFIFO, S_ISSOCK)
 
22
import signal
22
23
import sys
23
24
import time
24
25
import warnings
1398
1399
        import struct, fcntl, termios
1399
1400
        s = struct.pack('HHHH', 0, 0, 0, 0)
1400
1401
        x = fcntl.ioctl(1, termios.TIOCGWINSZ, s)
1401
 
        width, height = struct.unpack('HHHH', x)[0:2]
 
1402
        height, width = struct.unpack('HHHH', x)[0:2]
1402
1403
    except (IOError, AttributeError):
1403
1404
        pass
1404
1405
    return width, height
1418
1419
    _terminal_size = _ioctl_terminal_size
1419
1420
 
1420
1421
 
 
1422
def _terminal_size_changed(signum, frame):
 
1423
    """Set COLUMNS upon receiving a SIGnal for WINdow size CHange."""
 
1424
    width, height = _terminal_size(None, None)
 
1425
    if width is not None:
 
1426
        os.environ['COLUMNS'] = str(width)
 
1427
signal.signal(signal.SIGWINCH, _terminal_size_changed)
 
1428
 
 
1429
 
1421
1430
def supports_executable():
1422
1431
    return sys.platform != "win32"
1423
1432