server/sqlutils.py
changeset 10411 4ee15441f2eb
parent 10205 737271ffe407
parent 10375 28ec01db78b3
child 10588 fdaa0e4b7eaf
child 10643 cfded6d0da11
--- a/server/sqlutils.py	Mon Jun 22 14:15:16 2015 +0200
+++ b/server/sqlutils.py	Mon Jun 22 14:27:37 2015 +0200
@@ -28,7 +28,7 @@
 from logging import getLogger
 
 from logilab import database as db, common as lgc
-from logilab.common.shellutils import ProgressBar
+from logilab.common.shellutils import ProgressBar, DummyProgressBar
 from logilab.common.deprecation import deprecated
 from logilab.common.logging_ext import set_log_methods
 from logilab.database.sqlgen import SQLGenerator
@@ -72,7 +72,10 @@
         sqlstmts_as_string = True
         sqlstmts = sqlstmts.split(delimiter)
     if withpb:
-        pb = ProgressBar(len(sqlstmts), title=pbtitle)
+        if sys.stdout.isatty():
+            pb = ProgressBar(len(sqlstmts), title=pbtitle)
+        else:
+            pb = DummyProgressBar()
     failed = []
     for sql in sqlstmts:
         sql = sql.strip()