1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 from twisted.web.util import redirectTo
17 from twisted.internet import defer
18
19 from buildbot.status.web.base import HtmlResource, path_to_authzfail
20 from buildbot.util.eventual import eventually
21
22 -class RootPage(HtmlResource):
23 pageTitle = "Buildbot"
24
25 @defer.deferredGenerator
26 - def content(self, request, cxt):
27 status = self.getStatus(request)
28
29 d = self.getAuthz(request).actionAllowed("cleanShutdown", request)
30 wfd = defer.waitForDeferred(d)
31 yield wfd
32 res = wfd.getResult()
33
34 if request.path == '/shutdown':
35 if res:
36 eventually(status.cleanShutdown)
37 yield redirectTo("/", request)
38 return
39 else:
40 yield redirectTo(path_to_authzfail(request), request)
41 return
42 elif request.path == '/cancel_shutdown':
43 if res:
44 eventually(status.cancelCleanShutdown)
45 yield redirectTo("/", request)
46 return
47 else:
48 yield redirectTo(path_to_authzfail(request), request)
49 return
50
51 cxt.update(
52 shutting_down = status.shuttingDown,
53 shutdown_url = request.childLink("shutdown"),
54 cancel_shutdown_url = request.childLink("cancel_shutdown"),
55 )
56 template = request.site.buildbot_service.templates.get_template("root.html")
57 yield template.render(**cxt)
58 return
59