Try ipython-based shell first, falling back to plain shell
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
parent
b28005984c
commit
4d9b426ccf
@ -47,24 +47,21 @@ def py_shell(**user_namespace):
|
|||||||
|
|
||||||
def ipython_shell(**user_namespace):
|
def ipython_shell(**user_namespace):
|
||||||
"""
|
"""
|
||||||
Run a shell for the user using ipython.
|
Run a shell for the user using ipython. Return False if there is no IPython
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
from IPython import embed
|
from IPython import embed
|
||||||
except:
|
except:
|
||||||
print "IPython not available... exiting!"
|
return False
|
||||||
return
|
|
||||||
|
|
||||||
embed(
|
embed(
|
||||||
banner1=SHELL_BANNER,
|
banner1=SHELL_BANNER,
|
||||||
user_ns=user_namespace)
|
user_ns=user_namespace)
|
||||||
|
return True
|
||||||
|
|
||||||
def shell(args):
|
def shell(args):
|
||||||
"""
|
"""
|
||||||
Setup a shell for the user
|
Setup a shell for the user either a normal Python shell or an IPython one
|
||||||
either a normal Python shell
|
|
||||||
or an IPython one
|
|
||||||
"""
|
"""
|
||||||
user_namespace = {
|
user_namespace = {
|
||||||
'mg_globals': mg_globals,
|
'mg_globals': mg_globals,
|
||||||
@ -74,4 +71,6 @@ def shell(args):
|
|||||||
if args.ipython:
|
if args.ipython:
|
||||||
ipython_shell(**user_namespace)
|
ipython_shell(**user_namespace)
|
||||||
else:
|
else:
|
||||||
py_shell(**user_namespace)
|
# Try ipython_shell first and fall back if not available
|
||||||
|
if not ipython_shell(**user_namespace):
|
||||||
|
py_shell(**user_namespace)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user