Package buildbot :: Package status :: Package web :: Module root
[frames] | no frames]

Source Code for Module buildbot.status.web.root

 1  # This file is part of Buildbot.  Buildbot is free software: you can 
 2  # redistribute it and/or modify it under the terms of the GNU General Public 
 3  # License as published by the Free Software Foundation, version 2. 
 4  # 
 5  # This program is distributed in the hope that it will be useful, but WITHOUT 
 6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 8  # details. 
 9  # 
10  # You should have received a copy of the GNU General Public License along with 
11  # this program; if not, write to the Free Software Foundation, Inc., 51 
12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
13  # 
14  # Copyright Buildbot Team Members 
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