pdf: remove two unused files (we use pdf.js in an iframe, no need for our own bastard...
[mediagoblin.git] / mediagoblin / gmg_commands / shell.py
index 3169abe2c26cb00c6cc19d6574fb8321d5c1f70c..4998acd7b46e73766e7517b706f98298c75d92d3 100644 (file)
@@ -47,26 +47,22 @@ 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,
         'mgoblin_app': commands_util.setup_app(args),
@@ -75,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)