[migration] propose to open pdb on error during execution of rql/sql query stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 07 Sep 2010 23:02:08 +0200
branchstable
changeset 6187 348c7d93cda3
parent 6186 8ada7df95877
child 6188 e1c9610b2360
[migration] propose to open pdb on error during execution of rql/sql query
migration.py
server/migractions.py
--- a/migration.py	Tue Sep 07 23:00:53 2010 +0200
+++ b/migration.py	Tue Sep 07 23:02:08 2010 +0200
@@ -199,7 +199,8 @@
         if not ask_confirm or self.confirm(msg):
             return meth(*args, **kwargs)
 
-    def confirm(self, question, shell=True, abort=True, retry=False, default='y'):
+    def confirm(self, question, shell=True, abort=True, retry=False, pdb=False,
+                default='y'):
         """ask for confirmation and return true on positive answer
 
         if `retry` is true the r[etry] answer may return 2
@@ -207,6 +208,8 @@
         possibleanswers = ['y', 'n']
         if abort:
             possibleanswers.append('abort')
+        if pdb:
+            possibleanswers.append('pdb')
         if shell:
             possibleanswers.append('shell')
         if retry:
@@ -221,9 +224,13 @@
             return 2
         if answer == 'abort':
             raise SystemExit(1)
-        if shell and answer == 'shell':
+        if answer == 'shell':
             self.interactive_shell()
-            return self.confirm(question)
+            return self.confirm(question, shell, abort, retry, pdb, default)
+        if answer == 'pdb':
+            import pdb
+            pdb.set_trace()
+            return self.confirm(question, shell, abort, retry, pdb, default)
         return True
 
     def interactive_shell(self):
--- a/server/migractions.py	Tue Sep 07 23:00:53 2010 +0200
+++ b/server/migractions.py	Tue Sep 07 23:02:08 2010 +0200
@@ -1327,7 +1327,7 @@
                 cu = self.session.system_sql(sql, args)
             except:
                 ex = sys.exc_info()[1]
-                if self.confirm('Error: %s\nabort?' % ex):
+                if self.confirm('Error: %s\nabort?' % ex, pdb=True):
                     raise
                 return
             try:
@@ -1355,7 +1355,7 @@
                 try:
                     res = execute(rql, kwargs, build_descr=build_descr)
                 except Exception, ex:
-                    if self.confirm('Error: %s\nabort?' % ex):
+                    if self.confirm('Error: %s\nabort?' % ex, pdb=True):
                         raise
         return res