46
47
from lp.soyuz.scripts.packagecopier import do_copy
50
def specify_dsd_package(dsd):
51
"""Return (name, parent version) for `dsd`'s package.
53
This describes the package that `dsd` is for in a format suitable for
54
`PlainPackageCopyJobSource`.
56
:param dsd: A `DistroSeriesDifference`.
58
return (dsd.source_package_name.name, dsd.parent_source_version)
49
61
class PackageCopyJob(StormBase):
50
62
"""Base class for package copying jobs."""
174
186
PackageCopyJob.target_archive == target_archive)
175
187
return DecoratedResultSet(jobs, cls)
190
def getPendingJobsForTargetSeries(cls, target_series):
191
"""Get upcoming jobs for `target_series`, ordered by age."""
192
raw_jobs = IStore(PackageCopyJob).find(
194
Job.id == PackageCopyJob.job_id,
195
PackageCopyJob.job_type == cls.class_job_type,
196
PackageCopyJob.target_distroseries == target_series,
197
Job._status.is_in(Job.PENDING_STATUSES))
198
raw_jobs = raw_jobs.order_by(PackageCopyJob.id)
199
return DecoratedResultSet(raw_jobs, cls)
202
def getPendingJobsPerPackage(cls, target_series):
203
"""See `IPlainPackageCopyJobSource`."""
205
# Go through jobs in-order, picking the first matching job for
206
# any (package, version) tuple. Because of how
207
# getPendingJobsForTargetSeries orders its results, the first
208
# will be the oldest and thus presumably the first to finish.
209
for job in cls.getPendingJobsForTargetSeries(target_series):
210
for package in job.metadata["source_packages"]:
211
result.setdefault(tuple(package), job)
178
215
def source_packages(self):
179
216
getPublishedSources = self.source_archive.getPublishedSources