# HG changeset patch # User Laurent Peuch # Date 1553174910 -3600 # Node ID c53f66bcc641f381774f058fd9f552e2f31ce47c # Parent aff5d3498f68502f7963edd2cd45b4c83a2520ed [cli/enh] on 'shell' or migration command, use ipython if available diff -r aff5d3498f68 -r c53f66bcc641 cubicweb/migration.py --- a/cubicweb/migration.py Tue Mar 19 13:17:47 2019 +0100 +++ b/cubicweb/migration.py Thu Mar 21 14:28:30 2019 +0100 @@ -18,8 +18,6 @@ """utilities for instances migration""" from __future__ import print_function - - import sys import os import logging @@ -268,11 +266,20 @@ banner = """entering the migration python shell just type migration commands or arbitrary python code and type ENTER to execute it type "exit" or Ctrl-D to quit the shell and resume operation""" - interact(banner, local=local_ctx) + + # use ipython if available try: - readline.write_history_file(histfile) - except IOError: - pass + from IPython import start_ipython + print(banner) + start_ipython(argv=[], user_ns=local_ctx) + except ImportError: + interact(banner, local=local_ctx) + + try: + readline.write_history_file(histfile) + except IOError: + pass + # delete instance's confirm attribute to avoid questions del self.confirm self.need_wrap = True