mirror of
https://github.com/getredash/redash.git
synced 2025-12-25 01:03:20 -05:00
Add CLI command to open IPython shell
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user