def make_distro_target_clause(distro_target): """Create a where expression and a table list to limit results to a distro target. """ if distro_target is not None: if IDistroArchSeries.providedBy(distro_target): return ( [HWSubmission], [HWSubmission.distroarchseries == distro_target.id]) elif IDistroSeries.providedBy(distro_target): return ( [DistroArchSeries, HWSubmission], [ HWSubmission.distroarchseries == DistroArchSeries.id, DistroArchSeries.distroseries == distro_target.id, ]) elif IDistribution.providedBy(distro_target): return ( [DistroArchSeries, DistroSeries, HWSubmission], [ HWSubmission.distroarchseries == DistroArchSeries.id, DistroArchSeries.distroseries == DistroSeries.id, DistroSeries.distribution == distro_target.id, ]) else: raise ValueError( 'Parameter distro_target must be an IDistribution, ' 'IDistroSeries or IDistroArchSeries') return ([], [])
def make_distro_target_clause(distro_target): """Create a where expression and a table list to limit results to a distro target. """ if distro_target is not None: if IDistroArchSeries.providedBy(distro_target): return ([HWSubmission], [HWSubmission.distroarchseries == distro_target.id]) elif IDistroSeries.providedBy(distro_target): return ( [DistroArchSeries, HWSubmission], [ HWSubmission.distroarchseries == DistroArchSeries.id, DistroArchSeries.distroseries == distro_target.id, ], ) elif IDistribution.providedBy(distro_target): return ( [DistroArchSeries, DistroSeries, HWSubmission], [ HWSubmission.distroarchseries == DistroArchSeries.id, DistroArchSeries.distroseries == DistroSeries.id, DistroSeries.distribution == distro_target.id, ], ) else: raise ValueError("Parameter distro_target must be an IDistribution, " "IDistroSeries or IDistroArchSeries") return ([], [])
def ensureMirrorDistroArchSeries(self, distro_arch_series, pocket, component): """See `IDistributionMirror`.""" assert IDistroArchSeries.providedBy(distro_arch_series) mirror = self._getMirrorDistroArchSeries( distro_arch_series=distro_arch_series, pocket=pocket, component=component) if mirror is None: mirror = MirrorDistroArchSeries( pocket=pocket, distribution_mirror=self, distro_arch_series=distro_arch_series, component=component) return mirror
def _getSeriesPocketAndComponentDescription(self): """Return a string containing the name of the series, pocket and component. This is meant to be used in the logs, to help us identify if this is a MirrorDistroSeriesSource or a MirrorDistroArchSeries. """ if IDistroArchSeries.providedBy(self.series): text = ("Series %s, Architecture %s" % (self.series.distroseries.title, self.series.architecturetag)) else: text = "Series %s" % self.series.title text += (", Component %s and Pocket %s" % (self.component.name, self.pocket.title)) return text
def _getSeriesPocketAndComponentDescription(self): """Return a string containing the name of the series, pocket and component. This is meant to be used in the logs, to help us identify if this is a MirrorDistroSeriesSource or a MirrorDistroArchSeries. """ if IDistroArchSeries.providedBy(self.series): series = self.series.distroseries arch = self.series.architecturetag else: series = self.series arch = 'source' return '%s %s %s %s' % (series.distribution.name, series.getSuite( self.pocket), arch, self.component.name)
def _getSeriesPocketAndComponentDescription(self): """Return a string containing the name of the series, pocket and component. This is meant to be used in the logs, to help us identify if this is a MirrorDistroSeriesSource or a MirrorDistroArchSeries. """ if IDistroArchSeries.providedBy(self.series): text = ( "Series %s, Architecture %s" % (self.series.distroseries.title, self.series.architecturetag)) else: text = "Series %s" % self.series.title text += (", Component %s and Pocket %s" % (self.component.name, self.pocket.title)) return text
def __init__(self, mirror, series, pocket, component, url, log_file): self.mirror = mirror self.series = series self.pocket = pocket self.component = component self.url = url self.log_file = log_file if IDistroArchSeries.providedBy(series): self.mirror_class_name = 'MirrorDistroArchSeries' self.deleteMethod = self.mirror.deleteMirrorDistroArchSeries self.ensureMethod = self.mirror.ensureMirrorDistroArchSeries elif IDistroSeries.providedBy(series): self.mirror_class_name = 'MirrorDistroSeries' self.deleteMethod = self.mirror.deleteMirrorDistroSeriesSource self.ensureMethod = self.mirror.ensureMirrorDistroSeriesSource else: raise AssertionError('series must provide either ' 'IDistroArchSeries or IDistroSeries.')
def getBuildsForDistro(self, context, status=None, name=None, pocket=None, arch_tag=None): """See `IBinaryPackageBuildSet`.""" if IDistribution.providedBy(context): col = BinaryPackageBuild.distribution_id elif IDistroSeries.providedBy(context): col = BinaryPackageBuild.distro_series_id elif IDistroArchSeries.providedBy(context): col = BinaryPackageBuild.distro_arch_series_id else: raise AssertionError("Unsupported context: %r" % context) condition_clauses = [ col == context.id, BinaryPackageBuild.is_distro_archive] # XXX cprov 2006-09-25: It would be nice if we could encapsulate # the chunk of code below (which deals with the optional paramenters) # and share it with ISourcePackage.getBuildRecords() # exclude gina-generated and security (dak-made) builds # status == FULLYBUILT && datebuilt == null if status == BuildStatus.FULLYBUILT: condition_clauses.append(BinaryPackageBuild.date_finished != None) else: condition_clauses.append(Or( BinaryPackageBuild.status != BuildStatus.FULLYBUILT, BinaryPackageBuild.date_finished != None)) # Ordering according status # * NEEDSBUILD, BUILDING & UPLOADING by -lastscore # * SUPERSEDED & All by -BinaryPackageBuild.id # (nearly equivalent to -datecreated, but much more # efficient.) # * FULLYBUILT & FAILURES by -datebuilt # It should present the builds in a more natural order. clauseTables = [] order_by_table = None if status in [ BuildStatus.NEEDSBUILD, BuildStatus.BUILDING, BuildStatus.UPLOADING]: order_by = [Desc(BuildQueue.lastscore), BinaryPackageBuild.id] order_by_table = BuildQueue clauseTables.extend([BuildQueue, BuildPackageJob]) condition_clauses.extend([ BuildPackageJob.build_id == BinaryPackageBuild.id, BuildPackageJob.job_id == BuildQueue.jobID]) elif status == BuildStatus.SUPERSEDED or status is None: order_by = [Desc(BinaryPackageBuild.id)] else: order_by = [Desc(BinaryPackageBuild.date_finished), BinaryPackageBuild.id] # End of duplication (see XXX cprov 2006-09-25 above). self.handleOptionalParamsForBuildQueries( condition_clauses, clauseTables, status, name, pocket, arch_tag) find_spec = (BinaryPackageBuild,) if order_by_table: find_spec = find_spec + (order_by_table,) result_set = IStore(BinaryPackageBuild).using(*clauseTables).find( find_spec, *condition_clauses) result_set.order_by(*order_by) return self._decorate_with_prejoins( DecoratedResultSet(result_set, result_decorator=itemgetter(0)))