~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/translations/model/translationtemplatesbuildbehavior.py

Merge db-devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2010 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2010-2011 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
"""An `IBuildFarmJobBehavior` for `TranslationTemplatesBuildJob`.
13
13
 
14
14
import datetime
15
15
import os
 
16
import tempfile
 
17
 
16
18
import pytz
17
 
import tempfile
18
 
 
 
19
import transaction
19
20
from twisted.internet import defer
20
21
from zope.component import getUtility
21
22
from zope.interface import implements
28
29
    )
29
30
from lp.buildmaster.model.buildfarmjobbehavior import BuildFarmJobBehaviorBase
30
31
from lp.registry.interfaces.productseries import IProductSeriesSet
 
32
from lp.services.database.transaction_policy import DatabaseTransactionPolicy
31
33
from lp.translations.interfaces.translationimportqueue import (
32
34
    ITranslationImportQueue,
33
35
    )
132
134
    def storeBuildInfo(build, queue_item, build_status):
133
135
        """See `IPackageBuild`."""
134
136
        def got_log(lfa_id):
135
 
            build.build.log = lfa_id
136
 
            build.build.builder = queue_item.builder
137
 
            build.build.date_started = queue_item.date_started
138
 
            # XXX cprov 20060615 bug=120584: Currently buildduration includes
139
 
            # the scanner latency, it should really be asking the slave for
140
 
            # the duration spent building locally.
141
 
            build.build.date_finished = datetime.datetime.now(pytz.UTC)
 
137
            transaction.commit()
 
138
            with DatabaseTransactionPolicy(read_only=False):
 
139
                build.build.log = lfa_id
 
140
                build.build.builder = queue_item.builder
 
141
                build.build.date_started = queue_item.date_started
 
142
                # XXX cprov 20060615 bug=120584: Currently buildduration
 
143
                # includes the scanner latency.  It should really be
 
144
                # asking the slave for the duration spent building locally.
 
145
                build.build.date_finished = datetime.datetime.now(pytz.UTC)
 
146
                transaction.commit()
142
147
 
143
148
        d = build.getLogFromSlave(build, queue_item)
144
149
        return d.addCallback(got_log)