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.inlineCallbacks
26 - def content(self, request, cxt):
27 status = self.getStatus(request)
28
29 res = yield self.getAuthz(request).actionAllowed("cleanShutdown",
30 request)
31
32 if request.path == '/shutdown':
33 if res:
34 eventually(status.cleanShutdown)
35 defer.returnValue(redirectTo("/", request))
36 return
37 else:
38 defer.returnValue(
39 redirectTo(path_to_authzfail(request), request))
40 return
41 elif request.path == '/cancel_shutdown':
42 if res:
43 eventually(status.cancelCleanShutdown)
44 defer.returnValue(redirectTo("/", request))
45 return
46 else:
47 defer.returnValue(
48 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 defer.returnValue(template.render(**cxt))
58