~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/progress.py

Merge from integration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
from collections import deque
43
43
 
44
44
 
45
 
def _width():
46
 
    """Return estimated terminal width.
47
 
 
48
 
    TODO: Do something smart on Windows?
49
 
 
50
 
    TODO: Is there anything that gets a better update when the window
51
 
          is resized while the program is running?
52
 
    """
53
 
    try:
54
 
        return int(os.environ['COLUMNS'])
55
 
    except (IndexError, KeyError, ValueError):
56
 
        return 80
57
 
 
58
 
 
59
45
def _supports_progress(f):
60
46
    if not hasattr(f, 'isatty'):
61
47
        return False
162
148
 
163
149
 
164
150
    def __init__(self, **kwargs):
 
151
        from bzrlib.osutils import terminal_width
165
152
        _BaseProgressBar.__init__(self, **kwargs)
166
153
        self.spin_pos = 0
167
 
        self.width = _width()
 
154
        self.width = terminal_width()
168
155
        self.start_time = None
169
156
        self.last_update = None
170
157
        self.last_updates = deque()