/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Andrew Bennetts
  • Date: 2010-01-08 00:05:01 UTC
  • mfrom: (4938 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4948.
  • Revision ID: andrew.bennetts@canonical.com-20100108000501-8fj5j5ub6j5bd3es
MergeĀ lp:bzr

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
42
43
import subprocess
43
44
import tempfile
44
45
from tempfile import (
1427
1428
    _terminal_size = _ioctl_terminal_size
1428
1429
 
1429
1430
 
 
1431
def _terminal_size_changed(signum, frame):
 
1432
    """Set COLUMNS upon receiving a SIGnal for WINdow size CHange."""
 
1433
    width, height = _terminal_size(None, None)
 
1434
    if width is not None:
 
1435
        os.environ['COLUMNS'] = str(width)
 
1436
 
 
1437
if sys.platform == 'win32':
 
1438
    # Martin (gz) mentioned WINDOW_BUFFER_SIZE_RECORD from ReadConsoleInput but
 
1439
    # I've no idea how to plug that in the current design -- vila 20091216
 
1440
    pass
 
1441
else:
 
1442
    signal.signal(signal.SIGWINCH, _terminal_size_changed)
 
1443
 
 
1444
 
1430
1445
def supports_executable():
1431
1446
    return sys.platform != "win32"
1432
1447
 
2072
2087
    if use_cache:
2073
2088
        _cached_concurrency = concurrency
2074
2089
    return concurrency
 
2090
 
 
2091
 
 
2092
class UnicodeOrBytesToBytesWriter(codecs.StreamWriter):
 
2093
    """A stream writer that doesn't decode str arguments."""
 
2094
 
 
2095
    def __init__(self, encode, stream, errors='strict'):
 
2096
        codecs.StreamWriter.__init__(self, stream, errors)
 
2097
        self.encode = encode
 
2098
 
 
2099
    def write(self, object):
 
2100
        if type(object) is str:
 
2101
            self.stream.write(object)
 
2102
        else:
 
2103
            data, _ = self.encode(object, self.errors)
 
2104
            self.stream.write(data)