def __repr__(self):
     """Returns an informative representation of the job."""
     # This code assumes the job is referentially intact with good data,
     # or it will blow up.
     parts = "%s for" % self.__class__.__name__
     parts += " distribution: %s" % self.distribution.name
     parts += ", distroseries: %s" % self.distroseries.name
     parts += ", parent[overlay?/pockets/components]: "
     parents = []
     for i in range(len(self.overlays)):
         series = DistroSeries.get(self.parents[i])
         parents.append(
             "%s[%s/%s/%s]" %
             (series.name, self.overlays[i], self.overlay_pockets[i],
              self.overlay_components[i]))
     parts += ",".join(parents)
     if self.packagesets is None:
         pkgsets = None
     else:
         pkgsets = [
             IStore(Packageset).get(Packageset, int(pkgsetid)).name
             for pkgsetid in self.packagesets
         ]
     parts += ", architectures: %s" % (self.arches, )
     parts += ", archindep_archtag: %s" % self.archindep_archtag
     parts += ", packagesets: %s" % pkgsets
     parts += ", rebuild: %s" % self.rebuild
     return "<%s>" % parts
 def __repr__(self):
     """Returns an informative representation of the job."""
     # This code assumes the job is referentially intact with good data,
     # or it will blow up.
     parts = "%s for" % self.__class__.__name__
     parts += " distribution: %s" % self.distribution.name
     parts += ", distroseries: %s" % self.distroseries.name
     parts += ", parent[overlay?/pockets/components]: "
     parents = []
     for i in range(len(self.overlays)):
         series = DistroSeries.get(self.parents[i])
         parents.append("%s[%s/%s/%s]" % (
             series.name,
             self.overlays[i],
             self.overlay_pockets[i],
             self.overlay_components[i]))
     parts += ",".join(parents)
     pkgsets = [
         IStore(Packageset).get(Packageset, int(pkgsetid)).name
         for pkgsetid in  self.packagesets]
     parts += ", architectures: %s" % (self.arches,)
     parts += ", archindep_archtag: %s" % self.archindep_archtag
     parts += ", packagesets: %s" % pkgsets
     parts += ", rebuild: %s" % self.rebuild
     return "<%s>" % parts
Esempio n. 3
0
def _get_locals():
    if len(sys.argv) > 1:
        dbuser = sys.argv[1]
    else:
        dbuser = None
    dbconfig.override(dbuser=dbuser)
    execute_zcml_for_scripts()
    readline.parse_and_bind('tab: complete')
    # Mimic the real interactive interpreter's loading of any
    # $PYTHONSTARTUP file.
    startup = os.environ.get('PYTHONSTARTUP')
    if startup:
        execfile(startup)
    store = IMasterStore(Person)

    if dbuser == 'launchpad':
        # Create a few variables "in case they come in handy."
        # Do we really use these?  Are they worth carrying around?
        d = Distribution.get(1)
        p = Person.get(1)
        ds = DistroSeries.get(1)
        prod = Product.get(1)
        proj = ProjectGroup.get(1)
        b2 = Bug.get(2)
        b1 = Bug.get(1)
        s = Specification.get(1)
        q = Question.get(1)
        # Silence unused name warnings
        d, p, ds, prod, proj, b2, b1, s, q

    # Having a factory instance is handy.
    factory = LaunchpadObjectFactory()

    def browser_open(obj, *args, **kwargs):
        """Open a (possibly newly-created) object's view in a web browser.

        Accepts the same parameters as canonical_url.

        Performs a commit before invoking the browser, so
        "browser_open(factory.makeFoo())" works.
        """
        transaction.commit()
        webbrowser.open(canonical_url(obj, *args, **kwargs))

    # Silence unused name warnings
    factory, store

    res = {}
    res.update(locals())
    res.update(globals())
    del res['_get_locals']
    return res
