server/sqlutils.py
changeset 10411 4ee15441f2eb
parent 10205 737271ffe407
parent 10375 28ec01db78b3
child 10588 fdaa0e4b7eaf
child 10643 cfded6d0da11
equal deleted inserted replaced
10410:eb681a030699 10411:4ee15441f2eb
    26 from os.path import abspath
    26 from os.path import abspath
    27 from itertools import ifilter
    27 from itertools import ifilter
    28 from logging import getLogger
    28 from logging import getLogger
    29 
    29 
    30 from logilab import database as db, common as lgc
    30 from logilab import database as db, common as lgc
    31 from logilab.common.shellutils import ProgressBar
    31 from logilab.common.shellutils import ProgressBar, DummyProgressBar
    32 from logilab.common.deprecation import deprecated
    32 from logilab.common.deprecation import deprecated
    33 from logilab.common.logging_ext import set_log_methods
    33 from logilab.common.logging_ext import set_log_methods
    34 from logilab.database.sqlgen import SQLGenerator
    34 from logilab.database.sqlgen import SQLGenerator
    35 
    35 
    36 from cubicweb import Binary, ConfigurationError
    36 from cubicweb import Binary, ConfigurationError
    70     sqlstmts_as_string = False
    70     sqlstmts_as_string = False
    71     if isinstance(sqlstmts, basestring):
    71     if isinstance(sqlstmts, basestring):
    72         sqlstmts_as_string = True
    72         sqlstmts_as_string = True
    73         sqlstmts = sqlstmts.split(delimiter)
    73         sqlstmts = sqlstmts.split(delimiter)
    74     if withpb:
    74     if withpb:
    75         pb = ProgressBar(len(sqlstmts), title=pbtitle)
    75         if sys.stdout.isatty():
       
    76             pb = ProgressBar(len(sqlstmts), title=pbtitle)
       
    77         else:
       
    78             pb = DummyProgressBar()
    76     failed = []
    79     failed = []
    77     for sql in sqlstmts:
    80     for sql in sqlstmts:
    78         sql = sql.strip()
    81         sql = sql.strip()
    79         if withpb:
    82         if withpb:
    80             pb.update()
    83             pb.update()