Beispiel #1
0
    def content(self, request, cxt):
        status = self.getStatus(request)

        d = self.getAuthz(request).actionAllowed("cleanShutdown", request)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()

        if request.path == '/shutdown':
            if res:
                eventually(status.cleanShutdown)
                yield redirectTo("/", request)
                return
            else:
                yield redirectTo(path_to_authfail(request), request)
                return
        elif request.path == '/cancel_shutdown':
            if res:
                eventually(status.cancelCleanShutdown)
                yield redirectTo("/", request)
                return
            else:
                yield redirectTo(path_to_authfail(request), request)
                return

        cxt.update(
                shutting_down = status.shuttingDown,
                shutdown_url = request.childLink("shutdown"),
                cancel_shutdown_url = request.childLink("cancel_shutdown"),
                )
        template = request.site.buildbot_service.templates.get_template("root.html")
        yield template.render(**cxt)
        return
Beispiel #2
0
    def content(self, request, cxt):
        status = self.getStatus(request)

        d = self.getAuthz(request).actionAllowed("cleanShutdown", request)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()

        if request.path == '/shutdown':
            if res:
                eventually(status.cleanShutdown)
                yield redirectTo("/", request)
                return
            else:
                yield redirectTo(path_to_authfail(request), request)
                return
        elif request.path == '/cancel_shutdown':
            if res:
                eventually(status.cancelCleanShutdown)
                yield redirectTo("/", request)
                return
            else:
                yield redirectTo(path_to_authfail(request), request)
                return

        cxt.update(
            shutting_down=status.shuttingDown,
            shutdown_url=request.childLink("shutdown"),
            cancel_shutdown_url=request.childLink("cancel_shutdown"),
        )
        template = request.site.buildbot_service.templates.get_template(
            "root.html")
        yield template.render(**cxt)
        return
