gnome-games r8031 - in branches/gnome-2-24/glchess/src: . lib



Author: rancell
Date: Wed Oct 15 09:57:56 2008
New Revision: 8031
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8031&view=rev

Log:
Print failure to start message to stdout if cannot import GTK+


Modified:
   branches/gnome-2-24/glchess/src/glchess.in.in
   branches/gnome-2-24/glchess/src/lib/glchess.py

Modified: branches/gnome-2-24/glchess/src/glchess.in.in
==============================================================================
--- branches/gnome-2-24/glchess/src/glchess.in.in	(original)
+++ branches/gnome-2-24/glchess/src/glchess.in.in	Wed Oct 15 09:57:56 2008
@@ -15,6 +15,21 @@
 import pygtk
 pygtk.require('2.0')
 
+# Ignore any exceptions writing to stdout using print statements
+class SafeStdout:
+    def __init__(self):
+        self.stdout = sys.stdout
+    
+    def fileno(self):
+        return self.stdout.fileno()
+
+    def write(self, data):
+        try:
+            self.stdout.write(data)
+        except:
+            pass
+sys.stdout = SafeStdout()
+
 # Setup bugbuddy to report unhandled exceptions.
 try: 
     import bugbuddy
@@ -24,19 +39,26 @@
     pass
 
 def report_error():
-    import gtk
     import os.path
     import gettext
     from gettext import gettext as _
-        
+    
     gettext.bindtextdomain('gnome-games', os.path.join('@prefix@', 'share', 'locale'))
     gettext.textdomain('gnome-games')
     title = _("Chess incorrectly installed")
     description = _("""Chess is not able to start because required application files are not installed. If you are currently upgrading your system please wait until the upgrade has completed.""")
-    dialog = gtk.MessageDialog(type = gtk.MESSAGE_ERROR, message_format = title)
-    dialog.format_secondary_text(description)
-    dialog.add_button(gtk.STOCK_QUIT, gtk.RESPONSE_CLOSE)
-    dialog.run()
+
+    try:
+        import gtk
+    except ImportError:
+        print title
+        print '-' * len(title)
+        print description
+    else:
+        dialog = gtk.MessageDialog(type = gtk.MESSAGE_ERROR, message_format = title)
+        dialog.format_secondary_text(description)
+        dialog.add_button(gtk.STOCK_QUIT, gtk.RESPONSE_CLOSE)
+        dialog.run()
     sys.exit(0)
 
 # Chek if we are installed
@@ -49,13 +71,8 @@
 try:
     # Import glChess from pyexecdir or system installation.
     from glchess.glchess import start_game
-except ImportError:
-    # Import of glChess failed. Show error message.
-    report_error()
-    
-try:
     start_game()
 except ImportError:
-    # the game is not entirely installed
+    # Import of glChess failed. Show error message.
     report_error()
 

Modified: branches/gnome-2-24/glchess/src/lib/glchess.py
==============================================================================
--- branches/gnome-2-24/glchess/src/lib/glchess.py	(original)
+++ branches/gnome-2-24/glchess/src/lib/glchess.py	Wed Oct 15 09:57:56 2008
@@ -1,21 +1,3 @@
-import sys
-
-# Ignore any exceptions writing to stdout using print statements
-class SafeStdout:
-    def __init__(self):
-        self.stdout = sys.stdout
-    
-    def fileno(self):
-        return self.stdout.fileno()
-
-    def write(self, data):
-        try:
-            self.stdout.write(data)
-        except:
-            pass
-
-sys.stdout = SafeStdout()
-
 import main
 def start_game ():
     app = main.Application()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]