def _cachePrivateSourceOnSlave(self, logger):
        """Ask the slave to download source files for a private build.

        :param logger: A logger used for providing debug information.
        :return: A list of Deferreds, each of which represents a request
            to cache a file.
        """
        # The URL to the file in the archive consists of these parts:
        # archive_url / makePoolPath() / filename
        # Once this is constructed we add the http basic auth info.

        # Avoid circular imports.
        from lp.soyuz.model.publishing import makePoolPath

        archive = self.build.archive
        archive_url = archive.archive_url
        component_name = self.build.current_component.name
        dl = []
        for source_file in self.build.source_package_release.files:
            file_name = source_file.libraryfile.filename
            sha1 = source_file.libraryfile.content.sha1
            spn = self.build.source_package_release.sourcepackagename
            poolpath = makePoolPath(spn.name, component_name)
            url = urlappend(archive_url, poolpath)
            url = urlappend(url, file_name)
            logger.debug("Asking builder on %s to ensure it has file %s "
                         "(%s, %s)" % (
                            self._builder.url, file_name, url, sha1))
            dl.append(
                self._slave.sendFileToSlave(
                    sha1, url, "buildd", archive.buildd_secret))
        return dl
    def redirect_ticket(self):
        """Use RedirectionNavigation to redirect to +question.

        It will take care of the remaining steps and query URL.
        """
        target = urlappend(canonical_url(self.context, rootsite="answers"), "+question")
        return self.redirectSubTree(target)
Example #3
0
    def link_self(self):
        """See `IFeed`."""

        # The self link is the URL for this particular feed.  For example:
        # http://feeds.launchpad.net/ubuntu/announcments.atom
        path = "%s.%s" % (self.feedname, self.format)
        return urlappend(canonical_url(self.context, rootsite="feeds"),
                         path)
Example #4
0
    def __init__(self, proxy, builder_url, vm_host, timeout, reactor):
        """Initialize a BuilderSlave.

        :param proxy: An XML-RPC proxy, implementing 'callRemote'. It must
            support passing and returning None objects.
        :param builder_url: The URL of the builder.
        :param vm_host: The VM host to use when resuming.
        """
        self.url = builder_url
        self._vm_host = vm_host
        self._file_cache_url = urlappend(builder_url, 'filecache')
        self._server = proxy
        self.timeout = timeout
        self.reactor = reactor
Example #5
0
    def url(self):
        """See `IBugWatch`."""
        bugtracker = self.bugtracker
        bugtrackertype = self.bugtracker.bugtrackertype

        if bugtrackertype == BugTrackerType.EMAILADDRESS:
            return bugtracker.baseurl
        elif bugtrackertype in BUG_TRACKER_URL_FORMATS:
            url_format = BUG_TRACKER_URL_FORMATS[bugtrackertype]
            return urlappend(bugtracker.baseurl,
                             url_format % self.remotebug)
        else:
            raise AssertionError(
                'Unknown bug tracker type %s' % bugtrackertype)
    def _getPackageReleaseURLFromPublishingRecord(self, publishing_record):
        """Return the URL on this mirror from where the BinaryPackageRelease.

        Given a BinaryPackagePublishingHistory, return the URL on
        this mirror from where the BinaryPackageRelease file can be
        downloaded.
        """
        bpr = publishing_record.binarypackagerelease
        base_url = self.distribution_mirror.base_url
        path = poolify(bpr.sourcepackagename, self.component.name)
        file = BinaryPackageFile.selectOneBy(
            binarypackagerelease=bpr, filetype=BinaryPackageFileType.DEB)
        full_path = 'pool/%s/%s' % (path, file.libraryfile.filename)
        return urlappend(base_url, full_path)
Example #7
0
    def _getPackageReleaseURLFromPublishingRecord(self, publishing_record):
        """Return the URL on this mirror from where the BinaryPackageRelease.

        Given a BinaryPackagePublishingHistory, return the URL on
        this mirror from where the BinaryPackageRelease file can be
        downloaded.
        """
        bpr = publishing_record.binarypackagerelease
        base_url = self.distribution_mirror.base_url
        path = poolify(bpr.sourcepackagename, self.component.name)
        file = BinaryPackageFile.selectOneBy(
            binarypackagerelease=bpr, filetype=BinaryPackageFileType.DEB)
        full_path = 'pool/%s/%s' % (path, file.libraryfile.filename)
        return urlappend(base_url, full_path)
Example #8
0
    def __init__(self, proxy, builder_url, vm_host, timeout, reactor):
        """Initialize a BuilderSlave.

        :param proxy: An XML-RPC proxy, implementing 'callRemote'. It must
            support passing and returning None objects.
        :param builder_url: The URL of the builder.
        :param vm_host: The VM host to use when resuming.
        """
        self.url = builder_url
        self._vm_host = vm_host
        self._file_cache_url = urlappend(builder_url, 'filecache')
        self._server = proxy
        self.timeout = timeout
        self.reactor = reactor
