def proposeGoal(self, goal, proposer):
     """See ISpecification."""
     if goal is None:
         # we are clearing goals
         self.productseries = None
         self.distroseries = None
     elif (IProductSeries.providedBy(goal) and goal.product == self.target):
         # set the product series as a goal
         self.productseries = goal
         self.goal_proposer = proposer
         self.date_goal_proposed = UTC_NOW
         # and make sure there is no leftover distroseries goal
         self.distroseries = None
     elif (IDistroSeries.providedBy(goal)
           and goal.distribution == self.target):
         # set the distroseries goal
         self.distroseries = goal
         self.goal_proposer = proposer
         self.date_goal_proposed = UTC_NOW
         # and make sure there is no leftover distroseries goal
         self.productseries = None
     else:
         raise GoalProposeError('Inappropriate goal.')
     # record who made the proposal, and when
     self.goal_proposer = proposer
     self.date_goal_proposed = UTC_NOW
     # and of course set the goal status to PROPOSED
     self.goalstatus = SpecificationGoalStatus.PROPOSED
     # the goal should now also not have a decider
     self.goal_decider = None
     self.date_goal_decided = None
     if goal is not None and goal.personHasDriverRights(proposer):
         self.acceptBy(proposer)
 def proposeGoal(self, goal, proposer):
     """See ISpecification."""
     if goal is None:
         # we are clearing goals
         self.productseries = None
         self.distroseries = None
     elif (IProductSeries.providedBy(goal) and
           goal.product == self.target):
         # set the product series as a goal
         self.productseries = goal
         self.goal_proposer = proposer
         self.date_goal_proposed = UTC_NOW
         # and make sure there is no leftover distroseries goal
         self.distroseries = None
     elif (IDistroSeries.providedBy(goal) and
           goal.distribution == self.target):
         # set the distroseries goal
         self.distroseries = goal
         self.goal_proposer = proposer
         self.date_goal_proposed = UTC_NOW
         # and make sure there is no leftover distroseries goal
         self.productseries = None
     else:
         raise GoalProposeError('Inappropriate goal.')
     # record who made the proposal, and when
     self.goal_proposer = proposer
     self.date_goal_proposed = UTC_NOW
     # and of course set the goal status to PROPOSED
     self.goalstatus = SpecificationGoalStatus.PROPOSED
     # the goal should now also not have a decider
     self.goal_decider = None
     self.date_goal_decided = None
     if goal is not None and goal.personHasDriverRights(proposer):
         self.acceptBy(proposer)
Esempio n. 3
0
    def __init__(self, context, request):
        super(PillarInvolvementView, self).__init__(context, request)
        self.official_malone = False
        self.answers_usage = ServiceUsage.UNKNOWN
        self.blueprints_usage = ServiceUsage.UNKNOWN
        self.translations_usage = ServiceUsage.UNKNOWN
        self.codehosting_usage = ServiceUsage.UNKNOWN
        pillar = nearest(self.context, IPillar)

        self._set_official_launchpad(pillar)
        if IDistroSeries.providedBy(self.context):
            distribution = self.context.distribution
            self.codehosting_usage = distribution.codehosting_usage
            self.answers_usage = ServiceUsage.NOT_APPLICABLE
        elif IDistributionSourcePackage.providedBy(self.context):
            self.blueprints_usage = ServiceUsage.UNKNOWN
            self.translations_usage = ServiceUsage.UNKNOWN
        elif IProjectGroup.providedBy(pillar):
            # XXX: 2010-10-07 EdwinGrubbs bug=656292
            # Fix _set_official_launchpad().

            # Project groups do not support submit code, override the
            # default.
            self.codehosting_usage = ServiceUsage.NOT_APPLICABLE
        else:
            # The context is used by all apps.
            pass
