[migration/pdb] display traceback instead of only the exception for easier debugging

Closes #17219820

authorLaurent Peuch <cortex@worlddomination.be>
changeset5c432a7fc442
branchdefault
phasepublic
hiddenno
parent revision#cc681b6fcffa [migration/pdb] add option to use pdb.post_mortem if traceback is provided
child revision#ff63319a1730 Merge 3.26
files modified by this revision
cubicweb/server/migractions.py
# HG changeset patch
# User Laurent Peuch <cortex@worlddomination.be>
# Date 1558564384 -7200
# Thu May 23 00:33:04 2019 +0200
# Node ID 5c432a7fc442e170c9005666131b01a88a5c9334
# Parent cc681b6fcffab8fea64b33fa2736769ed6276797
[migration/pdb] display traceback instead of only the exception for easier debugging

Closes #17219820

diff --git a/cubicweb/server/migractions.py b/cubicweb/server/migractions.py
@@ -30,10 +30,11 @@
1  import sys
2  import os
3  import tarfile
4  import tempfile
5  import shutil
6 +import traceback
7  import os.path as osp
8  from datetime import datetime
9  from glob import glob
10  from copy import copy
11  from contextlib import contextmanager
@@ -1454,12 +1455,12 @@
12          if not ask_confirm or self.confirm('Execute sql: %s ?' % sql):
13              try:
14                  cu = self.cnx.system_sql(sql, args)
15              except Exception:
16                  _, ex, traceback_ = sys.exc_info()
17 -                if self.confirm('Error: %s\nabort?' % ex,
18 -                                pdb=True, traceback=traceback_):
19 +                traceback.print_exc()
20 +                if self.confirm('abort?', pdb=True, traceback=traceback_):
21                      raise
22                  return
23              try:
24                  return cu.fetchall()
25              except Exception:
@@ -1481,12 +1482,12 @@
26              if not ask_confirm or self.confirm('Execute rql: %s ?' % msg):
27                  try:
28                      res = execute(rql, kwargs, build_descr=build_descr)
29                  except Exception:
30                      _, ex, traceback_ = sys.exc_info()
31 -                    if self.confirm('Error: %s\nabort?' % ex,
32 -                                    pdb=True, traceback=traceback_):
33 +                    traceback.print_exc()
34 +                    if self.confirm('abort?', pdb=True, traceback=traceback_):
35                          raise
36          return res
37 
38      def rqliter(self, rql, kwargs=None, ask_confirm=True):
39          return ForRqlIterator(self, rql, kwargs, ask_confirm)
@@ -1572,12 +1573,12 @@
40                  raise StopIteration
41          try:
42              return self._h._cw.execute(rql, kwargs)
43          except Exception:
44              _, ex, traceback_ = sys.exc_info()
45 -            if self._h.confirm('Error: %s\nabort?' % ex,
46 -                               pdb=True, traceback=traceback_):
47 +            traceback.print_exc()
48 +            if self._h.confirm('abort?', pdb=True, traceback=traceback_):
49                  raise
50              else:
51                  raise StopIteration
52 
53      def __next__(self):