/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/ui/text.py

  • Committer: Martin Pool
  • Date: 2009-03-12 07:26:03 UTC
  • mto: This revision was merged to the branch mainline in revision 4144.
  • Revision ID: mbp@sourcefrog.net-20090312072603-2encofaehyg1iplv
Transport activity now shows scheme and direction

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
        This may update a progress bar, spinner, or similar display.
87
87
        By default it does nothing.
88
88
        """
89
 
        self._progress_view.show_transport_activity(byte_count)
 
89
        self._progress_view._show_transport_activity(transport,
 
90
            direction, byte_count)
90
91
 
91
92
    def _progress_updated(self, task):
92
93
        """A task has been updated and wants to be displayed.
154
155
            spin_str =  r'/-\|'[self._spin_pos % 4]
155
156
            self._spin_pos += 1
156
157
            cols = 20
157
 
            completion_fraction = \
158
 
                self._last_task._overall_completion_fraction() or 0
 
158
            if self._last_task is None:
 
159
                completion_fraction = 0
 
160
            else:
 
161
                completion_fraction = \
 
162
                    self._last_task._overall_completion_fraction() or 0
159
163
            markers = int(round(float(cols) * completion_fraction)) - 1
160
164
            bar_str = '[' + ('#' * markers + spin_str).ljust(cols) + '] '
161
165
            return bar_str
218
222
        self._last_repaint = now
219
223
        self._repaint()
220
224
 
221
 
    def show_transport_activity(self, byte_count):
222
 
        """Called by transports as they do IO.
 
225
    def _show_transport_activity(self, transport, direction, byte_count):
 
226
        """Called by transports via the ui_factory, as they do IO.
223
227
 
224
228
        This may update a progress bar, spinner, or similar display.
225
229
        By default it does nothing.
236
240
            # guard against clock stepping backwards, and don't update too
237
241
            # often
238
242
            rate = self._bytes_since_update / (now - self._transport_update_time)
239
 
            msg = ("%6dkB @ %4dkB/s" %
240
 
                (self._total_byte_count>>10, int(rate)>>10,))
 
243
            scheme = getattr(transport, '_scheme', None) or repr(transport)
 
244
            if direction == 'read':
 
245
                dir_char = '>'
 
246
            elif direction == 'write':
 
247
                dir_char = '<'
 
248
            else:
 
249
                dir_char = '?'
 
250
            msg = ("%.7s %s %6dkB %5dkB/s" %
 
251
                    (scheme, dir_char, self._total_byte_count>>10, int(rate)>>10,))
241
252
            self._transport_update_time = now
242
253
            self._last_repaint = now
243
254
            self._bytes_since_update = 0