Add CLI command to open IPython shell

This commit is contained in:
Arik Fraimovich
2017-06-29 12:21:09 +03:00
parent f64769cc80
commit c8ad866a53

View File

@@ -68,3 +68,23 @@ def send_test_mail(email=None):
mail.send(Message(subject="Test Message from Redash", recipients=[email],
body="Test message."))
@manager.command()
def ipython():
"""Starts IPython shell instead of the default Python shell."""
import sys
import IPython
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)