Beispiel #3
0
    def force(self, req, auth_ok=False):
        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]
        repository = req.args.get("repository", [""])[0]
        project = req.args.get("project", [""])[0]

        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s',"
                " repository='%s', project='%s' by user '%s'" %
                (self.builder_status.getName(), branch, revision, repository,
                 project, name))

        # check if this is allowed
        if not auth_ok:
            if not self.getAuthz(req).actionAllowed('forceBuild', req,
                                                    self.builder_status):
                log.msg("..but not authorized")
                return Redirect(path_to_authfail(req))
        # ensure that they've filled out the username field at least.
        if name == "<unknown>":
            log.msg("..but didn't include a username to blame")
            return Redirect(path_to_authfail(req))

        # keep weird stuff out of the branch revision, and property strings.
        # TODO: centralize this somewhere.
        if not re.match(r'^[\w.+/~-]*$', branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect(path_to_builder(req, self.builder_status))
        if not re.match(r'^[ \w\.\-\/]*$', revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect(path_to_builder(req, self.builder_status))
        properties = getAndCheckProperties(req)
        if properties is None:
            return Redirect(path_to_builder(req, self.builder_status))
        if not branch:
            branch = None
        if not revision:
            revision = None

        master = self.getBuildmaster(req)
        d = master.db.sourcestamps.addSourceStamp(branch=branch,
                                                  revision=revision,
                                                  project=project,
                                                  repository=repository)

        def make_buildset(ssid):
            r = (
                "The web-page 'force build' button was pressed by '%s': %s\n" %
                (html.escape(name), html.escape(reason)))
            return master.addBuildset(
                builderNames=[self.builder_status.getName()],
                ssid=ssid,
                reason=r,
                properties=properties.asDict())

        d.addCallback(make_buildset)
        d.addErrback(log.err, "(ignored) while trying to force build")
        # send the user back to the builder page
        return Redirect(path_to_builder(req, self.builder_status))
Beispiel #4
0
    def force(self, req, auth_ok=False):
        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]
        repository = req.args.get("repository", [""])[0]
        project = req.args.get("project", [""])[0]

        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s',"
                " repository='%s', project='%s' by user '%s'" % (
                self.builder_status.getName(), branch, revision, repository,
                project, name))

        # check if this is allowed
        if not auth_ok:
            if not self.getAuthz(req).actionAllowed('forceBuild', req, self.builder_status):
                log.msg("..but not authorized")
                return Redirect(path_to_authfail(req))
        # ensure that they've filled out the username field at least.
        if name == "<unknown>":
            log.msg("..but didn't include a username to blame")
            return Redirect(path_to_authfail(req))

        master = self.getBuildmaster(req)

        # keep weird stuff out of the branch revision, and property strings.
        branch_validate = master.config.validation['branch']
        revision_validate = master.config.validation['revision']
        if not branch_validate.match(branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect(path_to_builder(req, self.builder_status))
        if not revision_validate.match(revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect(path_to_builder(req, self.builder_status))
        properties = getAndCheckProperties(req)
        if properties is None:
            return Redirect(path_to_builder(req, self.builder_status))
        if not branch:
            branch = None
        if not revision:
            revision = None

        d = master.db.sourcestamps.addSourceStamp(branch=branch,
                revision=revision, project=project, repository=repository)
        def make_buildset(ssid):
            r = ("The web-page 'force build' button was pressed by '%s': %s\n"
                 % (html.escape(name), html.escape(reason)))
            return master.addBuildset(
                    builderNames=[self.builder_status.getName()],
                    ssid=ssid, reason=r, properties=properties.asDict())
        d.addCallback(make_buildset)
        d.addErrback(log.err, "(ignored) while trying to force build")
        # send the user back to the builder page
        return Redirect(path_to_builder(req, self.builder_status))
Beispiel #5
0
    def content(self, request, cxt):
        status = self.getStatus(request)

        if request.path == '/shutdown':
            return redirectTo(path_to_authfail(request), request)
        elif request.path == '/cancel_shutdown':
            return redirectTo(path_to_authfail(request), request)

        cxt.update(
                shutting_down = status.shuttingDown,
                shutdown_url = request.childLink("shutdown"),
                cancel_shutdown_url = request.childLink("cancel_shutdown"),
                )
        template = request.site.buildbot_service.templates.get_template("root.html")
        return template.render(**cxt)
Beispiel #6
0
 def getChild(self, path, req):
   if path == "build":
     if not self.getAuthz(req).actionAllowed('forceBuild',
                                             req):
       return Redirect(path_to_authfail(req))
     return self.build(req)
   return HtmlResource.getChild(self, path, req)
Beispiel #7
0
 def getChild(self, path, req):
   if path == "build":
     if not self.getAuthz(req).actionAllowed('forceBuild',
                                             req):
       return Redirect(path_to_authfail(req))
     return self.build(req)
   return HtmlResource.getChild(self, path, req)
Beispiel #8
0
    def performAction(self, req):
        authz = self.getAuthz(req)
        d = authz.actionAllowed('stopAllBuilds', req)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()
        if not res:
            yield path_to_authfail(req)
            return

        builders = None
        if self.selectedOrAll == 'all':
            builders = self.status.getBuilderNames()
        elif self.selectedOrAll == 'selected':
            builders = [b for b in req.args.get("selected", []) if b]

        for bname in builders:
            builder_status = self.status.getBuilder(bname)
            (state, current_builds) = builder_status.getState()
            if state != "building":
                continue
            for b in current_builds:
                build_status = builder_status.getBuild(b.number)
                if not build_status:
                    continue
                build = StatusResourceBuild(build_status)
                build.stop(req, auth_ok=True)
        # go back to the welcome page
        yield path_to_root(req)
Beispiel #9
0
    def performAction(self, req):
        authz = self.getAuthz(req)
        d = authz.actionAllowed('forceAllBuilds', req)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()

        if not res:
            yield path_to_authfail(req)
            return

        builders = None
        if self.selectedOrAll == 'all':
            builders = self.status.getBuilderNames()
        elif self.selectedOrAll == 'selected':
            builders = [b for b in req.args.get("selected", []) if b]

        for bname in builders:
            builder_status = self.status.getBuilder(bname)
            build = StatusResourceBuilder(builder_status)
            build.force(req,
                        auth_ok=True)  # auth_ok because we already checked

        # back to the welcome page
        yield path_to_root(req)
Beispiel #10
0
    def stop(self, req, auth_ok=False):
        # check if this is allowed
        if not auth_ok:
            if not self.getAuthz(req).actionAllowed('stopBuild', req,
                                                    self.build_status):
                return Redirect(path_to_authfail(req))

        b = self.build_status
        log.msg("web stopBuild of build %s:%s" % \
                (b.getBuilder().getName(), b.getNumber()))
        name = req.args.get("username", ["<unknown>"])[0]
        comments = req.args.get("comments", ["<no reason specified>"])[0]
        # html-quote both the username and comments, just to be safe
        reason = ("The web-page 'stop build' button was pressed by "
                  "'%s': %s\n" % (html.escape(name), html.escape(comments)))

        c = interfaces.IControl(self.getBuildmaster(req))
        bldrc = c.getBuilder(self.build_status.getBuilder().getName())
        if bldrc:
            bldc = bldrc.getBuild(self.build_status.getNumber())
            if bldc:
                bldc.stopBuild(reason)

        # we're at http://localhost:8080/svn-hello/builds/5/stop?[args] and
        # we want to go to: http://localhost:8080/svn-hello
        r = Redirect(path_to_builder(req, self.build_status.getBuilder()))
        d = defer.Deferred()
        reactor.callLater(1, d.callback, r)
        return DeferredResource(d)
Beispiel #11
0
    def stop(self, req, auth_ok=False):
        # check if this is allowed
        if not auth_ok:
            if not self.getAuthz(req).actionAllowed('stopBuild', req, self.build_status):
                return Redirect(path_to_authfail(req))

        b = self.build_status
        log.msg("web stopBuild of build %s:%s" % \
                (b.getBuilder().getName(), b.getNumber()))
        name = req.args.get("username", ["<unknown>"])[0]
        comments = req.args.get("comments", ["<no reason specified>"])[0]
        # html-quote both the username and comments, just to be safe
        reason = ("The web-page 'stop build' button was pressed by "
                  "'%s': %s\n" % (html.escape(name), html.escape(comments)))

        c = interfaces.IControl(self.getBuildmaster(req))
        bldrc = c.getBuilder(self.build_status.getBuilder().getName())
        if bldrc:
            bldc = bldrc.getBuild(self.build_status.getNumber())
            if bldc:
                bldc.stopBuild(reason)

        # we're at http://localhost:8080/svn-hello/builds/5/stop?[args] and
        # we want to go to: http://localhost:8080/svn-hello
        r = Redirect(path_to_builder(req, self.build_status.getBuilder()))
        d = defer.Deferred()
        reactor.callLater(1, d.callback, r)
        return DeferredResource(d)
    def performAction(self, req):
        try:
            request_id = req.args.get("id", [None])[0]
            if request_id == "all":
                cancel_all = True
            else:
                cancel_all = False
                request_id = int(request_id)
        except:
            request_id = None

        authz = self.getAuthz(req)
        if request_id:
            c = interfaces.IControl(self.getBuildmaster(req))
            builder_control = c.getBuilder(self.builder_status.getName())

            wfd = defer.waitForDeferred(
                    builder_control.getPendingBuildRequestControls())
            yield wfd
            brcontrols = wfd.getResult()

            for build_req in brcontrols:
                if cancel_all or (build_req.brid == request_id):
                    log.msg("Cancelling %s" % build_req)
                    if authz.actionAllowed('cancelPendingBuild',
                                           req, build_req):
                        build_req.cancel()
                    else:
                        yield path_to_authfail(req)
                        return
                    if not cancel_all:
                        break

        yield path_to_builder(req, self.builder_status)
Beispiel #13
0
    def stopchange(self, req, auth_ok=False):
        """Cancel all pending builds that include a given numbered change."""
        try:
            request_change = req.args.get("change", [None])[0]
            request_change = int(request_change)
        except:
            request_change = None

        authz = self.getAuthz(req)
        if request_change:
            # FIXME: Please, for the love of god one day make there only be
            # one getPendingBuilds() with combined status info/controls
            c = interfaces.IControl(self.getBuildmaster(req))
            builder_control = c.getBuilder(self.builder_status.getName())
            build_controls = dict((x.brid, x) for x in builder_control.getPendingBuilds())
            for build_req in self.builder_status.getPendingBuilds():
                ss = build_req.getSourceStamp()
                if not ss.changes:
                    continue
                for change in ss.changes:
                    if change.number == request_change:
                        control = build_controls[build_req.brid]
                        log.msg("Cancelling %s" % control)
                        if auth_ok or authz.actionAllowed('stopChange', req, control):
                            control.cancel()
                        else:
                            return Redirect(path_to_authfail(req))
        return Redirect(path_to_builder(req, self.builder_status))
Beispiel #14
0
    def performAction(self, req):
        authz = self.getAuthz(req)
        d = authz.actionAllowed('stopAllBuilds', req)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()
        if not res:
            yield path_to_authfail(req)
            return

        builders = None
        if self.selectedOrAll == 'all':
            builders = self.status.getBuilderNames()
        elif self.selectedOrAll == 'selected':
            builders = [b for b in req.args.get("selected", []) if b]

        for bname in builders:
            builder_status = self.status.getBuilder(bname)
            (state, current_builds) = builder_status.getState()
            if state != "building":
                continue
            for b in current_builds:
                build_status = builder_status.getBuild(b.number)
                if not build_status:
                    continue
                build = StatusResourceBuild(build_status)
                build.stop(req, auth_ok=True)
        # go back to the welcome page
        yield path_to_root(req)
Beispiel #15
0
    def cancelbuild(self, req):
        try:
            request_id = req.args.get("id", [None])[0]
            if request_id == "all":
                cancel_all = True
            else:
                cancel_all = False
                request_id = int(request_id)
        except:
            request_id = None

        authz = self.getAuthz(req)
        if request_id:
            c = interfaces.IControl(self.getBuildmaster(req))
            bc = c.getBuilder(self.builder_status.getName())
            for build_req in bc.getPendingBuilds():
                if cancel_all or (build_req.brid == request_id):
                    log.msg("Cancelling %s" % build_req)
                    if authz.actionAllowed('cancelPendingBuild', req,
                                           build_req):
                        build_req.cancel()
                    else:
                        return Redirect(path_to_authfail(req))
                    if not cancel_all:
                        break
        return Redirect(path_to_builder(req, self.builder_status))
Beispiel #16
0
    def performAction(self, req):
        authz = self.getAuthz(req)
        d = authz.actionAllowed(self.action, req, self.build_status)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()

        if not res:
            yield path_to_authfail(req)
            return

        b = self.build_status
        log.msg("web stopBuild of build %s:%s" % \
                    (b.getBuilder().getName(), b.getNumber()))
        name = authz.getUsername(req)
        comments = req.args.get("comments", ["<no reason specified>"])[0]
        # html-quote both the username and comments, just to be safe
        reason = ("The web-page 'stop build' button was pressed by "
                  "'%s': %s\n" % (html.escape(name), html.escape(comments)))

        c = interfaces.IControl(self.getBuildmaster(req))
        bldrc = c.getBuilder(self.build_status.getBuilder().getName())
        if bldrc:
            bldc = bldrc.getBuild(self.build_status.getNumber())
            if bldc:
                bldc.stopBuild(reason)

        yield path_to_builder(req, self.build_status.getBuilder())
        return
Beispiel #17
0
    def stopchange(self, req, auth_ok=False):
        """Cancel all pending builds that include a given numbered change."""
        try:
            request_change = req.args.get("change", [None])[0]
            request_change = int(request_change)
        except:
            request_change = None

        authz = self.getAuthz(req)
        if request_change:
            # FIXME: Please, for the love of god one day make there only be
            # one getPendingBuilds() with combined status info/controls
            c = interfaces.IControl(self.getBuildmaster(req))
            builder_control = c.getBuilder(self.builder_status.getName())
            build_controls = dict(
                (x.brid, x) for x in builder_control.getPendingBuilds())
            for build_req in self.builder_status.getPendingBuilds():
                ss = build_req.getSourceStamp()
                if not ss.changes:
                    continue
                for change in ss.changes:
                    if change.number == request_change:
                        control = build_controls[build_req.brid]
                        log.msg("Cancelling %s" % control)
                        if auth_ok or authz.actionAllowed(
                                'stopChange', req, control):
                            control.cancel()
                        else:
                            return Redirect(path_to_authfail(req))
        return Redirect(path_to_builder(req, self.builder_status))
Beispiel #18
0
    def cancelbuild(self, req):
        try:
            request_id = req.args.get("id", [None])[0]
            if request_id == "all":
                cancel_all = True
            else:
                cancel_all = False
                request_id = int(request_id)
        except:
            request_id = None

        authz = self.getAuthz(req)
        if request_id:
            c = interfaces.IControl(self.getBuildmaster(req))
            bc = c.getBuilder(self.builder_status.getName())
            for build_req in bc.getPendingBuilds():
                if cancel_all or id(build_req.original_request.status) == request_id:
                    log.msg("Cancelling %s" % build_req)
                    if authz.actionAllowed("cancelPendingBuild", req, build_req):
                        build_req.cancel()
                    else:
                        return Redirect(path_to_authfail(req))
                    if not cancel_all:
                        break
        return Redirect(path_to_builder(req, self.builder_status))
Beispiel #19
0
    def performAction(self, req):
        d = self.getAuthz(req).actionAllowed(self.action, req,
                                             self.build_status)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()

        if not res:
            yield path_to_authfail(req)
            return

        b = self.build_status
        log.msg("web stopBuild of build %s:%s" % \
                    (b.getBuilder().getName(), b.getNumber()))
        name = req.args.get("username", ["<unknown>"])[0]
        comments = req.args.get("comments", ["<no reason specified>"])[0]
        # html-quote both the username and comments, just to be safe
        reason = ("The web-page 'stop build' button was pressed by "
                  "'%s': %s\n" % (html.escape(name), html.escape(comments)))

        c = interfaces.IControl(self.getBuildmaster(req))
        bldrc = c.getBuilder(self.build_status.getBuilder().getName())
        if bldrc:
            bldc = bldrc.getBuild(self.build_status.getNumber())
            if bldc:
                bldc.stopBuild(reason)

        yield path_to_builder(req, self.build_status.getBuilder())
        return
Beispiel #20
0
    def force(self, req, auth_ok=False):
        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]
        repository = req.args.get("repository", [""])[0]
        project = req.args.get("project", [""])[0]

        r = "The web-page 'force build' button was pressed by '%s': %s\n" \
            % (html.escape(name), html.escape(reason))
        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s',"
                " repository='%s', project='%s' by user '%s'" %
                (self.builder_status.getName(), branch, revision, repository,
                 project, name))

        # check if this is allowed
        if not auth_ok:
            if not self.getAuthz(req).actionAllowed('forceBuild', req,
                                                    self.builder_status):
                log.msg("..but not authorized")
                return Redirect(path_to_authfail(req))

        # keep weird stuff out of the branch revision, and property strings.
        # TODO: centralize this somewhere.
        if not re.match(r'^[\w.+/~-]*$', branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect(path_to_builder(req, self.builder_status))
        if not re.match(r'^[ \w\.\-\/]*$', revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect(path_to_builder(req, self.builder_status))
        properties = getAndCheckProperties(req)
        if properties is None:
            return Redirect(path_to_builder(req, self.builder_status))
        if not branch:
            branch = None
        if not revision:
            revision = None

        # TODO: if we can authenticate that a particular User pushed the
        # button, use their name instead of None, so they'll be informed of
        # the results.
        # TODO2: we can authenticate that a particular User pushed the button
        # now, so someone can write this support. but it requires a
        # buildbot.changes.changes.Change instance which is tedious at this
        # stage to compute
        s = SourceStamp(branch=branch,
                        revision=revision,
                        project=project,
                        repository=repository)
        try:
            c = interfaces.IControl(self.getBuildmaster(req))
            bc = c.getBuilder(self.builder_status.getName())
            bc.submitBuildRequest(s, r, properties)
        except interfaces.NoSlaveError:
            # TODO: tell the web user that their request could not be
            # honored
            pass
        # send the user back to the builder page
        return Redirect(path_to_builder(req, self.builder_status))
Beispiel #21
0
    def performAction(self, req):
        # check if this is allowed
        d = self.getAuthz(req).actionAllowed(self.action, req,
                                             self.builder_status)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()
        if not res:
            log.msg("..but not authorized")
            yield path_to_authfail(req)
            return

        master = self.getBuildmaster(req)

        # keep weird stuff out of the branch revision, and property strings.
        branch_validate = master.config.validation['branch']
        revision_validate = master.config.validation['revision']
        if not branch_validate.match(self.req_args['branch']):
            log.msg("bad branch '%s'" % self.req_args['branch'])
            yield path_to_builder(req, self.builder_status)
            return
        if not revision_validate.match(self.req_args['revision']):
            log.msg("bad revision '%s'" % self.req_args['revision'])
            yield path_to_builder(req, self.builder_status)
            return
        properties = getAndCheckProperties(req)
        if properties is None:
            yield path_to_builder(req, self.builder_status)
            return
        if not self.req_args['branch']:
            self.req_args['branch'] = None
        if not self.req_args['revision']:
            self.req_args['revision'] = None

        d = master.db.sourcestamps.addSourceStamp(
            branch=self.req_args['branch'],
            revision=self.req_args['revision'],
            project=self.req_args['project'],
            repository=self.req_args['repository'])
        wfd = defer.waitForDeferred(d)
        yield wfd
        ssid = wfd.getResult()

        r = ("The web-page 'force build' button was pressed by '%s': %s\n" %
             (html.escape(
                 self.req_args['name']), html.escape(self.req_args['reason'])))
        d = master.addBuildset(builderNames=[self.builder_status.getName()],
                               ssid=ssid,
                               reason=r,
                               properties=properties.asDict())
        wfd = defer.waitForDeferred(d)
        yield wfd
        tup = wfd.getResult()
        # check that (bsid, brids) were properly stored
        if not isinstance(tup, (int, dict)):
            log.err("(ignored) while trying to force build")

        # send the user back to the builder page
        yield path_to_builder(req, self.builder_status)
Beispiel #22
0
 def on_login(res):
     if res:
         status = request.site.buildbot_service.master.status
         root = status.getBuildbotURL()
         return request.requestHeaders.getRawHeaders('referer',
                                                     [root])[0]
     else:
         return path_to_authfail(request)
Beispiel #23
0
 def on_login(res):
     if res:
         status = request.site.buildbot_service.master.status
         root = status.getBuildbotURL()
         return request.requestHeaders.getRawHeaders('referer',
                                                     [root])[0]
     else:
         return path_to_authfail(request)
    def performAction(self, req):
        """Cancel all pending builds that include a given numbered change."""
        authz = self.getAuthz(req)
        if not authz.actionAllowed('stopChange', req):
            yield path_to_authfail(req)
            return

        for bname in self.status.getBuilderNames():
            builder_status = self.status.getBuilder(bname)
            wfd = defer.waitForDeferred(
                self.stopChangeForBuilder(req, builder_status, auth_ok=True))
            yield wfd
            if not wfd.getResult():
                yield path_to_authfail(req)
                return

        yield path_to_root(req)
Beispiel #25
0
    def performAction(self, req):
        # check if this is allowed
        d = self.getAuthz(req).actionAllowed(self.action, req,
                                             self.builder_status)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()
        if not res:
            log.msg("..but not authorized")
            yield path_to_authfail(req)
            return

        master = self.getBuildmaster(req)

        # keep weird stuff out of the branch revision, and property strings.
        branch_validate = master.config.validation['branch']
        revision_validate = master.config.validation['revision']
        if not branch_validate.match(self.req_args['branch']):
            log.msg("bad branch '%s'" % self.req_args['branch'])
            yield path_to_builder(req, self.builder_status)
            return
        if not revision_validate.match(self.req_args['revision']):
            log.msg("bad revision '%s'" % self.req_args['revision'])
            yield path_to_builder(req, self.builder_status)
            return
        properties = getAndCheckProperties(req)
        if properties is None:
            yield path_to_builder(req, self.builder_status)
            return
        if not self.req_args['branch']:
            self.req_args['branch'] = None
        if not self.req_args['revision']:
            self.req_args['revision'] = None

        d = master.db.sourcestamps.addSourceStamp(
                                      branch=self.req_args['branch'],
                                      revision=self.req_args['revision'],
                                      project=self.req_args['project'],
                                      repository=self.req_args['repository'])
        wfd = defer.waitForDeferred(d)
        yield wfd
        ssid = wfd.getResult()

        r = ("The web-page 'force build' button was pressed by '%s': %s\n"
             % (html.escape(self.req_args['name']),
                html.escape(self.req_args['reason'])))
        d = master.addBuildset(builderNames=[self.builder_status.getName()],
                               ssid=ssid, reason=r,
                               properties=properties.asDict())
        wfd = defer.waitForDeferred(d)
        yield wfd
        tup = wfd.getResult()
        # check that (bsid, brids) were properly stored
        if not isinstance(tup, (int, dict)):
            log.err("(ignored) while trying to force build")

        # send the user back to the builder page
        yield path_to_builder(req, self.builder_status)
Beispiel #26
0
 def getChild(self, path, req):
     s = self.getStatus(req)
     slave = s.getSlave(self.slavename)
     if path == "shutdown":
         if self.getAuthz(req).actionAllowed("gracefulShutdown", req, slave):
             slave.setGraceful(True)
         else:
             return Redirect(path_to_authfail(req))
     return Redirect(path_to_slave(req, slave))
Beispiel #27
0
 def getChild(self, path, req):
     s = self.getStatus(req)
     slave = s.getSlave(self.slavename)
     if path == "shutdown":
         if self.getAuthz(req).actionAllowed("gracefulShutdown", req, slave):
             slave.setGraceful(True)
         else:
             return Redirect(path_to_authfail(req))
     return Redirect(path_to_slave(req, slave))
Beispiel #28
0
 def performAction(self, req):
     d = self.getAuthz(req).actionAllowed('showUsersPage', req)
     wfd = defer.waitForDeferred(d)
     yield wfd
     res = wfd.getResult()
     if not res:
         yield path_to_authfail(req)
         return
     # show the table
     yield path_to_root(req) + "users/table"
 def ping(self, req):
     log.msg("web ping of builder '%s'" % self.builder_status.getName())
     if not self.getAuthz(req).actionAllowed('pingBuilder', req, self.builder_status):
         log.msg("..but not authorized")
         return Redirect(path_to_authfail(req))
     c = interfaces.IControl(self.getBuildmaster(req))
     bc = c.getBuilder(self.builder_status.getName())
     bc.ping()
     # send the user back to the builder page
     return Redirect(path_to_builder(req, self.builder_status))
Beispiel #30
0
 def performAction(self, req):
     d = self.getAuthz(req).actionAllowed('showUsersPage', req)
     wfd = defer.waitForDeferred(d)
     yield wfd
     res = wfd.getResult()
     if not res:
         yield path_to_authfail(req)
         return
     # show the table
     yield path_to_root(req) + "users/table"
Beispiel #31
0
 def ping(self, req):
     log.msg("web ping of builder '%s'" % self.builder_status.getName())
     if not self.getAuthz(req).actionAllowed("pingBuilder", req, self.builder_status):
         log.msg("..but not authorized")
         return Redirect(path_to_authfail(req))
     c = interfaces.IControl(self.getBuildmaster(req))
     bc = c.getBuilder(self.builder_status.getName())
     bc.ping()
     # send the user back to the builder page
     return Redirect(path_to_builder(req, self.builder_status))
Beispiel #32
0
    def force(self, req, auth_ok=False):
        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]
        repository = req.args.get("repository", [""])[0]
        project = req.args.get("project", [""])[0]

        r = "The web-page 'force build' button was pressed by '%s': %s\n" \
            % (html.escape(name), html.escape(reason))
        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s',"
                " repository='%s', project='%s' by user '%s'" % (
                self.builder_status.getName(), branch, revision, repository,
                project, name))

        # check if this is allowed
        if not auth_ok:
            if not self.getAuthz(req).actionAllowed('forceBuild', req, self.builder_status):
                log.msg("..but not authorized")
                return Redirect(path_to_authfail(req))

        # keep weird stuff out of the branch revision, and property strings.
        # TODO: centralize this somewhere.
        if not re.match(r'^[\w.+/~-]*$', branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect(path_to_builder(req, self.builder_status))
        if not re.match(r'^[ \w\.\-\/]*$', revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect(path_to_builder(req, self.builder_status))
        properties = getAndCheckProperties(req)
        if properties is None:
            return Redirect(path_to_builder(req, self.builder_status))
        if not branch:
            branch = None
        if not revision:
            revision = None

        # TODO: if we can authenticate that a particular User pushed the
        # button, use their name instead of None, so they'll be informed of
        # the results.
        # TODO2: we can authenticate that a particular User pushed the button
        # now, so someone can write this support. but it requires a
        # buildbot.changes.changes.Change instance which is tedious at this
        # stage to compute
        s = SourceStamp(branch=branch, revision=revision, project=project, repository=repository)
        try:
            c = interfaces.IControl(self.getBuildmaster(req))
            bc = c.getBuilder(self.builder_status.getName())
            bc.submitBuildRequest(s, r, properties)
        except interfaces.NoSlaveError:
            # TODO: tell the web user that their request could not be
            # honored
            pass
        # send the user back to the builder page
        return Redirect(path_to_builder(req, self.builder_status))
Beispiel #33
0
    def forceall(self, req):
        authz = self.getAuthz(req)
        if not authz.actionAllowed("forceAllBuilds", req):
            return Redirect(path_to_authfail(req))

        for bname in self.status.getBuilderNames():
            builder_status = self.status.getBuilder(bname)
            build = StatusResourceBuilder(builder_status)
            build.force(req, auth_ok=True)  # auth_ok because we already checked
        # back to the welcome page
        return Redirect(path_to_root(req))
Beispiel #34
0
    def stopchangeall(self, req):
        authz = self.getAuthz(req)
        if not authz.actionAllowed('stopChange', req):
            return Redirect(path_to_authfail(req))

        for bname in self.status.getBuilderNames():
            builder_status = self.status.getBuilder(bname)
            build = StatusResourceBuilder(builder_status)
            build.stopchange(req, auth_ok=True)

        return Redirect(path_to_root(req))
Beispiel #35
0
    def stopchangeall(self, req):
        authz = self.getAuthz(req)
        if not authz.actionAllowed('stopChange', req):
            return Redirect(path_to_authfail(req))

        for bname in self.status.getBuilderNames():
            builder_status = self.status.getBuilder(bname)
            build = StatusResourceBuilder(builder_status)
            build.stopchange(req, auth_ok=True)

        return Redirect(path_to_root(req))
Beispiel #36
0
    def performAction(self, req):
        """Cancel all pending builds that include a given numbered change."""
        wfd = defer.waitForDeferred(
            self.stopChangeForBuilder(req, self.builder_status))
        yield wfd
        success = wfd.getResult()

        if not success:
            yield path_to_authfail(req)
        else:
            yield path_to_builder(req, self.builder_status)
    def performAction(self, req):
        """Cancel all pending builds that include a given numbered change."""
        wfd = defer.waitForDeferred(
            self.stopChangeForBuilder(req, self.builder_status))
        yield wfd
        success = wfd.getResult()

        if not success:
            yield path_to_authfail(req)
        else:
            yield path_to_builder(req, self.builder_status)
    def forceselected(self, req):
        authz = self.getAuthz(req)
        if not authz.actionAllowed('forceAllBuilds', req):
            return Redirect(path_to_authfail(req))

        for bname in [b for b in req.args.get("selected", []) if b]:
            builder_status = self.status.getBuilder(bname)
            build = StatusResourceBuilder(builder_status)
            build.force(req, auth_ok=True) # auth_ok because we already checked
        # back to the welcome page
        return Redirect(path_to_root(req))
Beispiel #39
0
    def performAction(self, request):
        d = self.getAuthz(request).actionAllowed(self.action, request,
                                                 self.slave)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()

        url = None
        if res:
            self.slave.setGraceful(True)
            url = path_to_slave(request, self.slave)
        else:
            url = path_to_authfail(request)
        yield url
Beispiel #40
0
    def content(self, request, cxt):
        status = self.getStatus(request)

        if request.path == '/shutdown':
            if self.getAuthz(request).actionAllowed("cleanShutdown", request):
                eventually(status.cleanShutdown)
                return redirectTo("/", request)
            else:
                return redirectTo(path_to_authfail(request), request)
        elif request.path == '/cancel_shutdown':
            if self.getAuthz(request).actionAllowed("cleanShutdown", request):
                eventually(status.cancelCleanShutdown)
                return redirectTo("/", request)
            else:
                return redirectTo(path_to_authfail(request), request)

        cxt.update(
                shutting_down = status.shuttingDown,
                shutdown_url = request.childLink("shutdown"),
                cancel_shutdown_url = request.childLink("cancel_shutdown"),
                )
        template = request.site.buildbot_service.templates.get_template("root.html")
        return template.render(**cxt)
Beispiel #41
0
    def performAction(self, req):
        url = None
        authz = self.getAuthz(req)
        d = authz.actionAllowed(self.action, req, self.builder)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()

        if not res:
            url = path_to_authfail(req)
        else:
            # get a control object
            c = interfaces.IControl(self.getBuildmaster(req))
            bc = c.getBuilder(self.builder.getName())

            b = self.build_status
            builder_name = self.builder.getName()
            log.msg("web rebuild of build %s:%s" %
                    (builder_name, b.getNumber()))
            name = authz.getUsername(req)
            comments = req.args.get("comments", ["<no reason specified>"])[0]
            reason = ("The web-page 'rebuild' button was pressed by "
                      "'%s': %s\n" % (name, comments))
            extraProperties = getAndCheckProperties(req)
            if not bc or not b.isFinished() or extraProperties is None:
                log.msg("could not rebuild: bc=%s, isFinished=%s" %
                        (bc, b.isFinished()))
                # TODO: indicate an error
            else:
                d = bc.rebuildBuild(b, reason, extraProperties)
                wfd = defer.waitForDeferred(d)
                yield wfd
                tup = wfd.getResult()
                # check that (bsid, brids) were properly stored
                if not isinstance(tup, (int, dict)):
                    log.err("while rebuilding a build")
            # we're at
            # http://localhost:8080/builders/NAME/builds/5/rebuild?[args]
            # Where should we send them?
            #
            # Ideally it would be to the per-build page that they just started,
            # but we don't know the build number for it yet (besides, it might
            # have to wait for a current build to finish). The next-most
            # preferred place is somewhere that the user can see tangible
            # evidence of their build starting (or to see the reason that it
            # didn't start). This should be the Builder page.

            url = path_to_builder(req, self.builder)
        yield url
Beispiel #42
0
    def content(self, request, cxt):
        status = self.getStatus(request)

        if request.path == '/shutdown':
            if self.getAuthz(request).actionAllowed("cleanShutdown", request):
                eventually(status.cleanShutdown)
                return redirectTo("/", request)
            else:
                return redirectTo(path_to_authfail(request), request)
        elif request.path == '/cancel_shutdown':
            if self.getAuthz(request).actionAllowed("cleanShutdown", request):
                eventually(status.cancelCleanShutdown)
                return redirectTo("/", request)
            else:
                return redirectTo(path_to_authfail(request), request)

        cxt.update(
            shutting_down=status.shuttingDown,
            shutdown_url=request.childLink("shutdown"),
            cancel_shutdown_url=request.childLink("cancel_shutdown"),
        )
        template = request.site.buildbot_service.templates.get_template(
            "root.html")
        return template.render(**cxt)
Beispiel #43
0
    def content(self, req, ctx):
        # check for False or True on showUsersPage, redirect immediately
        authz = self.getAuthz(req)
        if not authz.needAuthForm(self.action):
            if authz.advertiseAction(self.action):
                yield redirectTo("users/table", req)
                return
            else:
                yield redirectTo(path_to_authfail(req), req)
                return

        ctx['authz'] = self.getAuthz(req)
        ctx['table_link'] = req.childLink("table")
        template = req.site.buildbot_service.templates.get_template("users.html")
        yield template.render(**ctx)
Beispiel #44
0
    def performAction(self, request):
        d = self.getAuthz(request).actionAllowed(self.action,
                                                 request,
                                                 self.slave)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()

        url = None
        if res:
            self.slave.setGraceful(True)
            url = path_to_slave(request, self.slave)
        else:
            url = path_to_authfail(request)
        yield url
Beispiel #45
0
    def force(self, req, auth_ok=False):
        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]
        repository = req.args.get("repository", [""])[0]
        project = req.args.get("project", [""])[0]

        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s',"
                " repository='%s', project='%s' by user '%s'" % (
                self.builder_status.getName(), branch, revision, repository,
                project, name))

        # check if this is allowed
        if not auth_ok:
            if not self.getAuthz(req).actionAllowed('forceBuild', req, self.builder_status):
                log.msg("..but not authorized")
                return Redirect(path_to_authfail(req))

        # keep weird stuff out of the branch revision, and property strings.
        # TODO: centralize this somewhere.
        if not re.match(r'^[\w.+/~-]*$', branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect(path_to_builder(req, self.builder_status))
        if not re.match(r'^[ \w\.\-\/]*$', revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect(path_to_builder(req, self.builder_status))
        properties = getAndCheckProperties(req)
        if properties is None:
            return Redirect(path_to_builder(req, self.builder_status))
        if not branch:
            branch = None
        if not revision:
            revision = None

        master = self.getBuildmaster(req)
        d = master.db.sourcestamps.createSourceStamp(branch=branch,
                revision=revision, project=project, repository=repository)
        def make_buildset(ssid):
            r = ("The web-page 'force build' button was pressed by '%s': %s\n"
                 % (html.escape(name), html.escape(reason)))
            return master.addBuildset(
                    builderNames=[self.builder_status.getName()],
                    ssid=ssid, reason=r, properties=None)
        d.addCallback(make_buildset)
        d.addErrback(log.err, "(ignored) while trying to force build")
        # send the user back to the builder page
        return Redirect(path_to_builder(req, self.builder_status))
Beispiel #46
0
    def performAction(self, req):
        log.msg("web ping of builder '%s'" % self.builder_status.getName())
        d = self.getAuthz(req).actionAllowed('pingBuilder', req, self.builder_status)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()
        if not res:
            log.msg("..but not authorized")
            yield path_to_authfail(req)
            return

        c = interfaces.IControl(self.getBuildmaster(req))
        bc = c.getBuilder(self.builder_status.getName())
        bc.ping()
        # send the user back to the builder page
        yield path_to_builder(req, self.builder_status)
Beispiel #47
0
    def content(self, req, ctx):
        # check for False or True on showUsersPage, redirect immediately
        authz = self.getAuthz(req)
        if not authz.needAuthForm(self.action):
            if authz.advertiseAction(self.action):
                yield redirectTo("users/table", req)
                return
            else:
                yield redirectTo(path_to_authfail(req), req)
                return

        ctx['authz'] = self.getAuthz(req)
        ctx['table_link'] = req.childLink("table")
        template = req.site.buildbot_service.templates.get_template(
            "users.html")
        yield template.render(**ctx)
Beispiel #48
0
    def performAction(self, req):
        url = None
        d = self.getAuthz(req).actionAllowed(self.action, req, self.builder)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()

        if not res:
            url = path_to_authfail(req)
        else:
            # get a control object
            c = interfaces.IControl(self.getBuildmaster(req))
            bc = c.getBuilder(self.builder.getName())

            b = self.build_status
            builder_name = self.builder.getName()
            log.msg("web rebuild of build %s:%s" % (builder_name, b.getNumber()))
            name = req.args.get("username", ["<unknown>"])[0]
            comments = req.args.get("comments", ["<no reason specified>"])[0]
            reason = ("The web-page 'rebuild' button was pressed by "
                      "'%s': %s\n" % (name, comments))
            extraProperties = getAndCheckProperties(req)
            if not bc or not b.isFinished() or extraProperties is None:
                log.msg("could not rebuild: bc=%s, isFinished=%s"
                        % (bc, b.isFinished()))
                # TODO: indicate an error
            else:
                d = bc.rebuildBuild(b, reason, extraProperties)
                wfd = defer.waitForDeferred(d)
                yield wfd
                tup = wfd.getResult()
                # check that (bsid, brids) were properly stored
                if not isinstance(tup, (int, dict)):
                    log.err("while rebuilding a build")
            # we're at
            # http://localhost:8080/builders/NAME/builds/5/rebuild?[args]
            # Where should we send them?
            #
            # Ideally it would be to the per-build page that they just started,
            # but we don't know the build number for it yet (besides, it might
            # have to wait for a current build to finish). The next-most
            # preferred place is somewhere that the user can see tangible
            # evidence of their build starting (or to see the reason that it
            # didn't start). This should be the Builder page.

            url = path_to_builder(req, self.builder)
        yield url
Beispiel #49
0
    def performAction(self, req):
        log.msg("web ping of builder '%s'" % self.builder_status.getName())
        d = self.getAuthz(req).actionAllowed('pingBuilder', req,
                                             self.builder_status)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()
        if not res:
            log.msg("..but not authorized")
            yield path_to_authfail(req)
            return

        c = interfaces.IControl(self.getBuildmaster(req))
        bc = c.getBuilder(self.builder_status.getName())
        bc.ping()
        # send the user back to the builder page
        yield path_to_builder(req, self.builder_status)
Beispiel #50
0
    def stopall(self, req):
        authz = self.getAuthz(req)
        if not authz.actionAllowed('stopAllBuilds', req):
            return Redirect(path_to_authfail(req))

        for bname in self.status.getBuilderNames():
            builder_status = self.status.getBuilder(bname)
            (state, current_builds) = builder_status.getState()
            if state != "building":
                continue
            for b in current_builds:
                build_status = builder_status.getBuild(b.number)
                if not build_status:
                    continue
                build = StatusResourceBuild(build_status)
                build.stop(req, auth_ok=True)
        # go back to the welcome page
        return Redirect(path_to_root(req))
Beispiel #51
0
    def stopall(self, req):
        authz = self.getAuthz(req)
        if not authz.actionAllowed("stopAllBuilds", req):
            return Redirect(path_to_authfail(req))

        for bname in self.status.getBuilderNames():
            builder_status = self.status.getBuilder(bname)
            (state, current_builds) = builder_status.getState()
            if state != "building":
                continue
            for b in current_builds:
                build_status = builder_status.getBuild(b.number)
                if not build_status:
                    continue
                build = StatusResourceBuild(build_status)
                build.stop(req, auth_ok=True)
        # go back to the welcome page
        return Redirect(path_to_root(req))
Beispiel #52
0
    def rebuild(self, req):
        # check auth
        if not self.getAuthz(req).actionAllowed(
                'forceBuild', req, self.build_status.getBuilder()):
            return Redirect(path_to_authfail(req))

        # get a control object
        c = interfaces.IControl(self.getBuildmaster(req))
        bc = c.getBuilder(self.build_status.getBuilder().getName())

        b = self.build_status
        builder_name = b.getBuilder().getName()
        log.msg("web rebuild of build %s:%s" % (builder_name, b.getNumber()))
        name = req.args.get("username", ["<unknown>"])[0]
        comments = req.args.get("comments", ["<no reason specified>"])[0]
        reason = ("The web-page 'rebuild' button was pressed by "
                  "'%s': %s\n" % (name, comments))
        extraProperties = getAndCheckProperties(req)
        if not bc or not b.isFinished() or extraProperties is None:
            log.msg("could not rebuild: bc=%s, isFinished=%s" %
                    (bc, b.isFinished()))
            # TODO: indicate an error
        else:
            d = bc.rebuildBuild(b, reason, extraProperties)
            d.addErrback(log.err, "while rebuilding a build")
        # we're at
        # http://localhost:8080/builders/NAME/builds/5/rebuild?[args]
        # Where should we send them?
        #
        # Ideally it would be to the per-build page that they just started,
        # but we don't know the build number for it yet (besides, it might
        # have to wait for a current build to finish). The next-most
        # preferred place is somewhere that the user can see tangible
        # evidence of their build starting (or to see the reason that it
        # didn't start). This should be the Builder page.

        r = Redirect(path_to_builder(req, self.build_status.getBuilder()))
        d = defer.Deferred()
        reactor.callLater(1, d.callback, r)
        return DeferredResource(d)
Beispiel #53
0
    def content(self, req, ctx):
        d = self.getAuthz(req).actionAllowed('showUsersPage', req)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()
        if not res:
            yield redirectTo(path_to_authfail(req), req)
            return

        s = self.getStatus(req)

        d = s.master.db.users.getUsers()
        wfd = defer.waitForDeferred(d)
        yield wfd
        usdicts = wfd.getResult()

        users = ctx['users'] = usdicts
        for user in users:
            user['user_link'] = req.childLink(urllib.quote(str(user['uid']), ''))
        template = req.site.buildbot_service.templates.get_template(
                                                              "users_table.html")
        yield template.render(**ctx)
Beispiel #54
0
    def rebuild(self, req):
        # check auth
        if not self.getAuthz(req).actionAllowed('forceBuild', req, self.build_status.getBuilder()):
            return Redirect(path_to_authfail(req))

        # get a control object
        c = interfaces.IControl(self.getBuildmaster(req))
        bc = c.getBuilder(self.build_status.getBuilder().getName())

        b = self.build_status
        builder_name = b.getBuilder().getName()
        log.msg("web rebuild of build %s:%s" % (builder_name, b.getNumber()))
        name = req.args.get("username", ["<unknown>"])[0]
        comments = req.args.get("comments", ["<no reason specified>"])[0]
        reason = ("The web-page 'rebuild' button was pressed by "
                  "'%s': %s\n" % (name, comments))
        extraProperties = getAndCheckProperties(req)
        if not bc or not b.isFinished() or extraProperties is None:
            log.msg("could not rebuild: bc=%s, isFinished=%s"
                    % (bc, b.isFinished()))
            # TODO: indicate an error
        else:
            d = bc.rebuildBuild(b, reason, extraProperties)
            d.addErrback(log.err, "while rebuilding a build")
        # we're at
        # http://localhost:8080/builders/NAME/builds/5/rebuild?[args]
        # Where should we send them?
        #
        # Ideally it would be to the per-build page that they just started,
        # but we don't know the build number for it yet (besides, it might
        # have to wait for a current build to finish). The next-most
        # preferred place is somewhere that the user can see tangible
        # evidence of their build starting (or to see the reason that it
        # didn't start). This should be the Builder page.

        r = Redirect(path_to_builder(req, self.build_status.getBuilder()))
        d = defer.Deferred()
        reactor.callLater(1, d.callback, r)
        return DeferredResource(d)
Beispiel #55
0
    def content(self, req, ctx):
        d = self.getAuthz(req).actionAllowed('showUsersPage', req)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()
        if not res:
            yield redirectTo(path_to_authfail(req), req)
            return

        s = self.getStatus(req)

        d = s.master.db.users.getUsers()
        wfd = defer.waitForDeferred(d)
        yield wfd
        usdicts = wfd.getResult()

        users = ctx['users'] = usdicts
        for user in users:
            user['user_link'] = req.childLink(
                urllib.quote(str(user['uid']), ''))
        template = req.site.buildbot_service.templates.get_template(
            "users_table.html")
        yield template.render(**ctx)