# HG changeset patch # User Sylvain Thénault # Date 1283893328 -7200 # Node ID 348c7d93cda3375baecac63ab0ce69506371b7aa # Parent 8ada7df95877cca13555670a673c746288c3776d [migration] propose to open pdb on error during execution of rql/sql query diff -r 8ada7df95877 -r 348c7d93cda3 migration.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): diff -r 8ada7df95877 -r 348c7d93cda3 server/migractions.py --- 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