aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/gmg_commands/shell.py
diff options
context:
space:
mode:
authorSebastian Spaeth <Sebastian@SSpaeth.de>2012-12-18 16:54:07 +0100
committerSebastian Spaeth <Sebastian@SSpaeth.de>2012-12-19 10:33:29 +0100
commit4d9b426ccfe4b6a3c875e75399011d7cf25aa379 (patch)
tree7f0591d16f209ad06558fd9a412777471ee956af /mediagoblin/gmg_commands/shell.py
parentb28005984c8109c0af8aeb5c1a173730c7d7bb97 (diff)
downloadmediagoblin-4d9b426ccfe4b6a3c875e75399011d7cf25aa379.tar.lz
mediagoblin-4d9b426ccfe4b6a3c875e75399011d7cf25aa379.tar.xz
mediagoblin-4d9b426ccfe4b6a3c875e75399011d7cf25aa379.zip
Try ipython-based shell first, falling back to plain shell
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Diffstat (limited to 'mediagoblin/gmg_commands/shell.py')
-rw-r--r--mediagoblin/gmg_commands/shell.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/mediagoblin/gmg_commands/shell.py b/mediagoblin/gmg_commands/shell.py
index ec1ab535..4998acd7 100644
--- a/mediagoblin/gmg_commands/shell.py
+++ b/mediagoblin/gmg_commands/shell.py
@@ -47,24 +47,21 @@ def py_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:
from IPython import embed
except:
- print "IPython not available... exiting!"
- return
-
+ return False
+
embed(
banner1=SHELL_BANNER,
user_ns=user_namespace)
-
+ return True
def shell(args):
"""
- Setup a shell for the user
- either a normal Python shell
- or an IPython one
+ Setup a shell for the user either a normal Python shell or an IPython one
"""
user_namespace = {
'mg_globals': mg_globals,
@@ -74,4 +71,6 @@ def shell(args):
if args.ipython:
ipython_shell(**user_namespace)
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)