Esempio n. 4
0
def _get_locals():
    if len(sys.argv) > 1:
        dbuser = sys.argv[1]
    else:
        dbuser = None
    dbconfig.override(dbuser=dbuser)
    execute_zcml_for_scripts()
    readline.parse_and_bind('tab: complete')
    # Mimic the real interactive interpreter's loading of any
    # $PYTHONSTARTUP file.
    startup = os.environ.get('PYTHONSTARTUP')
    if startup:
        execfile(startup)
    store = IMasterStore(Person)

    if dbuser == 'launchpad':
        # Create a few variables "in case they come in handy."
        # Do we really use these?  Are they worth carrying around?
        d = Distribution.get(1)
        p = Person.get(1)
        ds = DistroSeries.get(1)
        prod = Product.get(1)
        proj = ProjectGroup.get(1)
        b2 = Bug.get(2)
        b1 = Bug.get(1)
        s = Specification.get(1)
        q = Question.get(1)
        # Silence unused name warnings
        d, p, ds, prod, proj, b2, b1, s, q

    # Having a factory instance is handy.
    factory = LaunchpadObjectFactory()

    def browser_open(obj, *args, **kwargs):
        """Open a (possibly newly-created) object's view in a web browser.

        Accepts the same parameters as canonical_url.

        Performs a commit before invoking the browser, so
        "browser_open(factory.makeFoo())" works.
        """
        transaction.commit()
        webbrowser.open(canonical_url(obj, *args, **kwargs))

    # Silence unused name warnings
    factory, store

    res = {}
    res.update(locals())
    res.update(globals())
    del res['_get_locals']
    return res
Esempio n. 5
0
    def __iter__(self):
        """`ArchiveSourcePublication` iterator."""
        results = []
        if not self.has_sources:
            return iter(results)

        # Load the extra-information for all source publications.
        # All of this code would be better on an object representing a set of
        # publications.
        changesfiles_by_source = self.getChangesFileBySource()
        # Source package names are used by setNewerDistroSeriesVersions:
        # batch load the used source package names.
        spn_ids = set()
        for spph in self._source_publications:
            spn_ids.add(spph.sourcepackagerelease.sourcepackagenameID)
        list(
            IStore(SourcePackageName).find(
                SourcePackageName, SourcePackageName.id.is_in(spn_ids)))
        DistroSeries.setNewerDistroSeriesVersions(self._source_publications)
        # Load all the build status summaries at once.
        publishing_set = getUtility(IPublishingSet)
        archive_pub_ids = defaultdict(list)
        for pub in self._source_publications:
            archive_pub_ids[pub.archive].append(pub.id)
        status_summaries = {}
        for archive, pub_ids in archive_pub_ids.items():
            status_summaries.update(
                publishing_set.getBuildStatusSummariesForSourceIdsAndArchive(
                    pub_ids, archive))

        # Build the decorated object with the information we have.
        for pub in self._source_publications:
            changesfile = changesfiles_by_source.get(pub, None)
            status_summary = status_summaries[pub.id]
            complete_pub = ArchiveSourcePublication(
                pub, changesfile=changesfile, status_summary=status_summary)
            results.append(complete_pub)

        return iter(results)
    def __iter__(self):
        """`ArchiveSourcePublication` iterator."""
        results = []
        if not self.has_sources:
            return iter(results)

        # Load the extra-information for all source publications.
        # All of this code would be better on an object representing a set of
        # publications.
        changesfiles_by_source = self.getChangesFileBySource()
        # Source package names are used by setNewerDistroSeriesVersions:
        # batch load the used source package names.
        spn_ids = set()
        for spph in self._source_publications:
            spn_ids.add(spph.sourcepackagerelease.sourcepackagenameID)
        list(IStore(SourcePackageName).find(SourcePackageName,
            SourcePackageName.id.is_in(spn_ids)))
        DistroSeries.setNewerDistroSeriesVersions(self._source_publications)
        # Load all the build status summaries at once.
        publishing_set = getUtility(IPublishingSet)
        archive_pub_ids = defaultdict(list)
        for pub in self._source_publications:
            archive_pub_ids[pub.archive].append(pub.id)
        status_summaries = {}
        for archive, pub_ids in archive_pub_ids.items():
            status_summaries.update(
                publishing_set.getBuildStatusSummariesForSourceIdsAndArchive(
                    pub_ids, archive))

        # Build the decorated object with the information we have.
        for pub in self._source_publications:
            changesfile = changesfiles_by_source.get(pub, None)
            status_summary = status_summaries[pub.id]
            complete_pub = ArchiveSourcePublication(
                pub, changesfile=changesfile, status_summary=status_summary)
            results.append(complete_pub)

        return iter(results)
Esempio n. 7
0
 def _get_distroseries(self, name):
     """Return the distroseries database object by name."""
     dr = DistroSeries.selectOneBy(name=name, distributionID=self.distro.id)
     if not dr:
         raise DataSetupError("Error finding distroseries %r" % name)
     return dr
Esempio n. 8
0
 def _get_distroseries(self, name):
     """Return the distroseries database object by name."""
     dr = DistroSeries.selectOneBy(name=name, distributionID=self.distro.id)
     if not dr:
         raise DataSetupError("Error finding distroseries %r" % name)
     return dr