diff options
Diffstat (limited to 'progress.py')
-rw-r--r-- | progress.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/progress.py b/progress.py index b119b374..2ace7010 100644 --- a/progress.py +++ b/progress.py | |||
@@ -13,10 +13,13 @@ | |||
13 | # See the License for the specific language governing permissions and | 13 | # See the License for the specific language governing permissions and |
14 | # limitations under the License. | 14 | # limitations under the License. |
15 | 15 | ||
16 | import os | ||
16 | import sys | 17 | import sys |
17 | from time import time | 18 | from time import time |
18 | from trace import IsTrace | 19 | from trace import IsTrace |
19 | 20 | ||
21 | _NOT_TTY = not os.isatty(2) | ||
22 | |||
20 | class Progress(object): | 23 | class Progress(object): |
21 | def __init__(self, title, total=0): | 24 | def __init__(self, title, total=0): |
22 | self._title = title | 25 | self._title = title |
@@ -29,7 +32,7 @@ class Progress(object): | |||
29 | def update(self, inc=1): | 32 | def update(self, inc=1): |
30 | self._done += inc | 33 | self._done += inc |
31 | 34 | ||
32 | if IsTrace(): | 35 | if _NOT_TTY or IsTrace(): |
33 | return | 36 | return |
34 | 37 | ||
35 | if not self._show: | 38 | if not self._show: |
@@ -56,7 +59,7 @@ class Progress(object): | |||
56 | sys.stderr.flush() | 59 | sys.stderr.flush() |
57 | 60 | ||
58 | def end(self): | 61 | def end(self): |
59 | if IsTrace() or not self._show: | 62 | if _NOT_TTY or IsTrace() or not self._show: |
60 | return | 63 | return |
61 | 64 | ||
62 | if self._total <= 0: | 65 | if self._total <= 0: |