changeset 751:db5f7388535d 0.6.x

Merge [821,822,823,824,825,826] from trunk. Thanks Walter\!
author hodgestar
date Thu, 22 Apr 2010 22:24:47 +0000
parents 132f6e23ffaf
children d9f06a314db5
files bitten/admin.py bitten/build/pythontools.py bitten/master.py bitten/queue.py bitten/tests/master.py bitten/web_ui.py
diffstat 6 files changed, 18 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/admin.py
+++ b/bitten/admin.py
@@ -212,7 +212,7 @@
                     'href': req.href.admin('bitten', 'configs', config.name),
                     'recipe': config.recipe and True or False
                 })
-            data['configs'] = configs
+            data['configs'] = sorted(configs, key=lambda x:x['label'].lower())
 
         add_stylesheet(req, 'bitten/admin.css')
         add_script(req, 'common/js/suggest.js')
--- a/bitten/build/pythontools.py
+++ b/bitten/build/pythontools.py
@@ -126,7 +126,8 @@
     returncode = shtools.execute(ctxt, executable=_python_path(ctxt),
                                  file_=file_, output=output, args=args)
     if returncode != 0:
-        ctxt.error('Executing %s failed (error code %s)' % (file_, returncode))
+        ctxt.error('Executing %s failed (error code %s)' % \
+                       (file_ or function or module, returncode))
 
 def pylint(ctxt, file_=None):
     """Extract data from a ``pylint`` run written to a file.
--- a/bitten/master.py
+++ b/bitten/master.py
@@ -210,6 +210,9 @@
         for step in list(BuildStep.select(self.env, build=build.id, db=db)):
             step.delete(db=db)
         build.update(db=db)
+
+        Attachment.delete_all(self.env, 'build', build.resource.id, db)
+
         db.commit()
 
         for listener in BuildSystem(self.env).listeners:
@@ -255,12 +258,6 @@
             self._send_error(req, HTTP_BAD_REQUEST, 'XML parser error')
         stepname = elem.attr['step']
 
-        # make sure it's the right slave.
-        if build.status != Build.IN_PROGRESS:
-            self._send_error(req, HTTP_CONFLICT,
-                        'Build %s has been invalidated for host %s.' \
-                                        % (build.id, req.remote_addr))
-
         step = BuildStep.fetch(self.env, build=build.id, name=stepname)
         if step:
             self._send_error(req, HTTP_CONFLICT, 'Build step already exists')
@@ -330,6 +327,7 @@
             filename = attach_elem.attr.get('filename')
             resource_id = attach_elem.attr.get('resource') == 'config' \
                                     and build.config or build.resource.id
+
             try: # Delete attachment if it already exists
                 old_attach = Attachment(self.env, 'build',
                                     parent_id=resource_id, filename=filename)
--- a/bitten/queue.py
+++ b/bitten/queue.py
@@ -24,6 +24,8 @@
 import time
 
 from trac.util.datefmt import to_timestamp
+from trac.attachment import Attachment
+
 
 from bitten.model import BuildConfig, TargetPlatform, Build, BuildStep
 
@@ -287,6 +289,8 @@
             for step in list(BuildStep.select(self.env, build=build.id, db=db)):
                 step.delete(db=db)
             build.update(db=db)
+
+            Attachment.delete_all(self.env, 'build', build.resource.id, db)
         db.commit()
 
     def should_delete_build(self, build, repos):
--- a/bitten/tests/master.py
+++ b/bitten/tests/master.py
@@ -699,6 +699,7 @@
         build = Build.fetch(self.env, build.id)
         build.slave = None
         build.status = Build.PENDING
+        build.slave_info = {}
         build.update()
 
         # have this slave submit more data.
@@ -727,8 +728,8 @@
         self.assertRaises(RequestDone, module.process_request, req)
 
         self.assertEquals(409, outheaders['Status'])
-        self.assertEquals('Build 1 has been invalidated for host 127.0.0.1.',
-                        outbody.getvalue())            
+        self.assertEquals('Token mismatch (wrong slave): slave=123, build=',
+                          outbody.getvalue())
 
         build = Build.fetch(self.env, build.id)
         self.assertEqual(Build.PENDING, build.status)
--- a/bitten/web_ui.py
+++ b/bitten/web_ui.py
@@ -16,7 +16,7 @@
 
 import pkg_resources
 from genshi.builder import tag
-from trac.attachment import AttachmentModule
+from trac.attachment import AttachmentModule, Attachment
 from trac.core import *
 from trac.mimeview.api import Context
 from trac.resource import Resource
@@ -248,7 +248,7 @@
                         'platform': platform.name, 'status': 'pending'
                     })
 
-        data['configs'] = configs
+        data['configs'] = sorted(configs, key=lambda x:x['label'].lower())
         data['page_mode'] = 'overview'
 
         in_progress_builds = Build.select(self.env, status=Build.IN_PROGRESS)
@@ -650,6 +650,8 @@
         build.slave_info = {}
         build.update()
 
+        Attachment.delete_all(self.env, 'build', build.resource.id, db)
+
         db.commit()
 
         req.redirect(req.href.build(build.config))
Copyright (C) 2012-2017 Edgewall Software