~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Colin Watson
  • Date: 2011-08-19 00:25:11 UTC
  • mfrom: (7675.1045.728 db-devel)
  • mto: This revision was merged to the branch mainline in revision 13909.
  • Revision ID: cjwatson@canonical.com-20110819002511-0x8hrqs1ckiqk53g
merge db-devel

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
# that it needs a bit of redesigning here around the publication stuff.
61
61
from lp.archivepublisher.config import getPubConfig
62
62
from lp.archivepublisher.customupload import CustomUploadError
 
63
from lp.archivepublisher.debversion import Version
63
64
from lp.archiveuploader.tagfiles import parse_tagfile_content
64
65
from lp.registry.interfaces.pocket import PackagePublishingPocket
65
66
from lp.registry.model.sourcepackagename import SourcePackageName
562
563
            # don't think we need them for sync rejections.
563
564
            return
564
565
 
565
 
        changes_file_object = StringIO.StringIO(self.changesfile.read())
 
566
        if self.changesfile is None:
 
567
            changes_file_object = None
 
568
        else:
 
569
            changes_file_object = StringIO.StringIO(self.changesfile.read())
566
570
        # We allow unsigned uploads since they come from the librarian,
567
571
        # which are now stored unsigned.
568
572
        self.notify(
824
828
    def _getChangesDict(self, changes_file_object=None):
825
829
        """Return a dictionary with changes file tags in it."""
826
830
        if changes_file_object is None:
 
831
            if self.changesfile is None:
 
832
                return {}, ''
827
833
            changes_file_object = self.changesfile
828
834
        changes_content = changes_file_object.read()
829
835
 
1293
1299
                  "in MAIN_ARCHIVE_PURPOSES.")
1294
1300
            return
1295
1301
 
 
1302
        # If the distroseries is 11.10 (oneiric) or later, the valid names
 
1303
        # check is not required.  (See bug 788685.)
 
1304
        distroseries = sourcepackagerelease.upload_distroseries
 
1305
        do_names_check = Version(distroseries.version) < Version('11.10')
 
1306
 
1296
1307
        valid_pockets = (
1297
1308
            PackagePublishingPocket.RELEASE, PackagePublishingPocket.SECURITY,
1298
1309
            PackagePublishingPocket.UPDATES, PackagePublishingPocket.PROPOSED)
1299
 
        valid_component_names = ('main', 'restricted')
 
1310
        valid_components = ('main', 'restricted')
1300
1311
        if (self.packageupload.pocket not in valid_pockets or
1301
 
            sourcepackagerelease.component.name not in valid_component_names):
 
1312
            (do_names_check and
 
1313
            sourcepackagerelease.component.name not in valid_components)):
1302
1314
            # XXX: CarlosPerelloMarin 2006-02-16 bug=31665:
1303
1315
            # This should be implemented using a more general rule to accept
1304
1316
            # different policies depending on the distribution.
1430
1442
 
1431
1443
        return conflicts.one()
1432
1444
 
 
1445
    def getBuildsForSources(self, distroseries, status=None, pockets=None,
 
1446
                            names=None):
 
1447
        """See `IPackageUploadSet`."""
 
1448
        # Avoiding circular imports.
 
1449
        from lp.registry.model.distroseries import DistroSeries
 
1450
        from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild
 
1451
        from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
 
1452
 
 
1453
        archives = distroseries.distribution.getArchiveIDList()
 
1454
        clauses = [
 
1455
            DistroSeries.id == PackageUpload.distroseriesID,
 
1456
            PackageUpload.archiveID.is_in(archives),
 
1457
            PackageUploadBuild.packageuploadID == PackageUpload.id,
 
1458
            ]
 
1459
 
 
1460
        if status is not None:
 
1461
            clauses.append(PackageUpload.status.is_in(status))
 
1462
        if pockets is not None:
 
1463
            clauses.append(PackageUpload.pocket.is_in(pockets))
 
1464
        if names is not None:
 
1465
            clauses.extend([
 
1466
                BinaryPackageBuild.id == PackageUploadBuild.buildID,
 
1467
                BinaryPackageBuild.source_package_release ==
 
1468
                    SourcePackageRelease.id,
 
1469
                SourcePackageRelease.sourcepackagename ==
 
1470
                    SourcePackageName.id,
 
1471
                SourcePackageName.name.is_in(names),
 
1472
                ])
 
1473
 
 
1474
        store = IStore(PackageUpload)
 
1475
        return store.find(PackageUpload, *clauses)
 
1476
 
1433
1477
    def count(self, status=None, distroseries=None, pocket=None):
1434
1478
        """See `IPackageUploadSet`."""
1435
1479
        clauses = []