changeset 94:e5d1a792aa45

Cleanup and records when a build is aborted.
author cmlenz
date Fri, 15 Jul 2005 14:11:29 +0000
parents b289e572bc7e
children 1984b2e01998
files bitten/master.py bitten/model.py
diffstat 2 files changed, 21 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/master.py
+++ b/bitten/master.py
@@ -271,6 +271,7 @@
                                 int(elem.attr['code']))
 
             if cmd == 'ANS':
+                db = self.env.get_db_cnx()
                 elem = xmlio.parse(payload.body)
 
                 if elem.name == 'started':
@@ -278,7 +279,6 @@
                     build.slave_info.update(self.info)
                     build.started = int(_parse_iso_datetime(elem.attr['time']))
                     build.status = Build.IN_PROGRESS
-                    build.update()
                     log.info('Slave %s started build of "%s" as of [%s]',
                              self.name, build.config, build.rev)
 
@@ -296,7 +296,7 @@
                         step.status = BuildStep.FAILURE
                     else:
                         step.status = BuildStep.SUCCESS
-                    step.insert()
+                    step.insert(db=db)
 
                 elif elem.name == 'completed':
                     log.info('Slave %s completed build of "%s" as of [%s]',
@@ -312,11 +312,16 @@
                     build.slave = None
                     build.started = 0
                     build.status = Build.PENDING
+                    build.slave_info = {}
+                    for step in BuildStep.select(self.env, build=build.id,
+                                                 db=db):
+                        step.delete(db=db)
 
                 elif elem.name == 'error':
                     build.status = Build.FAILURE
 
-                build.update()
+                build.update(db=db)
+                db.commit()
 
         snapshot_format = {
             ('application/tar', 'bzip2'): 'bzip2',
--- a/bitten/model.py
+++ b/bitten/model.py
@@ -460,6 +460,19 @@
     exists = property(fget=lambda self: self.build is not None)
     successful = property(fget=lambda self: self.status == BuildStep.SUCCESS)
 
+    def delete(self, db=None):
+        if not db:
+            db = self.env.get_db_cnx()
+            handle_ta = True
+        else:
+            handle_ta = False
+
+        cursor = db.cursor()
+        cursor.execute("DELETE FROM bitten_step WHERE build=%s AND name=%s",
+                       (self.build, self.name))
+        if handle_ta:
+            db.commit()
+
     def insert(self, db=None):
         if not db:
             db = self.env.get_db_cnx()
Copyright (C) 2012-2017 Edgewall Software