[Zope-CVS] SVN: zpkgtools/trunk/zpkgtools/app.py clean up the error message provided when errors are found in a configuration

Fred L. Drake, Jr. fdrake at gmail.com
Mon Aug 29 13:04:18 EDT 2005


Log message for revision 38144:
  clean up the error message provided when errors are found in a configuration
  file, so the user is presented with the error message and file location,
  but not a Python traceback
  

Changed:
  U   zpkgtools/trunk/zpkgtools/app.py

-=-
Modified: zpkgtools/trunk/zpkgtools/app.py
===================================================================
--- zpkgtools/trunk/zpkgtools/app.py	2005-08-29 16:51:44 UTC (rev 38143)
+++ zpkgtools/trunk/zpkgtools/app.py	2005-08-29 17:04:17 UTC (rev 38144)
@@ -23,6 +23,7 @@
 
 import zpkgtools
 
+from zpkgsetup import cfgparser
 from zpkgsetup import loggingapi as logging
 from zpkgsetup import package
 from zpkgsetup import publication
@@ -63,19 +64,20 @@
         location_maps = []
         for map in options.location_maps:
             if os.path.isfile(map):
-                map = os.path.abspath(map)
-                map = "file://" + urlutils.pathname2url(map)
+                map = urlutils.file_url(os.path.abspath(map))
             location_maps.append(map)
         cf.location_maps.extend(location_maps)
         path = options.configfile
         if path is None:
             path = config.defaultConfigurationPath()
-            if os.path.exists(path):
-                self.logger.debug("loading configuration file %s", path)
+            if not os.path.exists(path):
+                path = None
+        if path:
+            self.logger.debug("loading configuration file %s", path)
+            try:
                 cf.loadPath(path)
-        elif path:
-            self.logger.debug("loading configuration file %s", path)
-            cf.loadPath(path)
+            except cfgparser.ConfigurationError, e:
+                self.error(str(e))
         cf.finalize()
         self.locations = cf.locations
         if cf.collect_dependencies:



More information about the Zope-CVS mailing list