~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

[r=bac,
        julian-edwards][bug=862247] Initialization is not possible if the
        series has no publisher setup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from canonical.launchpad.helpers import ensure_unicode
19
19
from canonical.launchpad.interfaces.lpstorm import IMasterStore
20
20
from lp.app.errors import NotFoundError
 
21
from lp.archivepublisher.interfaces.publisherconfig import IPublisherConfigSet
21
22
from lp.buildmaster.enums import BuildStatus
22
23
from lp.registry.interfaces.distroseriesparent import IDistroSeriesParentSet
23
24
from lp.registry.interfaces.pocket import PackagePublishingPocket
147
148
                ("Series {child.name} has already been initialised"
148
149
                 ".").format(
149
150
                    child=self.distroseries))
 
151
        self._checkPublisherConfig()
150
152
        if (self.distroseries.distribution.has_published_sources and
151
153
            self.distroseries.previous_series is None):
152
154
            raise InitializationError(
160
162
            self._checkQueue(parent)
161
163
        self._checkSeries()
162
164
 
 
165
    def _checkPublisherConfig(self):
 
166
        """A series cannot be initialized if it has no publisher config
 
167
        set up.
 
168
        """
 
169
        publisherconfigset = getUtility(IPublisherConfigSet)
 
170
        config = publisherconfigset.getByDistribution(
 
171
            self.distroseries.distribution)
 
172
        if config is None:
 
173
            raise InitializationError(
 
174
                ("Distribution {child.name} has no publisher configuration. "
 
175
                 "Please ask an administrator to set this up"
 
176
                 ".").format(
 
177
                    child=self.distroseries.distribution))
 
178
 
163
179
    def _checkParents(self):
164
180
        """If self.first_derivation, the parents list cannot be empty."""
165
181
        if self.first_derivation: