Skip to content

Commit

Permalink
use ptpython instead of standard python shell (getredash#5483)
Browse files Browse the repository at this point in the history
  • Loading branch information
Omer Lachish authored May 5, 2021
1 parent 9c8c1bf commit 1c3f724
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
22 changes: 6 additions & 16 deletions redash/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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())
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ PyAthena>=1.5.0
ptvsd==4.3.2
freezegun==0.3.12
watchdog==0.9.0
ptpython==3.0.17

0 comments on commit 1c3f724

Please sign in to comment.