~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

  • Committer: John Arbash Meinel
  • Date: 2009-12-18 17:42:30 UTC
  • mto: This revision was merged to the branch mainline in revision 4934.
  • Revision ID: john@arbash-meinel.com-20091218174230-2xrmkkbw4f5idufr
Play around with the ui display a bit more.
Went through a lot of permutations, I think I like this one the most.

Show diffs side-by-side

added added

removed removed

Lines of Context:
264
264
        self._last_task = None
265
265
        self._total_byte_count = 0
266
266
        self._bytes_since_update = 0
 
267
        self._bytes_by_direction = {'unknown': 0, 'read': 0, 'write': 0}
267
268
        self._fraction = 0
268
269
        # force the progress bar to be off, as at the moment it doesn't 
269
270
        # correspond reliably to overall command progress
381
382
        # here.
382
383
        self._total_byte_count += byte_count
383
384
        self._bytes_since_update += byte_count
 
385
        if direction in self._bytes_by_direction:
 
386
            self._bytes_by_direction[direction] += byte_count
 
387
        else:
 
388
            self._bytes_by_direction['unknown'] += byte_count
384
389
        if not self._have_output:
385
390
            # As a workaround for <https://launchpad.net/bugs/321935> we only
386
391
            # show transport activity when there's already a progress bar
408
413
            self._last_transport_msg = msg
409
414
            self._repaint()
410
415
 
 
416
    def _format_bytes_by_direction(self):
 
417
        msg = ('Transferred: %.3fMiB'
 
418
               ' (r:%.3fMiB w:%.3fMiB'
 
419
               % (self._total_byte_count / 1024. / 1024.,
 
420
                  self._bytes_by_direction['read'] / 1024. / 1024.,
 
421
                  self._bytes_by_direction['write'] / 1024. / 1024.,
 
422
                 ))
 
423
        if self._bytes_by_direction['unknown'] > 0:
 
424
            msg += ' u:%.3fMiB)' % (
 
425
                self._bytes_by_direction['unknown'] / 1024. / 1024.
 
426
                )
 
427
        else:
 
428
            msg += ')'
 
429
        return msg
 
430
 
411
431
    def log_transport_activity(self, display=False):
412
 
        byte_message = 'Total byte count: %.3fMiB (%dB)' % (
413
 
                        self._total_byte_count / 1024. / 1024,
414
 
                        self._total_byte_count)
415
 
        trace.mutter(byte_message)
 
432
        msg = self._format_bytes_by_direction()
 
433
        trace.mutter(msg)
416
434
        if display:
417
435
            self.clear()
418
 
            self._term_file.write('%s\n' % (byte_message,))
 
436
            self._term_file.write(msg + '\n')
419
437
 
420
438
 
421
439
class TextUIOutputStream(object):