[Checkins] SVN: keas.build/trunk/ handle broken variant configuration more gracefully.

Paul Carduner paulcarduner at gmail.com
Thu Oct 1 15:34:21 EDT 2009


Log message for revision 104703:
  handle broken variant configuration more gracefully.

Changed:
  U   keas.build/trunk/CHANGES.txt
  U   keas.build/trunk/src/keas/build/build.py
  U   keas.build/trunk/src/keas/build/package.py

-=-
Modified: keas.build/trunk/CHANGES.txt
===================================================================
--- keas.build/trunk/CHANGES.txt	2009-10-01 19:30:03 UTC (rev 104702)
+++ keas.build/trunk/CHANGES.txt	2009-10-01 19:34:21 UTC (rev 104703)
@@ -13,6 +13,11 @@
   branch just to update the setup.py file with the new version
   number.  Instead only the top level directory is checked out.
 
+- Bug Fix: project build script would crash when variant
+  configuration was missing information required by its template. Now
+  a helpful error message is printed and no files will be uploaded
+  until all have been created successfully.
+
 0.1.3 (2009-09-30)
 ------------------
 

Modified: keas.build/trunk/src/keas/build/build.py
===================================================================
--- keas.build/trunk/src/keas/build/build.py	2009-10-01 19:30:03 UTC (rev 104702)
+++ keas.build/trunk/src/keas/build/build.py	2009-10-01 19:34:21 UTC (rev 104703)
@@ -115,20 +115,28 @@
             config.get(base.BUILD_SECTION, 'buildout-server-password'),
             options.offline)
 
+    filesToUpload = []
+
     # Create deployment configurations
     for section in config.sections():
         if section == base.BUILD_SECTION:
             continue
-        logger.info('Building deployment configuration: ' + section)
-        logger.info('Loading deploy template file: ' +
-                    config.get(section, 'template'))
-        template = file(config.get(section, 'template'), 'r').read()
-        vars = dict([(name, value) for name, value in config.items(section)
+        logger.info('Building deployment configuration: %s', section)
+        template_path = config.get(section, 'template')
+        logger.info('Loading deploy template file: %s', template_path)
+        template = file(template_path, 'r').read()
+        vars = dict([(name, value)
+                     for name, value in config.items(section)
                      if name != 'template'])
         vars['project-name'] = projectName
         vars['project-version'] = projectVersion
         vars['instance-name'] = section
-        deployConfigText = template %vars
+        try:
+            deployConfigText = template % vars
+        except KeyError, e:
+            logger.error("The %s deployment configuration is missing the %r setting required by %s",
+                         section, e.message, template_path)
+            sys.exit(0)
         deployConfigFilename = '%s-%s-%s.cfg' %(
             config.get(base.BUILD_SECTION, 'name'), section, projectVersion)
         deployConfig = ConfigParser.RawConfigParser()
@@ -137,10 +145,13 @@
         logger.info('Writing deployment file: ' + deployConfigFilename)
         deployConfig.write(open(deployConfigFilename, 'w'))
 
-        # Upload the deployment file
-        if not options.offline and not options.noUpload:
+        filesToUpload.append(deployConfigFilename)
+
+    # Upload the deployment files
+    if not options.offline and not options.noUpload:
+        for filename in filesToUpload:
             base.uploadFile(
-                deployConfigFilename,
+                filename,
                 config.get(
                     base.BUILD_SECTION, 'buildout-server')+'/'+projectName,
                 config.get(base.BUILD_SECTION, 'buildout-server-username'),

Modified: keas.build/trunk/src/keas/build/package.py
===================================================================
--- keas.build/trunk/src/keas/build/package.py	2009-10-01 19:30:03 UTC (rev 104702)
+++ keas.build/trunk/src/keas/build/package.py	2009-10-01 19:34:21 UTC (rev 104703)
@@ -327,8 +327,11 @@
             # the last release.
             changed = False
             if self.options.branch:
+                logger.info('Checking for changes since version %s; please wait...', versions[-1])
                 changed = self.hasChangedSince(
                     versions[-1], self.options.branch)
+            if not changed:
+                logger.info("No changes detected.")
             # 3.2. If the branch changed and the next version should be
             # suggested, let's find the next version.
             if self.options.nextVersion and changed:



More information about the checkins mailing list