| OLD | NEW |
| 1 # | 1 # |
| 2 # Copyright (C) 2009 The Android Open Source Project | 2 # Copyright (C) 2009 The Android Open Source Project |
| 3 # | 3 # |
| 4 # Licensed under the Apache License, Version 2.0 (the "License"); | 4 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 # you may not use this file except in compliance with the License. | 5 # you may not use this file except in compliance with the License. |
| 6 # You may obtain a copy of the License at | 6 # You may obtain a copy of the License at |
| 7 # | 7 # |
| 8 # http://www.apache.org/licenses/LICENSE-2.0 | 8 # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 # | 9 # |
| 10 # Unless required by applicable law or agreed to in writing, software | 10 # Unless required by applicable law or agreed to in writing, software |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 def update(self, inc=1): | 28 def update(self, inc=1): |
| 29 self._done += inc | 29 self._done += inc |
| 30 | 30 |
| 31 if not self._show: | 31 if not self._show: |
| 32 if 0.5 <= time() - self._start: | 32 if 0.5 <= time() - self._start: |
| 33 self._show = True | 33 self._show = True |
| 34 else: | 34 else: |
| 35 return | 35 return |
| 36 | 36 |
| 37 if self._total <= 0: | 37 if self._total <= 0: |
| 38 sys.stderr.write('\r%s: %d, ' % ( | 38 sys.stdout.write('\r%s: %d, ' % ( |
| 39 self._title, | 39 self._title, |
| 40 self._done)) | 40 self._done)) |
| 41 sys.stderr.flush() | 41 sys.stdout.flush() |
| 42 else: | 42 else: |
| 43 p = (100 * self._done) / self._total | 43 p = (100 * self._done) / self._total |
| 44 | 44 |
| 45 if self._lastp != p: | 45 if self._lastp != p: |
| 46 self._lastp = p | 46 self._lastp = p |
| 47 sys.stderr.write('\r%s: %3d%% (%d/%d) ' % ( | 47 sys.stdout.write('\r%s: %3d%% (%d/%d) ' % ( |
| 48 self._title, | 48 self._title, |
| 49 p, | 49 p, |
| 50 self._done, | 50 self._done, |
| 51 self._total)) | 51 self._total)) |
| 52 sys.stderr.flush() | 52 sys.stdout.flush() |
| 53 | 53 |
| 54 def end(self): | 54 def end(self): |
| 55 if not self._show: | 55 if not self._show: |
| 56 return | 56 return |
| 57 | 57 |
| 58 if self._total <= 0: | 58 if self._total <= 0: |
| 59 sys.stderr.write('\r%s: %d, done. \n' % ( | 59 sys.stdout.write('\r%s: %d, done. \n' % ( |
| 60 self._title, | 60 self._title, |
| 61 self._done)) | 61 self._done)) |
| 62 sys.stderr.flush() | 62 sys.stdout.flush() |
| 63 else: | 63 else: |
| 64 p = (100 * self._done) / self._total | 64 p = (100 * self._done) / self._total |
| 65 sys.stderr.write('\r%s: %3d%% (%d/%d), done. \n' % ( | 65 sys.stdout.write('\r%s: %3d%% (%d/%d), done. \n' % ( |
| 66 self._title, | 66 self._title, |
| 67 p, | 67 p, |
| 68 self._done, | 68 self._done, |
| 69 self._total)) | 69 self._total)) |
| 70 sys.stderr.flush() | 70 sys.stdout.flush() |
| OLD | NEW |