[migrations/pdb] add to every failing migration operation a "p(db)" option

Instead, the migration command will just crash without offering the possibility of the user to debug or continue the migration.

Closes #17219772

authorLaurent Peuch <cortex@worlddomination.be>
changeset3cf37ec616ad
branchdefault
phasepublic
hiddenno
parent revision#30b205676182 [pyramid/ctl] add a new option to activate the debugtoolbar (-t)
child revision#38d24fb2ae48 [cubicweb/utils] add QueryCache.__contains__() to improve dict-like behavior. Closes #255426
files modified by this revision
cubicweb/migration.py
# HG changeset patch
# User Laurent Peuch <cortex@worlddomination.be>
# Date 1558564411 -7200
# Thu May 23 00:33:31 2019 +0200
# Node ID 3cf37ec616ad341b1bdf5b84cdafdb3a6608def5
# Parent 30b205676182b2d1fdedd60c1098ad2fe2711bf7
[migrations/pdb] add to every failing migration operation a "p(db)" option

Instead, the migration command will just crash without offering the possibility
of the user to debug or continue the migration.

Closes #17219772

diff --git a/cubicweb/migration.py b/cubicweb/migration.py
@@ -21,10 +21,11 @@
1  import os
2  import string
3  import logging
4  import tempfile
5  import itertools
6 +import traceback
7  from os.path import exists, join, basename, splitext
8  from itertools import chain
9 
10  from logilab.common import IGNORED_EXTENSIONS
11  from logilab.common.decorators import cached
@@ -131,12 +132,18 @@
12          except AttributeError:
13              cmd = 'cmd_%s' % name
14              # search self.__class__ to avoid infinite recursion
15              if hasattr(self.__class__, cmd):
16                  meth = getattr(self, cmd)
17 -                return lambda *args, **kwargs: self.interact(args, kwargs,
18 -                                                             meth=meth)
19 +                try:
20 +                    return lambda *args, **kwargs: self.interact(args, kwargs,
21 +                                                                 meth=meth)
22 +                except:
23 +                    _, ex, traceback_ = sys.exc_info()
24 +                    traceback.print_exc()
25 +                    if self.confirm('abort?', pdb=True, traceback=traceback_):
26 +                        raise
27              raise
28          raise AttributeError(name)
29 
30      def migrate(self, vcconf, toupgrade, options):
31          """upgrade the given set of cubes