8687.15.17
by Karl Fogel
Add the copyright header block to the rest of the files under lib/lp/. |
1 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
|
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
3 |
||
7334.1.1
by Muharem Hrnjadovic
imported from dead branch |
4 |
# pylint: disable-msg=E0211,E0213
|
5 |
||
6 |
"""PackageCopyRequest interfaces."""
|
|
7 |
||
8 |
__metaclass__ = type |
|
9 |
||
10 |
__all__ = [ |
|
11 |
'IPackageCopyRequest', |
|
12 |
'IPackageCopyRequestSet', |
|
13 |
]
|
|
14 |
||
15 |
from zope.interface import Interface |
|
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
16 |
from zope.schema import ( |
17 |
Bool, |
|
18 |
Choice, |
|
19 |
Datetime, |
|
20 |
Int, |
|
21 |
Object, |
|
22 |
Text, |
|
23 |
)
|
|
7334.1.1
by Muharem Hrnjadovic
imported from dead branch |
24 |
|
14600.1.12
by Curtis Hovey
Move i18n to lp. |
25 |
from lp import _ |
7675.110.3
by Curtis Hovey
Ran the migration script to move registry code to lp.registry. |
26 |
from lp.registry.interfaces.distroseries import IDistroSeries |
27 |
from lp.registry.interfaces.person import IPerson |
|
9113.7.5
by Jonathan Lange
One more. |
28 |
from lp.registry.interfaces.pocket import PackagePublishingPocket |
11411.6.7
by Julian Edwards
Move PackageCopyStatus |
29 |
from lp.soyuz.enums import PackageCopyStatus |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
30 |
from lp.soyuz.interfaces.archive import IArchive |
31 |
from lp.soyuz.interfaces.component import IComponent |
|
7334.1.1
by Muharem Hrnjadovic
imported from dead branch |
32 |
|
33 |
||
34 |
class IPackageCopyRequest(Interface): |
|
35 |
"""A Build interface"""
|
|
36 |
||
37 |
id = Int(title=_('ID'), required=True, readonly=True) |
|
38 |
||
39 |
target_archive = Object( |
|
40 |
title=_("Target archive"), schema=IArchive, |
|
41 |
required=True, readonly=True, |
|
42 |
description=_("The archive to which packages will be copied.")) |
|
43 |
||
44 |
target_distroseries = Object( |
|
45 |
title=_("Target distroseries"), schema=IDistroSeries, |
|
46 |
required=False, readonly=True, |
|
47 |
description=_("The target DistroSeries.")) |
|
48 |
||
49 |
target_component = Object( |
|
50 |
title=_("Target component"), schema=IComponent, |
|
51 |
required=False, readonly=True, |
|
52 |
description=_("The target component.")) |
|
53 |
||
54 |
target_pocket = Choice( |
|
55 |
title=_('Target pocket'), required=False, |
|
56 |
vocabulary=PackagePublishingPocket, |
|
57 |
description=_("The target pocket.")) |
|
58 |
||
59 |
copy_binaries = Bool( |
|
60 |
title=_('Copy binaries'), required=True, default=False, |
|
61 |
description=_("Whether binary packages should be copied as well.")) |
|
62 |
||
63 |
source_archive = Object( |
|
64 |
title=_("Source archive"), schema=IArchive, |
|
65 |
required=True, readonly=True, |
|
66 |
description=_("The archive from which packages will be copied.")) |
|
67 |
||
68 |
source_distroseries = Object( |
|
69 |
title=_("Source distroseries"), schema=IDistroSeries, |
|
70 |
required=False, readonly=True, |
|
71 |
description=_("The source DistroSeries.")) |
|
72 |
||
73 |
source_component = Object( |
|
74 |
title=_("Source component"), schema=IComponent, |
|
75 |
required=False, readonly=True, |
|
76 |
description=_("The source component.")) |
|
77 |
||
78 |
source_pocket = Choice( |
|
79 |
title=_('Source pocket'), required=False, |
|
80 |
vocabulary=PackagePublishingPocket, |
|
81 |
description=_("The source pocket.")) |
|
82 |
||
83 |
requester = Object( |
|
84 |
title=_("Requester"), schema=IPerson, |
|
85 |
required=True, readonly=True, |
|
86 |
description=_("The person who requested the package copy operation.")) |
|
87 |
||
88 |
status = Choice( |
|
89 |
title=_('Copy status'), required=True, |
|
90 |
vocabulary=PackageCopyStatus, |
|
91 |
description=_("The current status of the copy operation.")) |
|
92 |
||
93 |
reason = Text( |
|
94 |
title=_('Reason'), required=False, |
|
95 |
description=_("The reason for this package copy operation.")) |
|
96 |
||
97 |
date_created = Datetime( |
|
98 |
title=_('Date created'), required=True, readonly=True, |
|
99 |
description=_("The time when the package copy request was created.")) |
|
100 |
||
101 |
date_started = Datetime( |
|
102 |
title=_('Date started'), required=False, readonly=False, |
|
103 |
description=_("The time when the copy request processing started.")) |
|
104 |
||
105 |
date_completed = Datetime( |
|
106 |
title=_('Date completed'), required=False, readonly=False, |
|
107 |
description=_("The time when the copy request processing completed.")) |
|
108 |
||
109 |
def __str__(): |
|
110 |
"""Return a textual representation of the package copy request."""
|
|
111 |
||
112 |
def markAsInprogress(): |
|
113 |
"""Mark this request as being in progress.
|
|
7334.1.3
by Muharem Hrnjadovic
Paul's review comments |
114 |
|
7334.1.1
by Muharem Hrnjadovic
imported from dead branch |
115 |
Update the 'status' and 'date_started' properties as appropriate.
|
116 |
"""
|
|
117 |
||
7334.1.4
by Muharem Hrnjadovic
Brad's review comments |
118 |
def markAsCompleted(): |
7334.1.1
by Muharem Hrnjadovic
imported from dead branch |
119 |
"""Mark this request as completed.
|
7334.1.3
by Muharem Hrnjadovic
Paul's review comments |
120 |
|
7334.1.1
by Muharem Hrnjadovic
imported from dead branch |
121 |
Update the 'status' and 'date_completed' properties as appropriate.
|
122 |
"""
|
|
123 |
||
124 |
def markAsFailed(): |
|
125 |
"""Mark this request as failed.
|
|
7334.1.3
by Muharem Hrnjadovic
Paul's review comments |
126 |
|
7334.1.1
by Muharem Hrnjadovic
imported from dead branch |
127 |
Update the 'status' and 'date_completed' properties as appropriate.
|
128 |
"""
|
|
129 |
||
130 |
def markAsCanceling(): |
|
131 |
"""Mark this request as canceling.
|
|
7334.1.3
by Muharem Hrnjadovic
Paul's review comments |
132 |
|
7334.1.1
by Muharem Hrnjadovic
imported from dead branch |
133 |
Update the 'status' as appropriate.
|
134 |
"""
|
|
135 |
||
136 |
def markAsCancelled(): |
|
137 |
"""Mark this request as cancelled.
|
|
7334.1.3
by Muharem Hrnjadovic
Paul's review comments |
138 |
|
7334.1.1
by Muharem Hrnjadovic
imported from dead branch |
139 |
Update the 'status' and 'date_completed' properties as appropriate.
|
140 |
"""
|
|
141 |
||
142 |
||
143 |
class IPackageCopyRequestSet(Interface): |
|
144 |
"""Interface for package copy requests."""
|
|
145 |
def new(source, target, requester, copy_binaries=False, reason=None): |
|
146 |
"""Create a new copy request using the package locations passed.
|
|
147 |
||
148 |
:param source: PackageLocation specifying the source of the package
|
|
149 |
copy operation.
|
|
150 |
:param target: PackageLocation specifying the target of the package
|
|
151 |
copy operation.
|
|
152 |
:param requester: The person who requested the package copy operation.
|
|
153 |
:param copy_binaries: Whether or not binary packages should be copied
|
|
154 |
as well.
|
|
155 |
:param reason: The reason for this package copy request.
|
|
156 |
||
157 |
:return: a newly created `IPackageCopyRequest`.
|
|
158 |
"""
|
|
159 |
||
160 |
def getByPersonAndStatus(requester, status=None): |
|
161 |
"""Return copy requests that match requester and status.
|
|
162 |
||
163 |
If no status is passed, all copy requests for 'requester' will be
|
|
164 |
returned.
|
|
165 |
||
166 |
:param requester: The person who requested the package copy operation.
|
|
167 |
:param status: Optional `PackageCopyStatus` filter, if passed only
|
|
168 |
copy requests with that status will be considered.
|
|
169 |
||
170 |
:return: a (potentially empty) result set of `IPackageCopyRequest`
|
|
171 |
instances.
|
|
172 |
"""
|
|
173 |
||
174 |
def getByTargetDistroSeries(distroseries): |
|
175 |
"""Return copy requests with matching target distroseries.
|
|
176 |
||
177 |
:param distroseries: The target distroseries to look for.
|
|
178 |
||
179 |
:return: a (potentially empty) result set of `IPackageCopyRequest`
|
|
180 |
instances.
|
|
181 |
"""
|
|
182 |
||
183 |
def getBySourceDistroSeries(distroseries): |
|
184 |
"""Return copy requests with matching source distroseries.
|
|
185 |
||
186 |
:param distroseries: The source distroseries to look for.
|
|
187 |
||
188 |
:return: a (potentially empty) result set of `IPackageCopyRequest`
|
|
189 |
instances.
|
|
190 |
"""
|
|
191 |
||
192 |
def getByTargetArchive(archive): |
|
193 |
"""Return copy requests with matching target archive.
|
|
194 |
||
195 |
:param distroseries: The target archive to look for.
|
|
196 |
||
197 |
:return: a (potentially empty) result set of `IPackageCopyRequest`
|
|
198 |
instances.
|
|
199 |
"""
|
|
200 |