Esempio n. 4
0
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 ([], [])
Esempio n. 5
0
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 ([], [])
Esempio n. 6
0
    def __init__(self, context, request):
        super(PillarInvolvementView, self).__init__(context, request)
        self.official_malone = False
        self.answers_usage = ServiceUsage.UNKNOWN
        self.blueprints_usage = ServiceUsage.UNKNOWN
        self.translations_usage = ServiceUsage.UNKNOWN
        self.codehosting_usage = ServiceUsage.UNKNOWN
        pillar = nearest(self.context, IPillar)

        self._set_official_launchpad(pillar)
        if IDistroSeries.providedBy(self.context):
            distribution = self.context.distribution
            self.codehosting_usage = distribution.codehosting_usage
            self.answers_usage = ServiceUsage.NOT_APPLICABLE
        elif IDistributionSourcePackage.providedBy(self.context):
            self.blueprints_usage = ServiceUsage.UNKNOWN
            self.translations_usage = ServiceUsage.UNKNOWN
        elif IProjectGroup.providedBy(pillar):
            # XXX: 2010-10-07 EdwinGrubbs bug=656292
            # Fix _set_official_launchpad().

            # Project groups do not support submit code, override the
            # default.
            self.codehosting_usage = ServiceUsage.NOT_APPLICABLE
        else:
            # The context is used by all apps.
            pass
 def ensureMirrorDistroSeriesSource(self, distroseries, pocket, component):
     """See `IDistributionMirror`."""
     assert IDistroSeries.providedBy(distroseries)
     mirror = self._getMirrorDistroSeriesSource(
         distroseries=distroseries, pocket=pocket, component=component)
     if mirror is None:
         mirror = MirrorDistroSeriesSource(
             distribution_mirror=self, distroseries=distroseries,
             pocket=pocket, component=component)
     return mirror
def get_specification_active_product_filter(context):
    if (IDistribution.providedBy(context) or IDistroSeries.providedBy(context)
        or IProduct.providedBy(context) or IProductSeries.providedBy(context)):
        return [], []
    from lp.registry.model.product import Product
    tables = [
        LeftJoin(Product, Specification.productID == Product.id)]
    active_products = (
        Or(Specification.product == None, Product.active == True))
    return tables, [active_products]
Esempio n. 9
0
def get_specification_active_product_filter(context):
    if (IDistribution.providedBy(context) or IDistroSeries.providedBy(context)
            or IProduct.providedBy(context)
            or IProductSeries.providedBy(context)):
        return [], []
    from lp.registry.model.product import Product
    tables = [LeftJoin(Product, Specification.productID == Product.id)]
    active_products = (Or(Specification.product == None,
                          Product.active == True))
    return tables, [active_products]
Esempio n. 10
0
    def __iter__(self):
        if not IDistroSeries.providedBy(self.context):
            # This vocabulary is only useful from a DistroSeries context.
            return

        query = self._baseQueryList()
        query.append("distroseries = %s" % sqlvalues(self.context))
        language_packs = self._table.select(" AND ".join(query), orderBy=self._orderBy)

        for language_pack in language_packs:
            yield self.toTerm(language_pack)
def get_bugtaskflat_constraint(target):
    """Convert an `IBugTarget` to a list of constraints on BugTaskFlat."""
    raw_key = bug_target_to_key(target)
    # For the purposes of BugSummary, DSP/SP tasks count for their
    # distro(series).
    if IDistribution.providedBy(target) or IDistroSeries.providedBy(target):
        del raw_key['sourcepackagename']
    # Map to ID columns to work around Storm bug #682989.
    return [
        getattr(BugTaskFlat, '%s_id' % k) == (v.id if v else None)
        for (k, v) in raw_key.items()]
Esempio n. 12
0
 def ensureMirrorDistroSeriesSource(self, distroseries, pocket, component):
     """See `IDistributionMirror`."""
     assert IDistroSeries.providedBy(distroseries)
     mirror = self._getMirrorDistroSeriesSource(distroseries=distroseries,
                                                pocket=pocket,
                                                component=component)
     if mirror is None:
         mirror = MirrorDistroSeriesSource(distribution_mirror=self,
                                           distroseries=distroseries,
                                           pocket=pocket,
                                           component=component)
     return mirror
Esempio n. 13
0
    def __iter__(self):
        if not IDistroSeries.providedBy(self.context):
            # This vocabulary is only useful from a DistroSeries context.
            return

        query = self._baseQueryList()
        query.append('distroseries = %s' % sqlvalues(self.context))
        language_packs = self._table.select(' AND '.join(query),
                                            orderBy=self._orderBy)

        for language_pack in language_packs:
            yield self.toTerm(language_pack)
