commit-gnue
[Top][All Lists]
Advanced

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

r5147 - in trunk/gnue-forms/src: . uidrivers/_base uidrivers/curses uidr


From: jcater
Subject: r5147 - in trunk/gnue-forms/src: . uidrivers/_base uidrivers/curses uidrivers/gtk2 uidrivers/qt uidrivers/win32 uidrivers/wx
Date: Mon, 23 Feb 2004 23:56:35 -0600 (CST)

Author: jcater
Date: 2004-02-23 23:56:34 -0600 (Mon, 23 Feb 2004)
New Revision: 5147

Added:
   trunk/gnue-forms/src/uidrivers/_base/Exceptions.py
Modified:
   trunk/gnue-forms/src/GFClient.py
   trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
   trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py
   trunk/gnue-forms/src/uidrivers/qt/MenuBar.py
   trunk/gnue-forms/src/uidrivers/qt/QTApp.py
   trunk/gnue-forms/src/uidrivers/qt/QTSplashScreen.py
   trunk/gnue-forms/src/uidrivers/qt/UIdriver.py
   trunk/gnue-forms/src/uidrivers/win32/UIdriver.py
   trunk/gnue-forms/src/uidrivers/wx/UIdriver.py
Log:
added exceptions to UIDrivers to help give feedback when startup yields an 
error... instead of lumping them all into ImportError

Modified: trunk/gnue-forms/src/GFClient.py
===================================================================
--- trunk/gnue-forms/src/GFClient.py    2004-02-24 04:45:21 UTC (rev 5146)
+++ trunk/gnue-forms/src/GFClient.py    2004-02-24 05:56:34 UTC (rev 5147)
@@ -42,6 +42,7 @@
 from gnue.forms import VERSION
 from gnue.forms.GFInstance import *
 from gnue.forms.GFConfig import ConfigOptions
+from gnue.forms.uidrivers._base import Exceptions
 
 class GFClient(GClientApp):
   #
@@ -86,15 +87,19 @@
         self._ui = dyn_import("gnue.forms.uidrivers.%s" % (self.ui_type))
         break
       except ImportError, err:
-        GDebug.printMesg(1,_("Unable to load UI driver")+" %s" % self.ui_type)
+        GDebug.printMesg(1,_("Unknown UI Driver:")+" %s" % self.ui_type)
         GDebug.printMesg(1,err)
         try:
           self._ui = dyn_import("%s" % (self.ui_type.replace('/','.')))
           break
         except ImportError, err:
-          GDebug.printMesg(1,_("Unable to load UI driver")+" %s" % 
self.ui_type)
+          GDebug.printMesg(1,_("Unknown UI driver")+" %s" % self.ui_type)
           GDebug.printMesg(1,err)
 
+          self.handleStartupError(_("Unknown UI driver specified: %s") % 
self.ui_type)
+
+      except Exceptions.UIException, err:
+
         # If user specified a specific UI, don't cycle...
         if SPECIFIC_UI:
           raise  # TODO: TEMPORARY

Added: trunk/gnue-forms/src/uidrivers/_base/Exceptions.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_base/Exceptions.py  2004-02-24 04:45:21 UTC 
(rev 5146)
+++ trunk/gnue-forms/src/uidrivers/_base/Exceptions.py  2004-02-24 05:56:34 UTC 
(rev 5147)
@@ -0,0 +1,35 @@
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Copyright 2000-2004 Free Software Foundation
+#
+# FILE:
+# UIqt.py
+#
+# DESCRIPTION:
+"""
+Common exceptions
+"""
+# NOTES:
+#
+
+class UIException(StandardError):
+  pass
+
+class DriverNotSupported(UIException):
+  pass

Modified: trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/UIdriver.py   2004-02-24 04:45:21 UTC 
(rev 5146)
+++ trunk/gnue-forms/src/uidrivers/curses/UIdriver.py   2004-02-24 05:56:34 UTC 
(rev 5147)
@@ -32,7 +32,14 @@
 import string
 
 import atexit
