changeset 72:b2d371dac270

Allow individual steps of a recipe to be marked as optional, i.e. that an error in such a step should not mean that the build failed.
author cmlenz
date Fri, 01 Jul 2005 11:09:12 +0000
parents 2c71450a9238
children 6d7753ea1798
files bitten/recipe.py bitten/slave.py recipe.xml scripts/build.py
diffstat 4 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/recipe.py
+++ b/bitten/recipe.py
@@ -18,8 +18,10 @@
 #
 # Author: Christopher Lenz <cmlenz@gmx.de>
 
+import logging
 import os.path
 
+from bitten.build import BuildError
 from bitten.util import xmlio
 
 __all__ = ['Recipe']
@@ -50,6 +52,7 @@
         self._elem = elem
         self.id = elem.attr['id']
         self.description = elem.attr.get('description')
+        self.onerror = elem.attr.get('onerror', 'fail')
 
     def __iter__(self):
         for child in self._elem:
@@ -61,6 +64,16 @@
             else:
                 raise InvalidRecipeError, "Unknown element <%s>" % child.name
 
+    def execute(self, ctxt):
+        try:
+            for function, args in self:
+                function(ctxt, **args)
+        except BuildError, e:
+            if self.onerror == 'fail':
+                raise BuildError, e
+            logging.warning('Ignoring error in step %s (%s)', self.id, e)
+            return None
+
     def _args(self, elem):
         return dict([(name.replace('-', '_'), value) for name, value
                      in elem.attr.items()])
--- a/bitten/slave.py
+++ b/bitten/slave.py
@@ -140,9 +140,7 @@
             for step in recipe:
                 logging.info('Executing build step "%s"', step.id)
                 try:
-                    for function, args in step:
-                        logging.debug('Executing command "%s"', function)
-                        function(recipe.ctxt, **args)
+                    step.execute(recipe.ctxt)
                     xml = xmlio.Element('step', id=step.id, result='success',
                                         description=step.description)
                     self.channel.send_ans(msgno, beep.MIMEMessage(xml))
--- a/recipe.xml
+++ b/recipe.xml
@@ -17,7 +17,7 @@
         </reports>
     </step>
 
-    <step id="lint" title="Run Pylint"
+    <step id="lint" title="Run Pylint" onerror="ignore"
           description="Run Pylint to check for bad style and potential errors">
         <c:make target="pylint"/>
         <reports>
--- a/scripts/build.py
+++ b/scripts/build.py
@@ -34,8 +34,7 @@
     for step in recipe:
         if not step_id or step.id == step_id:
             print '-->', step.description or step.id
-            for function, kw in step:
-                function(recipe.ctxt, **kw)
+            step.execute(recipe.ctxt)
             print
             steps_run.append(step.id)
 
Copyright (C) 2012-2017 Edgewall Software