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.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