commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8295 - trunk/gnue-common/src/apps


From: reinhard
Subject: [gnue] r8295 - trunk/gnue-common/src/apps
Date: Mon, 3 Apr 2006 18:22:44 -0500 (CDT)

Author: reinhard
Date: 2006-03-30 15:10:13 -0600 (Thu, 30 Mar 2006)
New Revision: 8295

Modified:
   trunk/gnue-common/src/apps/GBaseApp.py
   trunk/gnue-common/src/apps/GConfig.py
Log:
Properly handle unicode in exceptions.


Modified: trunk/gnue-common/src/apps/GBaseApp.py
===================================================================
--- trunk/gnue-common/src/apps/GBaseApp.py      2006-03-30 20:22:00 UTC (rev 
8294)
+++ trunk/gnue-common/src/apps/GBaseApp.py      2006-03-30 21:10:13 UTC (rev 
8295)
@@ -332,7 +332,7 @@
                        self.OPTIONS ['debug-file'])
     except ValueError:
        raise StartupError, \
-          _('The debug_level option ("-d") expects numerical values.')
+           u_('The debug_level option ("-d") expects numerical values.')
 
     assert gDebug (2, "Python %s" % sys.version)
     assert gDebug (2, "Run Options: %s" % opt)

Modified: trunk/gnue-common/src/apps/GConfig.py
===================================================================
--- trunk/gnue-common/src/apps/GConfig.py       2006-03-30 20:22:00 UTC (rev 
8294)
+++ trunk/gnue-common/src/apps/GConfig.py       2006-03-30 21:10:13 UTC (rev 
8295)
@@ -29,17 +29,20 @@
 from ConfigParser import *
 import os, sys, string
 from gnue import paths
-from gnue.common.apps import GDebug
+from gnue.common.apps import errors, GDebug
 from gnue.common.utils.FileUtils import openResource
 from gnue.common.utils.TextUtils import lineWrap
 from gnue.common import GCConfig
 import copy
 
-class InvalidFormatError (StandardError):
-  # Raised if the Connections Definition File is
-  # in an unreadable format.
+# -----------------------------------------------------------------------------
+# Configuration file cannot be parsed
+# -----------------------------------------------------------------------------
+
+class InvalidFormatError (errors.AdminError):
   pass
 
+
 class GConfig:
   def __init__(self, section, defaults=None, configFilename="gnue.conf", 
homeConfigDir=".gnue"):
 
@@ -103,14 +106,14 @@
         assert gDebug(2,'Configuration files were read in this order:  %s' % \
                          (fileLocations) )
       except DuplicateSectionError:
-        raise InvalidFormatError, _('The file has duplicate source 
definitions.')
+        raise InvalidFormatError, \
+            u_('Configuration file has duplicate sections.')
       except MissingSectionHeaderError:
-        raise InvalidFormatError, _('The file has no source definitions.')
+        raise InvalidFormatError, \
+            u_('Configuration file has no sections.')
       except:
-        print u_("The file cannot be parsed. %(exType)s :: %(exValue)s") \
-            % {'exType': sys.exc_type,
-               'exValue': sys.exc_value}
-        raise InvalidFormatError, _('The file cannot be parsed.')
+        raise InvalidFormatError, \
+            u_('Configuration file cannot be parsed:\n%s') % sys.exc_value
 
       #
       # Common only needs checked once
@@ -257,12 +260,9 @@
 # highest priority: site_config.cfg (depreciated -- will be removed)
 
 if os.environ.has_key('GNUE_INSTALLED_SITE_CFG'):
-  try:
-    input = open(os.environ['GNUE_INSTALLED_SITE_CFG'],'r')
-    text = input.read()
-    input.close()
-  except IOError:
-    raise _("Unable to read the GNUE_INSTALLED_SITE_CFG file... There is a 
problem with your installation")
+  input = open(os.environ['GNUE_INSTALLED_SITE_CFG'],'r')
+  text = input.read()
+  input.close()
 
   # This evaluates the text file as a python script (hope you secured it)
   # The resulting namespace is stored as a dict in _site_config.





reply via email to

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