~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/scripts/queue.py

  • Committer: Curtis Hovey
  • Date: 2011-05-27 21:03:22 UTC
  • mto: This revision was merged to the branch mainline in revision 13136.
  • Revision ID: curtis.hovey@canonical.com-20110527210322-yv1o7vkwr9u25t34
Moved templates to the packages that use them.

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-2010 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
# pylint: disable-msg=W0231
24
24
from zope.component import getUtility
25
25
 
26
26
from canonical.config import config
 
27
from lp.app.browser.tales import DurationFormatterAPI
27
28
from canonical.librarian.utils import filechunks
28
 
from lp.app.browser.tales import DurationFormatterAPI
29
29
from lp.app.errors import NotFoundError
30
30
from lp.services.propertycache import cachedproperty
31
31
from lp.soyuz.enums import PackageUploadStatus
79
79
 
80
80
    def __init__(self, distribution_name, suite_name, queue, terms,
81
81
                 component_name, section_name, priority_name,
82
 
                 display, no_mail=True, exact_match=False, log=None):
83
 
        """Initializes passed variables. """
 
82
                 announcelist, display, no_mail=True, exact_match=False,
 
83
                 log=None):
 
84
        """Initialises passed variables. """
84
85
        self.terms = terms
85
86
        # Some actions have addtional commands at the start of the terms
86
87
        # so allow them to state that here by specifiying the start index.
93
94
        self.no_mail = no_mail
94
95
        self.distribution_name = distribution_name
95
96
        self.suite_name = suite_name
 
97
        self.announcelist = announcelist
96
98
        self.default_sender = "%s <%s>" % (
97
99
            config.uploader.default_sender_name,
98
100
            config.uploader.default_sender_address)
110
112
            pocket=self.pocket)
111
113
 
112
114
    def setDefaultContext(self):
113
 
        """Set default distribuiton, distroseries."""
 
115
        """Set default distribuiton, distroseries, announcelist."""
114
116
        # if not found defaults to 'ubuntu'
115
117
 
116
118
        # Avoid circular imports.
120
122
        distroset = getUtility(IDistributionSet)
121
123
        try:
122
124
            self.distribution = distroset[self.distribution_name]
123
 
        except NotFoundError:
 
125
        except NotFoundError, info:
124
126
            self.distribution = distroset['ubuntu']
125
127
 
126
128
        if self.suite_name:
129
131
            try:
130
132
                self.distroseries, self.pocket = (
131
133
                    self.distribution.getDistroSeriesAndPocket(
132
 
                        self.suite_name))
133
 
            except NotFoundError:
 
134
                    self.suite_name))
 
135
            except NotFoundError, info:
134
136
                raise QueueActionError('Context not found: "%s/%s"'
135
137
                                       % (self.distribution.name,
136
138
                                          self.suite_name))
138
140
            self.distroseries = self.distribution.currentseries
139
141
            self.pocket = PackagePublishingPocket.RELEASE
140
142
 
 
143
        if not self.announcelist:
 
144
            self.announcelist = self.distroseries.changeslist
 
145
 
141
146
    def initialize(self):
142
147
        """Builds a list of affected records based on the filter argument."""
143
148
        self.setDefaultContext()
194
199
                    term, version = term.strip().split('/')
195
200
 
196
201
                # Expand SQLObject results.
197
 
                # XXX 2011-06-13 JeroenVermeulen bug=394645: This should
198
 
                # use getPackageUploads, not getQueueItems, so that it
199
 
                # will also include copy-job uploads.
200
202
                for item in self.distroseries.getQueueItems(
201
203
                    status=self.queue, name=term, version=version,
202
204
                    exact_match=self.exact_match, pocket=self.pocket):
270
272
        Optionally pass a binarypackagename via 'only' argument to display
271
273
        only exact matches within the selected build queue items.
272
274
        """
273
 
        if queue_item.package_copy_job or not queue_item.sources.is_empty():
274
 
            self.display(
275
 
                "\t | * %s/%s Component: %s Section: %s" % (
276
 
                    queue_item.package_name,
277
 
                    queue_item.package_version,
278
 
                    queue_item.component_name,
279
 
                    queue_item.section_name,
280
 
                    ))
 
275
        for source in queue_item.sources:
 
276
            spr = source.sourcepackagerelease
 
277
            self.display("\t | * %s/%s Component: %s Section: %s"
 
278
                         % (spr.sourcepackagename.name, spr.version,
 
279
                            spr.component.name, spr.section.name))
281
280
 
282
281
        for queue_build in queue_item.builds:
283
282
            for bpr in queue_build.build.binarypackages:
484
483
            self.display('Accepting %s' % queue_item.displayname)
485
484
            try:
486
485
                queue_item.acceptFromQueue(
487
 
                    logger=self.log, dry_run=self.no_mail)
 
486
                    announce_list=self.announcelist, logger=self.log,
 
487
                    dry_run=self.no_mail)
488
488
            except QueueInconsistentStateError, info:
489
489
                self.display('** %s could not be accepted due to %s'
490
490
                             % (queue_item.displayname, info))
522
522
 
523
523
    def __init__(self, distribution_name, suite_name, queue, terms,
524
524
                 component_name, section_name, priority_name,
525
 
                 display, no_mail=True, exact_match=False, log=None):
 
525
                 announcelist, display, no_mail=True, exact_match=False,
 
526
                 log=None):
526
527
        """Constructor for QueueActionOverride."""
527
528
 
528
529
        # This exists so that self.terms_start_index can be set as this action
531
532
        # over-ride.
532
533
        QueueAction.__init__(self, distribution_name, suite_name, queue,
533
534
                             terms, component_name, section_name,
534
 
                             priority_name, display, no_mail=True,
535
 
                             exact_match=False, log=log)
 
535
                             priority_name, announcelist, display,
 
536
                             no_mail=True, exact_match=False, log=log)
536
537
        self.terms_start_index = 1
537
538
        self.overrides_performed = 0
538
539
 
545
546
        # ("source" or "binary").
546
547
        try:
547
548
            override_stanza = self.terms[0]
548
 
        except IndexError:
 
549
        except IndexError, info:
549
550
            self.displayUsage('Missing override_stanza.')
550
551
            return
551
552
 
664
665
    """A wrapper for queue_action classes."""
665
666
 
666
667
    def __init__(self, queue, distribution_name, suite_name,
667
 
                 no_mail, component_name, section_name, priority_name,
668
 
                 display=default_display, log=None):
 
668
                 announcelist, no_mail, component_name, section_name,
 
669
                 priority_name, display=default_display, log=None):
669
670
        self.queue = queue
670
671
        self.distribution_name = distribution_name
671
672
        self.suite_name = suite_name
 
673
        self.announcelist = announcelist
672
674
        self.no_mail = no_mail
673
675
        self.component_name = component_name
674
676
        self.section_name = section_name
699
701
            queue_action = queue_action_class(
700
702
                distribution_name=self.distribution_name,
701
703
                suite_name=self.suite_name,
 
704
                announcelist=self.announcelist,
702
705
                queue=self.queue,
703
706
                no_mail=self.no_mail,
704
707
                display=self.display,