~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/buildmaster/model/buildfarmjob.py

  • Committer: Steve Kowalik
  • Date: 2011-08-07 04:05:52 UTC
  • mto: This revision was merged to the branch mainline in revision 13626.
  • Revision ID: stevenk@ubuntu.com-20110807040552-mwnxo0flmhvl35e8
Correct the notification based on review comments, and remove request{,ed}
from the function names, switching to create{,d}.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009 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
__metaclass__ = type
32
32
from storm.store import Store
33
33
from zope.component import (
34
34
    ComponentLookupError,
 
35
    getAdapter,
35
36
    getUtility,
36
37
    )
37
38
from zope.interface import (
41
42
from zope.proxy import isProxy
42
43
from zope.security.proxy import removeSecurityProxy
43
44
 
 
45
from canonical.database.constants import UTC_NOW
 
46
from canonical.database.enumcol import DBEnum
 
47
from canonical.launchpad.interfaces.lpstorm import (
 
48
    IMasterStore,
 
49
    IStore,
 
50
    )
 
51
from canonical.launchpad.webapp.interfaces import (
 
52
    DEFAULT_FLAVOR,
 
53
    IStoreSelector,
 
54
    MAIN_STORE,
 
55
    )
44
56
from lp.app.errors import NotFoundError
45
57
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
46
58
from lp.buildmaster.enums import (
57
69
    )
58
70
from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet
59
71
from lp.registry.model.teammembership import TeamParticipation
60
 
from lp.services.database.constants import UTC_NOW
61
 
from lp.services.database.enumcol import DBEnum
62
 
from lp.services.database.lpstorm import (
63
 
    IMasterStore,
64
 
    IStore,
65
 
    )
66
 
from lp.services.webapp.interfaces import (
67
 
    DEFAULT_FLAVOR,
68
 
    IStoreSelector,
69
 
    MAIN_STORE,
70
 
    )
71
72
 
72
73
 
73
74
class BuildFarmJobOld:
100
101
        """See `IBuildFarmJobOld`."""
101
102
        raise NotImplementedError
102
103
 
103
 
    def getByJobs(self, job):
104
 
        """See `IBuildFarmJobOld`."""
105
 
        raise NotImplementedError
106
 
 
107
104
    def jobStarted(self):
108
105
        """See `IBuildFarmJobOld`."""
109
106
        pass
116
113
        """See `IBuildFarmJobOld`."""
117
114
        pass
118
115
 
119
 
    def jobCancel(self):
120
 
        """See `IBuildFarmJobOld`."""
121
 
        pass
122
 
 
123
116
    @staticmethod
124
117
    def addCandidateSelectionCriteria(processor, virtualized):
125
118
        """See `IBuildFarmJobOld`."""
164
157
        """
165
158
        raise NotImplementedError
166
159
 
167
 
    @staticmethod
168
 
    def preloadBuildFarmJobs(jobs):
169
 
        """Preload the build farm jobs to which the given jobs will delegate.
170
 
 
171
 
        """
172
 
        pass
173
 
 
174
160
    @classmethod
175
161
    def getByJob(cls, job):
176
162
        """See `IBuildFarmJobOld`."""
177
163
        store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
178
164
        return store.find(cls, cls.job == job).one()
179
165
 
180
 
    @classmethod
181
 
    def getByJobs(cls, jobs):
182
 
        """See `IBuildFarmJobOld`.
183
 
        """
184
 
        store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
185
 
        job_ids = [job.id for job in jobs]
186
 
        return store.find(
187
 
            cls, cls.job_id.is_in(job_ids))
188
 
 
189
166
    def generateSlaveBuildCookie(self):
190
167
        """See `IBuildFarmJobOld`."""
191
168
        buildqueue = getUtility(IBuildQueueSet).getByJob(self.job)
322
299
    # a job.
323
300
    jobAborted = jobReset
324
301
 
325
 
    def jobCancel(self):
326
 
        """See `IBuildFarmJob`."""
327
 
        self.status = BuildStatus.CANCELLED
328
 
 
329
302
    @staticmethod
330
303
    def addCandidateSelectionCriteria(processor, virtualized):
331
304
        """See `IBuildFarmJob`."""
373
346
        """See `IBuild`"""
374
347
        return self.status not in [BuildStatus.NEEDSBUILD,
375
348
                                   BuildStatus.BUILDING,
376
 
                                   BuildStatus.CANCELLED,
377
 
                                   BuildStatus.CANCELLING,
378
349
                                   BuildStatus.UPLOADING,
379
350
                                   BuildStatus.SUPERSEDED]
380
351