/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: 2010-02-09 19:04:02 UTC
  • mfrom: (5010 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5019.
  • Revision ID: mbp@canonical.com-20100209190402-2xbzrchmb4dfi2j7
Resolve conflicts with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2005, 2008, 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
61
61
        # paints progress, network activity, etc
62
62
        self._progress_view = self.make_progress_view()
63
63
        
 
64
    def be_quiet(self, state):
 
65
        if state and not self._quiet:
 
66
            self.clear_term()
 
67
        UIFactory.be_quiet(self, state)
 
68
        self._progress_view = self.make_progress_view()
 
69
 
64
70
    def clear_term(self):
65
71
        """Prepare the terminal for output.
66
72
 
146
152
    def make_progress_view(self):
147
153
        """Construct and return a new ProgressView subclass for this UI.
148
154
        """
149
 
        # if the user specifically requests either text or no progress bars,
150
 
        # always do that.  otherwise, guess based on $TERM and tty presence.
151
 
        if os.environ.get('BZR_PROGRESS_BAR') == 'text':
 
155
        # with --quiet, never any progress view
 
156
        # <https://bugs.edge.launchpad.net/bzr/+bug/320035>.  Otherwise if the
 
157
        # user specifically requests either text or no progress bars, always
 
158
        # do that.  otherwise, guess based on $TERM and tty presence.
 
159
        if self.is_quiet():
 
160
            return NullProgressView()
 
161
        elif os.environ.get('BZR_PROGRESS_BAR') == 'text':
152
162
            return TextProgressView(self.stderr)
153
163
        elif os.environ.get('BZR_PROGRESS_BAR') == 'none':
154
164
            return NullProgressView()
411
421
        elif now >= (self._transport_update_time + 0.5):
412
422
            # guard against clock stepping backwards, and don't update too
413
423
            # often
414
 
            rate = self._bytes_since_update / (now - self._transport_update_time)
415
 
            msg = ("%6dKB %5dKB/s" %
416
 
                    (self._total_byte_count>>10, int(rate)>>10,))
 
424
            rate = (self._bytes_since_update
 
425
                    / (now - self._transport_update_time))
 
426
            # using base-10 units (see HACKING.txt).
 
427
            msg = ("%6dkB %5dkB/s" %
 
428
                    (self._total_byte_count / 1000, int(rate) / 1000,))
417
429
            self._transport_update_time = now
418
430
            self._last_repaint = now
419
431
            self._bytes_since_update = 0
429
441
                transfer_time = 0.001
430
442
            bps = self._total_byte_count / transfer_time
431
443
 
432
 
        msg = ('Transferred: %.0fKiB'
433
 
               ' (%.1fK/s r:%.0fK w:%.0fK'
434
 
               % (self._total_byte_count / 1024.,
435
 
                  bps / 1024.,
436
 
                  self._bytes_by_direction['read'] / 1024.,
437
 
                  self._bytes_by_direction['write'] / 1024.,
 
444
        # using base-10 units (see HACKING.txt).
 
445
        msg = ('Transferred: %.0fkB'
 
446
               ' (%.1fkB/s r:%.0fkB w:%.0fkB'
 
447
               % (self._total_byte_count / 1000.,
 
448
                  bps / 1000.,
 
449
                  self._bytes_by_direction['read'] / 1000.,
 
450
                  self._bytes_by_direction['write'] / 1000.,
438
451
                 ))
439
452
        if self._bytes_by_direction['unknown'] > 0:
440
 
            msg += ' u:%.0fK)' % (
441
 
                self._bytes_by_direction['unknown'] / 1024.
 
453
            msg += ' u:%.0fkB)' % (
 
454
                self._bytes_by_direction['unknown'] / 1000.
442
455
                )
443
456
        else:
444
457
            msg += ')'