Example #9
0
    def getFile(self, sha_sum, file_to_write):
        """Fetch a file from the builder.

        :param sha_sum: The sha of the file (which is also its name on the
            builder)
        :param file_to_write: A file name or file-like object to write
            the file to
        :return: A Deferred that calls back when the download is done, or
            errback with the error string.
        """
        file_url = urlappend(self._file_cache_url, sha_sum).encode('utf8')
        # If desired we can pass a param "timeout" here but let's leave
        # it at the default value if it becomes obvious we need to
        # change it.
        return downloadPage(file_url, file_to_write, followRedirect=0)
Example #10
0
    def getFile(self, sha_sum, file_to_write):
        """Fetch a file from the builder.

        :param sha_sum: The sha of the file (which is also its name on the
            builder)
        :param file_to_write: A file name or file-like object to write
            the file to
        :return: A Deferred that calls back when the download is done, or
            errback with the error string.
        """
        file_url = urlappend(self._file_cache_url, sha_sum).encode('utf8')
        # If desired we can pass a param "timeout" here but let's leave
        # it at the default value if it becomes obvious we need to
        # change it.
        return downloadPage(file_url, file_to_write, followRedirect=0)
Example #11
0
    def makeBuilderSlave(cls, builder_url, vm_host, timeout, reactor=None,
                         proxy=None):
        """Create and return a `BuilderSlave`.

        :param builder_url: The URL of the slave buildd machine,
            e.g. http://localhost:8221
        :param vm_host: If the slave is virtual, specify its host machine
            here.
        :param reactor: Used by tests to override the Twisted reactor.
        :param proxy: Used By tests to override the xmlrpc.Proxy.
        """
        rpc_url = urlappend(builder_url.encode('utf-8'), 'rpc')
        if proxy is None:
            server_proxy = xmlrpc.Proxy(
                rpc_url, allowNone=True, connectTimeout=timeout)
            server_proxy.queryFactory = QuietQueryFactory
        else:
            server_proxy = proxy
        return cls(server_proxy, builder_url, vm_host, timeout, reactor)
Example #12
0
    def makeBuilderSlave(cls,
                         builder_url,
                         vm_host,
                         timeout,
                         reactor=None,
                         proxy=None):
        """Create and return a `BuilderSlave`.

        :param builder_url: The URL of the slave buildd machine,
            e.g. http://localhost:8221
        :param vm_host: If the slave is virtual, specify its host machine
            here.
        :param reactor: Used by tests to override the Twisted reactor.
        :param proxy: Used By tests to override the xmlrpc.Proxy.
        """
        rpc_url = urlappend(builder_url.encode('utf-8'), 'rpc')
        if proxy is None:
            server_proxy = xmlrpc.Proxy(rpc_url,
                                        allowNone=True,
                                        connectTimeout=timeout)
            server_proxy.queryFactory = QuietQueryFactory
        else:
            server_proxy = proxy
        return cls(server_proxy, builder_url, vm_host, timeout, reactor)
Example #13
0
 def getURL(self, sha1):
     """Get the URL for a file on the builder with a given SHA-1."""
     return urlappend(self._file_cache_url, sha1).encode('utf8')
Example #14
0
 def getURL(self, sha1):
     return urlappend(
         'http://localhost:8221/filecache/', sha1).encode('utf8')
Example #15
0
 def _getPage(self, page):
     """GET the specified page on the remote HTTP server."""
     page_url = urlappend(self.sourceforge_baseurl, page)
     with override_timeout(config.updatesourceforgeremoteproduct.timeout):
         return urlfetch(page_url, use_proxy=True).content
 def link_alternate(self):
     """See `IFeed`."""
     # Return the human-readable alternate URL for this feed.  For example:
     # https://launchpad.net/ubuntu/+announcements
     return urlappend(canonical_url(self.context, rootsite="mainsite"),
                      "+announcements")
 def _getPage(self, page):
     """GET the specified page on the remote HTTP server."""
     page_url = urlappend(self.sourceforge_baseurl, page)
     return urlopen(page_url).read()
 def _getPage(self, page):
     """GET the specified page on the remote HTTP server."""
     page_url = urlappend(self.sourceforge_baseurl, page)
     return urlopen(page_url).read()
 def link_alternate(self):
     """See `IFeed`."""
     # Return the human-readable alternate URL for this feed.  For example:
     # https://launchpad.net/ubuntu/+announcements
     return urlappend(canonical_url(self.context, rootsite="mainsite"),
                      "+announcements")