Esempio n. 1
0
 def test_non_greedy(self):
     self.assertEqual(
         '{"one": "http://example.com/", '
         '"two": "http://<redacted>@example.com/", '
         '"three": "http://<redacted>@example.org/"}',
         sanitise_urls(
             '{"one": "http://example.com/", '
             '"two": "http://*****:*****@example.com/", '
             '"three": "http://*****:*****@example.org/"}'))
Esempio n. 2
0
 def _runGit(self, *args, **kwargs):
     """Run git with arguments, sending output to the logger."""
     cmd = ["git"] + list(args)
     git_process = subprocess.Popen(cmd,
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.STDOUT,
                                    **kwargs)
     for line in git_process.stdout:
         line = line.decode("UTF-8", "replace").rstrip("\n")
         self._logger.info(sanitise_urls(line))
     retcode = git_process.wait()
     if retcode:
         raise subprocess.CalledProcessError(retcode, cmd)
    def dispatchBuildToSlave(self, logger):
        """See `IBuildFarmJobBehaviour`."""
        cookie = self.build.build_cookie
        logger.info("Preparing job %s (%s) on %s." %
                    (cookie, self.build.title, self._builder.url))

        builder_type, das, pocket, files, args = yield (
            self.composeBuildRequest(logger))

        # First cache the chroot and any other files that the job needs.
        pocket_chroot = None
        for image_type in self.image_types:
            pocket_chroot = das.getPocketChroot(pocket=pocket,
                                                image_type=image_type)
            if pocket_chroot is not None:
                break
        if pocket_chroot is None:
            raise CannotBuild("Unable to find a chroot for %s" %
                              das.displayname)
        chroot = pocket_chroot.chroot
        args["image_type"] = pocket_chroot.image_type.name.lower()

        filename_to_sha1 = {}
        dl = []
        dl.append(
            self._slave.sendFileToSlave(logger=logger,
                                        url=chroot.http_url,
                                        sha1=chroot.content.sha1))
        for filename, params in files.items():
            filename_to_sha1[filename] = params['sha1']
            dl.append(self._slave.sendFileToSlave(logger=logger, **params))
        yield defer.gatherResults(dl)

        combined_args = {
            'builder_type': builder_type,
            'chroot_sha1': chroot.content.sha1,
            'filemap': filename_to_sha1,
            'args': args
        }
        logger.info("Dispatching job %s (%s) to %s:\n%s" %
                    (cookie, self.build.title, self._builder.url,
                     sanitise_urls(repr(combined_args))))

        (status, info) = yield self._slave.build(cookie, builder_type,
                                                 chroot.content.sha1,
                                                 filename_to_sha1, args)

        logger.info(
            "Job %s (%s) started on %s: %s %s" %
            (cookie, self.build.title, self._builder.url, status, info))
Esempio n. 4
0
 def test_removes_credentials(self):
     self.assertEqual(
         'http://<redacted>@example.com/',
         sanitise_urls('http://*****:*****@example.com/'))
Esempio n. 5
0
 def test_already_clean(self):
     self.assertEqual('clean', sanitise_urls('clean'))