|
|
@@ -13,10 +13,13 @@
|
|
|
# See the License for the specific language governing permissions and
|
|
|
# limitations under the License.
|
|
|
|
|
|
+import os
|
|
|
import sys
|
|
|
from time import time
|
|
|
from trace import IsTrace
|
|
|
|
|
|
+_NOT_TTY = not os.isatty(2)
|
|
|
+
|
|
|
class Progress(object):
|
|
|
def __init__(self, title, total=0):
|
|
|
self._title = title
|
|
|
@@ -29,7 +32,7 @@ class Progress(object):
|
|
|
def update(self, inc=1):
|
|
|
self._done += inc
|
|
|
|
|
|
- if IsTrace():
|
|
|
+ if _NOT_TTY or IsTrace():
|
|
|
return
|
|
|
|
|
|
if not self._show:
|
|
|
@@ -56,7 +59,7 @@ class Progress(object):
|
|
|
sys.stderr.flush()
|
|
|
|
|
|
def end(self):
|
|
|
- if IsTrace() or not self._show:
|
|
|
+ if _NOT_TTY or IsTrace() or not self._show:
|
|
|
return
|
|
|
|
|
|
if self._total <= 0:
|