Esempio n. 14
0
def get_bugtaskflat_constraint(target):
    """Convert an `IBugTarget` to a list of constraints on BugTaskFlat."""
    raw_key = bug_target_to_key(target)
    # For the purposes of BugSummary, DSP/SP tasks count for their
    # distro(series).
    if IDistribution.providedBy(target) or IDistroSeries.providedBy(target):
        del raw_key['sourcepackagename']
    # Map to ID columns to work around Storm bug #682989.
    return [
        getattr(BugTaskFlat, '%s_id' % k) == (v.id if v else None)
        for (k, v) in raw_key.items()
    ]
    def __call__(self, context):
        import_queue = getUtility(ITranslationImportQueue)
        if hasattr(self, 'view'):
            user = self.view.user
        else:
            user = None
        targets = import_queue.getRequestTargets(user)
        filtered_targets = set()

        # Read filter_status, in order to mark targets that have requests with
        # that status pending.  This works because we set up the filter_status
        # widget before the filter_target one, which uses this vocabulary
        # factory.
        status_widget = self.view.widgets['filter_status']
        if status_widget.hasInput():
            try:
                status_filter = status_widget.getInputValue()
            except ConversionError:
                raise UnexpectedFormData("Invalid status parameter.")
            if status_filter != 'all':
                try:
                    status = RosettaImportStatus.items[status_filter]
                    filtered_targets = set(
                        import_queue.getRequestTargets(user=None,
                                                       status=status))
                except LookupError:
                    # Unknown status.  Ignore.
                    pass

        terms = [SimpleTerm('all', 'all', 'All targets')]

        for item in SpecialTranslationImportTargetFilter.items:
            term_name = '[%s]' % item.name
            terms.append(SimpleTerm(term_name, term_name, item.title))

        for target in targets:
            if IDistroSeries.providedBy(target):
                # Distroseries are not pillar names, we need to note
                # distribution.name/distroseries.name
                term_name = '%s/%s' % (target.distribution.name, target.name)
            else:
                term_name = target.name

            displayname = target.displayname
            if target in filtered_targets:
                displayname += '*'

            terms.append(SimpleTerm(term_name, term_name, displayname))
        return SimpleVocabulary(terms)
Esempio n. 16
0
def milestone_matches_bugtask(milestone, bugtask):
    """ Return True if the milestone can be set against this bugtask."""
    bug_target = bugtask.target
    naked_milestone = removeSecurityProxy(milestone)

    if IProduct.providedBy(bug_target):
        return bugtask.product.id == naked_milestone.productID
    elif IProductSeries.providedBy(bug_target):
        return bugtask.productseries.product.id == naked_milestone.productID
    elif (IDistribution.providedBy(bug_target)
          or IDistributionSourcePackage.providedBy(bug_target)):
        return bugtask.distribution.id == naked_milestone.distributionID
    elif (IDistroSeries.providedBy(bug_target)
          or ISourcePackage.providedBy(bug_target)):
        return bugtask.distroseries.id == naked_milestone.distroseriesID
    return False
Esempio n. 17
0
def milestone_matches_bugtask(milestone, bugtask):
    """ Return True if the milestone can be set against this bugtask."""
    bug_target = bugtask.target
    naked_milestone = removeSecurityProxy(milestone)

    if IProduct.providedBy(bug_target):
        return bugtask.product.id == naked_milestone.productID
    elif IProductSeries.providedBy(bug_target):
        return bugtask.productseries.product.id == naked_milestone.productID
    elif (IDistribution.providedBy(bug_target) or
          IDistributionSourcePackage.providedBy(bug_target)):
        return bugtask.distribution.id == naked_milestone.distributionID
    elif (IDistroSeries.providedBy(bug_target) or
          ISourcePackage.providedBy(bug_target)):
        return bugtask.distroseries.id == naked_milestone.distroseriesID
    return False
    def __call__(self, context):
        import_queue = getUtility(ITranslationImportQueue)
        if hasattr(self, "view"):
            user = self.view.user
        else:
            user = None
        targets = import_queue.getRequestTargets(user)
        filtered_targets = set()

        # Read filter_status, in order to mark targets that have requests with
        # that status pending.  This works because we set up the filter_status
        # widget before the filter_target one, which uses this vocabulary
        # factory.
        status_widget = self.view.widgets["filter_status"]
        if status_widget.hasInput():
            try:
                status_filter = status_widget.getInputValue()
            except ConversionError:
                raise UnexpectedFormData("Invalid status parameter.")
            if status_filter != "all":
                try:
                    status = RosettaImportStatus.items[status_filter]
                    filtered_targets = set(import_queue.getRequestTargets(user=None, status=status))
                except LookupError:
                    # Unknown status.  Ignore.
                    pass

        terms = [SimpleTerm("all", "all", "All targets")]

        for item in SpecialTranslationImportTargetFilter.items:
            term_name = "[%s]" % item.name
            terms.append(SimpleTerm(term_name, term_name, item.title))

        for target in targets:
            if IDistroSeries.providedBy(target):
                # Distroseries are not pillar names, we need to note
                # distribution.name/distroseries.name
                term_name = "%s/%s" % (target.distribution.name, target.name)
            else:
                term_name = target.name

            displayname = target.displayname
            if target in filtered_targets:
                displayname += "*"

            terms.append(SimpleTerm(term_name, term_name, displayname))
        return SimpleVocabulary(terms)
