cubicweb/server/migractions.py
changeset 12745 cc681b6fcffa
parent 12742 ca698656251c
child 12746 5c432a7fc442
equal deleted inserted replaced
12744:19aef4729d45 12745:cc681b6fcffa
   260                     format = written_format
   260                     format = written_format
   261         repo = self.repo = repository.Repository(self.config)
   261         repo = self.repo = repository.Repository(self.config)
   262         source = repo.system_source
   262         source = repo.system_source
   263         try:
   263         try:
   264             source.restore(osp.join(tmpdir, source.uri), self.confirm, drop, format)
   264             source.restore(osp.join(tmpdir, source.uri), self.confirm, drop, format)
   265         except Exception as exc:
   265         except Exception:
       
   266             _, exc, traceback_ = sys.exc_info()
   266             print('-> error trying to restore %s [%s]' % (source.uri, exc))
   267             print('-> error trying to restore %s [%s]' % (source.uri, exc))
   267             if not self.confirm('Continue anyway?', default='n'):
   268             if not self.confirm('Continue anyway?', default='n', pdb=True, traceback=traceback_):
   268                 raise SystemExit(1)
   269                 raise SystemExit(1)
   269         finally:
   270         finally:
   270             shutil.rmtree(tmpdir)
   271             shutil.rmtree(tmpdir)
   271         # call hooks
   272         # call hooks
   272         repo.bootstrap()
   273         repo.bootstrap()
  1452         """
  1453         """
  1453         if not ask_confirm or self.confirm('Execute sql: %s ?' % sql):
  1454         if not ask_confirm or self.confirm('Execute sql: %s ?' % sql):
  1454             try:
  1455             try:
  1455                 cu = self.cnx.system_sql(sql, args)
  1456                 cu = self.cnx.system_sql(sql, args)
  1456             except Exception:
  1457             except Exception:
  1457                 ex = sys.exc_info()[1]
  1458                 _, ex, traceback_ = sys.exc_info()
  1458                 if self.confirm('Error: %s\nabort?' % ex, pdb=True):
  1459                 if self.confirm('Error: %s\nabort?' % ex,
       
  1460                                 pdb=True, traceback=traceback_):
  1459                     raise
  1461                     raise
  1460                 return
  1462                 return
  1461             try:
  1463             try:
  1462                 return cu.fetchall()
  1464                 return cu.fetchall()
  1463             except Exception:
  1465             except Exception:
  1477             else:
  1479             else:
  1478                 msg = rql
  1480                 msg = rql
  1479             if not ask_confirm or self.confirm('Execute rql: %s ?' % msg):
  1481             if not ask_confirm or self.confirm('Execute rql: %s ?' % msg):
  1480                 try:
  1482                 try:
  1481                     res = execute(rql, kwargs, build_descr=build_descr)
  1483                     res = execute(rql, kwargs, build_descr=build_descr)
  1482                 except Exception as ex:
  1484                 except Exception:
  1483                     if self.confirm('Error: %s\nabort?' % ex, pdb=True):
  1485                     _, ex, traceback_ = sys.exc_info()
       
  1486                     if self.confirm('Error: %s\nabort?' % ex,
       
  1487                                     pdb=True, traceback=traceback_):
  1484                         raise
  1488                         raise
  1485         return res
  1489         return res
  1486 
  1490 
  1487     def rqliter(self, rql, kwargs=None, ask_confirm=True):
  1491     def rqliter(self, rql, kwargs=None, ask_confirm=True):
  1488         return ForRqlIterator(self, rql, kwargs, ask_confirm)
  1492         return ForRqlIterator(self, rql, kwargs, ask_confirm)
  1566         if self.ask_confirm:
  1570         if self.ask_confirm:
  1567             if not self._h.confirm('Execute rql: %s ?' % msg):
  1571             if not self._h.confirm('Execute rql: %s ?' % msg):
  1568                 raise StopIteration
  1572                 raise StopIteration
  1569         try:
  1573         try:
  1570             return self._h._cw.execute(rql, kwargs)
  1574             return self._h._cw.execute(rql, kwargs)
  1571         except Exception as ex:
  1575         except Exception:
  1572             if self._h.confirm('Error: %s\nabort?' % ex):
  1576             _, ex, traceback_ = sys.exc_info()
       
  1577             if self._h.confirm('Error: %s\nabort?' % ex,
       
  1578                                pdb=True, traceback=traceback_):
  1573                 raise
  1579                 raise
  1574             else:
  1580             else:
  1575                 raise StopIteration
  1581                 raise StopIteration
  1576 
  1582 
  1577     def __next__(self):
  1583     def __next__(self):