lbalhar / rpms / ipython

Forked from rpms/ipython 4 years ago
Clone
a34b15b
commit 8161523536289eaed01ca42707f6785f59343cd7
a34b15b
Author: Fernando Perez <Fernando.Perez@berkeley.edu>
a34b15b
Date:   Tue Oct 26 14:32:10 2010 -0700
a34b15b
a34b15b
    Do not require GTK to be either present or usable to start.
a34b15b
    
a34b15b
    Before, we only checked that we could import GTK, but in a linux
a34b15b
    console, it's possible to import it while not being able to start it
a34b15b
    (no X11 present).
a34b15b
    
a34b15b
    This should resolve https://bugzilla.redhat.com/show_bug.cgi?id=646079
a34b15b
    Thanks to Tom Spura for reporting it.
a34b15b
a34b15b
diff --git a/IPython/Shell.py b/IPython/Shell.py
a34b15b
index 9481099..38006d7 100644
a34b15b
--- a/IPython/Shell.py
a34b15b
+++ b/IPython/Shell.py
a34b15b
@@ -1152,7 +1152,8 @@ class IPShellMatplotlibQt4(IPShellQt4):
a34b15b
 def check_gtk(mode):
a34b15b
     try:
a34b15b
         import gtk
a34b15b
-    except ImportError:
a34b15b
+    except (ImportError, RuntimeError):
a34b15b
+        # GTK not present, or can't be started (no X11, happens in console)
a34b15b
         return mode
a34b15b
     if hasattr(gtk,'set_interactive'):
a34b15b
         gtk.set_interactive(False)
a34b15b
@@ -1243,7 +1244,8 @@ def _select_shell(argv):
a34b15b
             th_mode = 'tkthread'
a34b15b
 
a34b15b
         # New versions of pygtk don't need the brittle threaded support.
a34b15b
-        th_mode = check_gtk(th_mode)
a34b15b
+        if th_mode == 'gthread':
a34b15b
+            th_mode = check_gtk(th_mode)
a34b15b
         return th_shell[th_mode]
a34b15b
 
a34b15b