Esempio n. 19
0
    def setTarget(self, target):
        """Constrain the search to only return items in target.

        This is equivalent to calling setProduct etc but the type of target
        does not need to be known to the caller.

        :param target: A `IHasBug`, or some search term like all/any/none on
            `IHasBug`. If using all/any all the targets must be of the
            same type due to implementation limitations. Currently only
            distroseries and productseries `IHasBug` implementations are
            supported.
        """
        # Yay circular deps.
        from lp.registry.interfaces.distribution import IDistribution
        from lp.registry.interfaces.distroseries import IDistroSeries
        from lp.registry.interfaces.product import IProduct
        from lp.registry.interfaces.productseries import IProductSeries
        from lp.registry.interfaces.milestone import IMilestone
        from lp.registry.interfaces.projectgroup import IProjectGroup
        from lp.registry.interfaces.sourcepackage import ISourcePackage
        from lp.registry.interfaces.distributionsourcepackage import \
            IDistributionSourcePackage
        if isinstance(target, (any, all)):
            assert len(target.query_values), \
                'cannot determine target with no targets'
            instance = target.query_values[0]
        else:
            instance = target
        if IDistribution.providedBy(instance):
            self.setDistribution(target)
        elif IDistroSeries.providedBy(instance):
            self.setDistroSeries(target)
        elif IProduct.providedBy(instance):
            self.setProduct(target)
        elif IProductSeries.providedBy(instance):
            self.setProductSeries(target)
        elif IMilestone.providedBy(instance):
            self.milestone = target
        elif ISourcePackage.providedBy(instance):
            self.setSourcePackage(target)
        elif IDistributionSourcePackage.providedBy(instance):
            self.setSourcePackage(target)
        elif IProjectGroup.providedBy(instance):
            self.setProject(target)
        else:
            raise AssertionError("unknown target type %r" % target)
Esempio n. 20
0
    def setTarget(self, target):
        """Constrain the search to only return items in target.

        This is equivalent to calling setProduct etc but the type of target
        does not need to be known to the caller.

        :param target: A `IHasBug`, or some search term like all/any/none on
            `IHasBug`. If using all/any all the targets must be of the
            same type due to implementation limitations. Currently only
            distroseries and productseries `IHasBug` implementations are
            supported.
        """
        # Yay circular deps.
        from lp.registry.interfaces.distribution import IDistribution
        from lp.registry.interfaces.distroseries import IDistroSeries
        from lp.registry.interfaces.product import IProduct
        from lp.registry.interfaces.productseries import IProductSeries
        from lp.registry.interfaces.milestone import IMilestone
        from lp.registry.interfaces.projectgroup import IProjectGroup
        from lp.registry.interfaces.sourcepackage import ISourcePackage
        from lp.registry.interfaces.distributionsourcepackage import \
            IDistributionSourcePackage
        if isinstance(target, (any, all)):
            assert len(target.query_values), \
                'cannot determine target with no targets'
            instance = target.query_values[0]
        else:
            instance = target
        if IDistribution.providedBy(instance):
            self.setDistribution(target)
        elif IDistroSeries.providedBy(instance):
            self.setDistroSeries(target)
        elif IProduct.providedBy(instance):
            self.setProduct(target)
        elif IProductSeries.providedBy(instance):
            self.setProductSeries(target)
        elif IMilestone.providedBy(instance):
            self.milestone = target
        elif ISourcePackage.providedBy(instance):
            self.setSourcePackage(target)
        elif IDistributionSourcePackage.providedBy(instance):
            self.setSourcePackage(target)
        elif IProjectGroup.providedBy(instance):
            self.setProjectGroup(target)
        else:
            raise AssertionError("unknown target type %r" % target)
 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.')
Esempio n. 22
0
 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.')
Esempio n. 23
0
 def _getByName(self, name):
     """Return the named milestone from the context."""
     # IProductSeries and IDistroSeries are imported here to
     # avoid an import loop.
     from lp.registry.interfaces.productseries import (IProductSeries)
     from lp.registry.interfaces.distroseries import IDistroSeries
     if IMilestone.providedBy(self.context):
         milestone = self.context.target.getMilestone(name)
     elif IProductSeries.providedBy(self.context):
         milestone = self.context.product.getMilestone(name)
     elif IDistroSeries.providedBy(self.context):
         milestone = self.context.distribution.getMilestone(name)
     else:
         raise AssertionError(
             'Editing a milestone in an unexpected context: %r' %
             self.context)
     if milestone is not None:
         self.errormessage = _(
             "The name %%s is already used by a milestone in %s." %
             milestone.target.displayname)
     return milestone
