~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

Merge db-devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009-2011 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=E0611,W0212
10
10
    ]
11
11
 
12
12
 
 
13
import datetime
 
14
import operator
 
15
import re
 
16
from StringIO import StringIO
 
17
 
13
18
import apt_pkg
14
 
import datetime
15
19
from debian.changelog import (
16
20
    Changelog,
17
21
    ChangelogCreateError,
18
22
    ChangelogParseError,
19
23
    )
20
 
import operator
21
 
import re
22
 
from StringIO import StringIO
23
 
 
24
24
import pytz
25
25
import simplejson
26
26
from sqlobject import (
73
73
from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild
74
74
from lp.soyuz.model.files import SourcePackageReleaseFile
75
75
from lp.soyuz.model.packagediff import PackageDiff
76
 
from lp.soyuz.model.publishing import SourcePackagePublishingHistory
 
76
from lp.soyuz.model.publishing import (
 
77
    BinaryPackagePublishingHistory,
 
78
    SourcePackagePublishingHistory,
 
79
    )
77
80
from lp.soyuz.model.queue import (
78
81
    PackageUpload,
79
82
    PackageUploadSource,
646
649
 
647
650
        output = "\n\n".join(chunks)
648
651
        return output.decode("utf-8", "replace")
 
652
 
 
653
    def getActiveArchSpecificPublications(self, archive, distroseries,
 
654
                                          pocket):
 
655
        """Find architecture-specific binary publications for this release.
 
656
 
 
657
        For example, say source package release contains binary packages of:
 
658
         * "foo" for i386 (pending in i386)
 
659
         * "foo" for amd64 (published in amd64)
 
660
         * "foo-common" for the "all" architecture (pending or published in
 
661
           various real processor architectures)
 
662
 
 
663
        In that case, this search will return foo(i386) and foo(amd64).  The
 
664
        dominator uses this when figuring out whether foo-common can be
 
665
        superseded: we don't track dependency graphs, but we know that the
 
666
        architecture-specific "foo" releases are likely to depend on the
 
667
        architecture-independent foo-common release.
 
668
 
 
669
        :param archive: The `Archive` to search.
 
670
        :param distroseries: The `DistroSeries` to search.
 
671
        :param pocket: The `PackagePublishingPocket` to search.
 
672
        :return: A Storm result set of active, architecture-specific
 
673
            `BinaryPackagePublishingHistory` objects for this source package
 
674
            release and the given `archive`, `distroseries`, and `pocket`.
 
675
        """
 
676
        # Avoid circular imports.
 
677
        from lp.soyuz.interfaces.publishing import active_publishing_status
 
678
        from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
 
679
        from lp.soyuz.model.distroarchseries import DistroArchSeries
 
680
 
 
681
        return Store.of(self).find(
 
682
            BinaryPackagePublishingHistory,
 
683
            BinaryPackageBuild.source_package_release_id == self.id,
 
684
            BinaryPackageRelease.build == BinaryPackageBuild.id,
 
685
            BinaryPackagePublishingHistory.binarypackagereleaseID ==
 
686
                BinaryPackageRelease.id,
 
687
            BinaryPackagePublishingHistory.archiveID == archive.id,
 
688
            BinaryPackagePublishingHistory.distroarchseriesID ==
 
689
                DistroArchSeries.id,
 
690
            DistroArchSeries.distroseriesID == distroseries.id,
 
691
            BinaryPackagePublishingHistory.pocket == pocket,
 
692
            BinaryPackagePublishingHistory.status.is_in(
 
693
                active_publishing_status),
 
694
            BinaryPackageRelease.architecturespecific == True)