diff --git a/redash/cli/__init__.py b/redash/cli/__init__.py index c20031ff97..6f0528695c 100644 --- a/redash/cli/__init__.py +++ b/redash/cli/__init__.py @@ -1,7 +1,7 @@ import click import simplejson from flask import current_app -from flask.cli import FlaskGroup, run_command +from flask.cli import FlaskGroup, run_command, with_appcontext from rq import Connection from redash import __version__, create_app, settings, rq_redis_connection @@ -75,23 +75,13 @@ def send_test_mail(email=None): ) -@manager.command() -def ipython(): - """Starts IPython shell instead of the default Python shell.""" +@manager.command("shell") +@with_appcontext +def shell(): import sys - import IPython + from ptpython import repl from flask.globals import _app_ctx_stack app = _app_ctx_stack.top.app - banner = "Python %s on %s\nIPython: %s\nRedash version: %s\n" % ( - sys.version, - sys.platform, - IPython.__version__, - __version__, - ) - - ctx = {} - ctx.update(app.make_shell_context()) - - IPython.embed(banner1=banner, user_ns=ctx) + repl.embed(globals=app.make_shell_context()) diff --git a/requirements_dev.txt b/requirements_dev.txt index a3152fae53..c02036c50d 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -11,3 +11,4 @@ PyAthena>=1.5.0 ptvsd==4.3.2 freezegun==0.3.12 watchdog==0.9.0 +ptpython==3.0.17