-import curses
+
+from gnue.forms.uidrivers._base import Exceptions
+
+try:
+  import curses
+except ImportError:
+  raise Exceptions.DriverNotSupported, _("The GNUe-Forms Curses driver 
requires Python 2.1+ and the ncurses library.")
+
 from gnue.common.cursing import *
 
 from gnue.common import events

Modified: trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py     2004-02-24 04:45:21 UTC 
(rev 5146)
+++ trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py     2004-02-24 05:56:34 UTC 
(rev 5147)
@@ -29,20 +29,27 @@
 import sys
 import string
 
-import pygtk
-pygtk.require('2.0')
+from gnue.forms.uidrivers._base import Exceptions
 
-import gtk
-import pango
+try:
+  import pygtk
+  pygtk.require('2.0')
 
-## check if we really imported gtk 2.0
-if not hasattr(gtk,"keysyms"):
-  print _("Import error: You need pygtk 2.0 to use the gtk2 user" +\
+  import gtk
+  import pango
+
+  ## check if we really imported gtk 2.0
+  if not hasattr(gtk,"keysyms"):
+    print _("Import error: You need pygtk 2.0 to use the gtk2 user" +\
           " interface driver.")
-  print "You are actually using gtk %s.%s.%s ."% gtk.gtk_version + \
+    print "You are actually using gtk %s.%s.%s ."% gtk.gtk_version + \
         "and pygtk %s.%s.%s ."% gtk.pygtk_version
+    raise ImportError
 
+except ImportError:
+  raise Exceptions.DriverNotSupported, _("The GNUe-Forms GTK driver requires 
PyGTK and GTK 2.x.")
 
+
 from gnue.common import events
 from gnue.common.apps import GDebug
 from gnue.common.apps import GConfig

Modified: trunk/gnue-forms/src/uidrivers/qt/MenuBar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt/MenuBar.py        2004-02-24 04:45:21 UTC 
(rev 5146)
+++ trunk/gnue-forms/src/uidrivers/qt/MenuBar.py        2004-02-24 05:56:34 UTC 
(rev 5147)
@@ -19,22 +19,23 @@
 # Copyright 2000-2004 Free Software Foundation
 #
 # FILE:
-# wx/MenuBar.py
+# qt/MenuBar.py
 #
 # DESCRIPTION:
-# A generic UIdriver base for common message-based GUI toolkits.
-#
+"""
+A generic UIdriver base for common message-based GUI toolkits.
+"""
 # NOTES:
 #
 
 import string
 from qt import *
 from gnue.forms.uidrivers._commonGuiToolkit.MenuBar import MenuBar as 
_BaseMenuBar
-  
+
 class MenuBar(_BaseMenuBar):
 
   # Create the menu
-  def init(self): 
+  def init(self):
     self.menu = self.container.menuBar()
     self.__idmap = {}
     return self.menu
@@ -44,52 +45,52 @@
     menu = QPopupMenu(parent)
     parent.insertItem(name, menu)
     QObject.connect(menu, SIGNAL('activated(int)'), self.__itemSelected)
-    
+
     return menu
-  
+
   # Add a menu item (action)
   def addAction(self, name, parent, userAction):
     label = name
     hotkey = userAction.getHotKeyText()
     iconloc = userAction.getIconLocation(size="16x16")
 
-    if hotkey: 
+    if hotkey:
       label += '\t%s' % hotkey
-      
+
     # Set the action icon if available
-    if iconloc: 
-      try: 
+    if iconloc:
+      try:
         # Some caching logic for faster second/third forms
         icon = _cachedIcons[iconloc]
-      except KeyError: 
+      except KeyError:
         icon = QIconSet(QPixmap(iconloc))
         _cachedIcons[iconloc] = icon
       id = parent.insertItem(icon, label)
-    else: 
+    else:
       id = parent.insertItem(label)
-    
+
     parent.setWhatsThis(id, userAction.description or '')
-    
+
     self.__idmap[id] = 'request' + userAction.event
-            
+
     return (parent, id)
-    
+
   # Add a separator
-  def addSeparator(self, parent): 
+  def addSeparator(self, parent):
     parent.insertSeparator()
-    
+
   # Enable a menu item
   def enableItem(self, item):
     parent, id = item
     parent.setItemEnabled(id, 1)
-  
+
   # Disable a menu item
-  def disableItem(self, item): 
+  def disableItem(self, item):
     parent, id = item
     parent.setItemEnabled(id, 0)
 
   # A menu item was selected
-  def __itemSelected(self, itemid): 
+  def __itemSelected(self, itemid):
     self.driver.dispatchEvent(self.__idmap[itemid], _form=self.form)
 
 

Modified: trunk/gnue-forms/src/uidrivers/qt/QTApp.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt/QTApp.py  2004-02-24 04:45:21 UTC (rev 
5146)
+++ trunk/gnue-forms/src/uidrivers/qt/QTApp.py  2004-02-24 05:56:34 UTC (rev 
5147)
@@ -22,8 +22,9 @@
 # UIqt.py
 #
 # DESCRIPTION:
-# A QT-based user interface driver for GNUe forms.
-#
+"""
+A QT-based user interface driver for GNUe forms.
+"""
 # NOTES:
 #
 
@@ -43,10 +44,10 @@
     return __QtApp
 
 class GFqtApp(QApplication):
-  def __init__(self): 
+  def __init__(self):
     QApplication.__init__(self, sys.argv)
     QObject.connect(self, SIGNAL('lastWindowClosed()'),
-                    self, SLOT('quit()'))    
-                    
+                    self, SLOT('quit()'))
+
   # TODO: self.setFont() will set fonts for all child widgets!!!
-            
+

Modified: trunk/gnue-forms/src/uidrivers/qt/QTSplashScreen.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt/QTSplashScreen.py 2004-02-24 04:45:21 UTC 
(rev 5146)
+++ trunk/gnue-forms/src/uidrivers/qt/QTSplashScreen.py 2004-02-24 05:56:34 UTC 
(rev 5147)
@@ -22,8 +22,9 @@
 # SplashScreen.py
 #
 # DESCRIPTION:
-# A QT based splash screen
-#
+"""
+A QT based splash screen
+"""
 # NOTES:
 #
 
@@ -35,11 +36,11 @@
 
 class QTSplashScreen: ###(SplashScreen):
   def __init__(self):
-    return 
-    
+    return
+
     images_dir = GConfig.getInstalledBase('forms_images','common_images') + '/'
     bitmapFile=images_dir+gConfigForms('splashScreenPNG')
-    
+
     SplashScreen.__init__(self,None,bitmapfile=bitmapFile,
                           duration = 3000, callback=self.onCloseSplash,
                           
style=wxCENTRE_ON_SCREEN|wxSIMPLE_BORDER|wxSTAY_ON_TOP
@@ -56,7 +57,7 @@
                  
size=wxSize(swidth,theight),pos=wxPoint(1,1),style=wxALIGN_CENTRE)
 
     self.SetFont(wxFont(10,wxSWISS,wxNORMAL,wxBOLD))
-    
+
     text = _("Version %s") % VERSION
     twidth,theight = self.GetTextExtent(text)
     wxStaticText(parent=self, id=-1, label=str(text),
@@ -96,7 +97,7 @@
     #self.mainWindow.Show(true)                 #TODO: May need to put back 
but doubt it
     wxYield() # Flush the pending queue to insure something is
               # there before the splashscreen dies
-                
+
     # For some reason, a simple Close() doesn't cooperate with
     # the modal login box and all hell breaks loose
     self.Show(0)

Modified: trunk/gnue-forms/src/uidrivers/qt/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt/UIdriver.py       2004-02-24 04:45:21 UTC 
(rev 5146)
+++ trunk/gnue-forms/src/uidrivers/qt/UIdriver.py       2004-02-24 05:56:34 UTC 
(rev 5147)
@@ -22,15 +22,22 @@
 # UIqt.py
 #
 # DESCRIPTION:
-# A pyQT based user interface driver for GNUe forms.
-#
+"""
+A pyQT based user interface driver for GNUe forms.
+"""
 # NOTES:
 #
+
 import sys
 import string
 
-from qt import *
+from gnue.forms.uidrivers._base import Exceptions
 
+try:
+  from qt import *
+except ImportError:
+  raise Exceptions.DriverNotSupported, _("The GNUe-Forms QT3 driver requires 
PyQT.")
+
 from gnue.common import events
 from gnue.common.apps import GDebug
 from gnue.common.apps import GConfig

Modified: trunk/gnue-forms/src/uidrivers/win32/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/UIdriver.py    2004-02-24 04:45:21 UTC 
(rev 5146)
+++ trunk/gnue-forms/src/uidrivers/win32/UIdriver.py    2004-02-24 05:56:34 UTC 
(rev 5147)
@@ -30,8 +30,13 @@
 import sys
 import string
 
-import win32gui, win32con, afxres, commctrl, win32clipboard, win32ui
+from gnue.forms.uidrivers._base import Exceptions
 
+try:
+  import win32gui, win32con, afxres, commctrl, win32clipboard, win32ui
+except ImportError:
+  raise Exceptions.DriverNotSupported, _("The GNUe-Forms Win32 driver requires 
PyWin32.")
+
 from gnue.common import events
 from gnue.common.apps import GDebug
 from gnue.common.apps import GConfig

Modified: trunk/gnue-forms/src/uidrivers/wx/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/UIdriver.py       2004-02-24 04:45:21 UTC 
(rev 5146)
+++ trunk/gnue-forms/src/uidrivers/wx/UIdriver.py       2004-02-24 05:56:34 UTC 
(rev 5147)
@@ -29,7 +29,13 @@
 import sys
 import string
 
-from wxPython import __version__ as WXVERSION
+from gnue.forms.uidrivers._base import Exceptions
+
+try:
+  from wxPython import __version__ as WXVERSION
+except ImportError:
+  raise Exceptions.DriverNotSupported, _("The GNUe-Forms wx driver requires 
wxPython.")
+
 from wxPython.wx import *
 
 from gnue.common import events





reply via email to

[Prev in Thread] Current Thread [Next in Thread]