~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/archivepublisher/scripts/publish_ftpmaster.py

  • Committer: Jelmer Vernooij
  • Date: 2011-08-22 21:04:00 UTC
  • mfrom: (13261.7.21 bzr-2.4b4)
  • mto: This revision was merged to the branch mainline in revision 13941.
  • Revision ID: jelmer@canonical.com-20110822210400-3hfq31q2wgrtauad
Merge bzr-2.4b4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    )
28
28
from lp.services.utils import file_exists
29
29
from lp.soyuz.enums import ArchivePurpose
 
30
from lp.soyuz.scripts.custom_uploads_copier import CustomUploadsCopier
30
31
from lp.soyuz.scripts.ftpmaster import LpQueryDistro
31
32
from lp.soyuz.scripts.processaccepted import ProcessAccepted
32
33
from lp.soyuz.scripts.publishdistro import PublishDistro
295
296
                "Indexes for %s were created on %s.\n"
296
297
                % (suite, datetime.now(utc)))
297
298
 
298
 
    def createIndexes(self, distribution, suite):
299
 
        """Create archive indexes for `distroseries`."""
300
 
        self.logger.info("Creating archive indexes for %s.", suite)
301
 
        self.runPublishDistro(distribution, args=['-A'], suites=[suite])
302
 
        self.markIndexCreationComplete(distribution, suite)
 
299
    def createIndexes(self, distribution, suites):
 
300
        """Create archive indexes for `suites` of `distroseries`."""
 
301
        self.logger.info(
 
302
            "Creating archive indexes for %s.", ', '.join(suites))
 
303
        self.runPublishDistro(distribution, args=['-A'], suites=suites)
 
304
        for suite in suites:
 
305
            self.markIndexCreationComplete(distribution, suite)
303
306
 
304
307
    def processAccepted(self, distribution):
305
308
        """Run the process-accepted script."""
563
566
            self.recoverWorkingDists()
564
567
            raise
565
568
 
 
569
    def prepareFreshSeries(self, distribution):
 
570
        """If there are any new distroseries, prepare them for publishing.
 
571
 
 
572
        :return: True if a series did indeed still need some preparation,
 
573
            of False for the normal case.
 
574
        """
 
575
        have_fresh_series = False
 
576
        for series in distribution.series:
 
577
            suites_needing_indexes = self.listSuitesNeedingIndexes(series)
 
578
            if len(suites_needing_indexes) != 0:
 
579
                # This is a fresh series.
 
580
                have_fresh_series = True
 
581
                if series.previous_series is not None:
 
582
                    CustomUploadsCopier(series).copy(series.previous_series)
 
583
                self.createIndexes(distribution, suites_needing_indexes)
 
584
 
 
585
        return have_fresh_series
 
586
 
566
587
    def setUp(self):
567
588
        """Process options, and set up internal state."""
568
589
        self.processOptions()
570
591
 
571
592
    def processDistro(self, distribution):
572
593
        """Process `distribution`."""
573
 
        for series in distribution.series:
574
 
            suites_needing_indexes = self.listSuitesNeedingIndexes(series)
575
 
            if len(suites_needing_indexes) > 0:
576
 
                for suite in suites_needing_indexes:
577
 
                    self.createIndexes(distribution, suite)
578
 
                # Don't try to do too much in one run.  Leave the rest
579
 
                # of the work for next time.
580
 
                return
 
594
        if self.prepareFreshSeries(distribution):
 
595
            # We've done enough here.  Leave some server time for others.
 
596
            return
581
597
 
582
598
        self.processAccepted(distribution)
583
599