~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-04-23 13:47:32 UTC
  • mfrom: (5179.1.1 integration2)
  • Revision ID: pqm@pqm.ubuntu.com-20100423134732-e01c947fwuvjwtl2
(vila, for gz) Use signal only where available

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
from shutil import (
40
40
    rmtree,
41
41
    )
42
 
import signal
43
42
import socket
44
43
import subprocess
45
44
import tempfile
1366
1365
        platform or Python version.
1367
1366
    """
1368
1367
    try:
 
1368
        import signal
1369
1369
        siginterrupt = signal.siginterrupt
 
1370
    except ImportError:
 
1371
        # This python implementation doesn't provide signal support, hence no
 
1372
        # handler exists
 
1373
        return None
1370
1374
    except AttributeError:
1371
1375
        # siginterrupt doesn't exist on this platform, or for this version
1372
1376
        # of Python.
1483
1487
 
1484
1488
 
1485
1489
_registered_sigwinch = False
1486
 
 
1487
1490
def watch_sigwinch():
1488
 
    """Register for SIGWINCH, once and only once."""
 
1491
    """Register for SIGWINCH, once and only once.
 
1492
 
 
1493
    Do nothing if the signal module is not available.
 
1494
    """
1489
1495
    global _registered_sigwinch
1490
1496
    if not _registered_sigwinch:
1491
 
        if sys.platform == 'win32':
1492
 
            # Martin (gz) mentioned WINDOW_BUFFER_SIZE_RECORD from
1493
 
            # ReadConsoleInput but I've no idea how to plug that in
1494
 
            # the current design -- vila 20091216
 
1497
        try:
 
1498
            import signal
 
1499
            if getattr(signal, "SIGWINCH", None) is not None:
 
1500
                set_signal_handler(signal.SIGWINCH, _terminal_size_changed)
 
1501
        except ImportError:
 
1502
            # python doesn't provide signal support, nothing we can do about it
1495
1503
            pass
1496
 
        else:
1497
 
            set_signal_handler(signal.SIGWINCH, _terminal_size_changed)
1498
1504
        _registered_sigwinch = True
1499
1505
 
1500
1506