Esempio n. 24
0
 def _getByName(self, name):
     """Return the named milestone from the context."""
     # IProductSeries and IDistroSeries are imported here to
     # avoid an import loop.
     from lp.registry.interfaces.productseries import (
         IProductSeries)
     from lp.registry.interfaces.distroseries import IDistroSeries
     if IMilestone.providedBy(self.context):
         milestone = self.context.target.getMilestone(name)
     elif IProductSeries.providedBy(self.context):
         milestone = self.context.product.getMilestone(name)
     elif IDistroSeries.providedBy(self.context):
         milestone = self.context.distribution.getMilestone(name)
     else:
         raise AssertionError(
             'Editing a milestone in an unexpected context: %r'
             % self.context)
     if milestone is not None:
         self.errormessage = _(
             "The name %%s is already used by a milestone in %s."
             % milestone.target.displayname)
     return milestone
    def initialize(self):
        if IPerson.providedBy(self.context):
            self.is_person = True
        elif IDistribution.providedBy(self.context):
            self.is_target = True
            self.is_pillar = True
            self.show_series = True
        elif IProduct.providedBy(self.context):
            self.is_target = True
            self.is_pillar = True
            self.has_wiki = True
            self.show_series = True
        elif IProjectGroup.providedBy(self.context):
            self.is_project = True
            self.is_pillar = True
            self.has_wiki = True
            self.show_target = True
            self.show_series = True
        elif IProjectGroupSeries.providedBy(self.context):
            self.show_milestone = True
            self.show_target = True
            self.show_series = True
        elif (IProductSeries.providedBy(self.context) or
              IDistroSeries.providedBy(self.context)):
            self.is_series = True
            self.show_milestone = True
        elif ISprint.providedBy(self.context):
            self.is_sprint = True
            self.show_target = True
        else:
            raise AssertionError('Unknown blueprint listing site.')

        if IHasDrivers.providedBy(self.context):
            self.has_drivers = True

        self.batchnav = BatchNavigator(
            self.specs, self.request,
            size=config.launchpad.default_batch_size)
    def initialize(self):
        if IPerson.providedBy(self.context):
            self.is_person = True
        elif IDistribution.providedBy(self.context):
            self.is_target = True
            self.is_pillar = True
            self.show_series = True
        elif IProduct.providedBy(self.context):
            self.is_target = True
            self.is_pillar = True
            self.has_wiki = True
            self.show_series = True
        elif IProjectGroup.providedBy(self.context):
            self.is_project = True
            self.is_pillar = True
            self.has_wiki = True
            self.show_target = True
            self.show_series = True
        elif IProjectGroupSeries.providedBy(self.context):
            self.show_milestone = True
            self.show_target = True
            self.show_series = True
        elif (IProductSeries.providedBy(self.context)
              or IDistroSeries.providedBy(self.context)):
            self.is_series = True
            self.show_milestone = True
        elif ISprint.providedBy(self.context):
            self.is_sprint = True
            self.show_target = True
        else:
            raise AssertionError('Unknown blueprint listing site.')

        if IHasDrivers.providedBy(self.context):
            self.has_drivers = True

        self.batchnav = BatchNavigator(
            self.specs, self.request, size=config.launchpad.default_batch_size)
Esempio n. 27
0
 def __init__(self, distroseries, sourcepackagerelease):
     assert IDistroSeries.providedBy(distroseries)
     self.distroseries = distroseries
     assert ISourcePackageRelease.providedBy(sourcepackagerelease)
     self.sourcepackagerelease = sourcepackagerelease
Esempio n. 28
0
    def is_distroseries_milestone(self):
        """Is the current milestone is a distroseries milestone?

        Milestones that belong to distroseries cannot have releases.
        """
        return IDistroSeries.providedBy(self.context.series_target)
Esempio n. 29
0
    def is_distroseries_milestone(self):
        """Is the current milestone is a distroseries milestone?

        Milestones that belong to distroseries cannot have releases.
        """
        return IDistroSeries.providedBy(self.context.series_target)
    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)))
 def __init__(self, distroseries, sourcepackagerelease):
     assert IDistroSeries.providedBy(distroseries)
     self.distroseries = distroseries
     assert ISourcePackageRelease.providedBy(sourcepackagerelease)
     self.sourcepackagerelease = sourcepackagerelease