Trees | Indices | Help |
|
---|
|
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 17 import time, urllib 18 from twisted.web import html 19 from twisted.web.util import Redirect 20 from twisted.web.resource import NoResource 21 from twisted.internet import defer 22 23 from buildbot.status.web.base import HtmlResource, abbreviate_age, \ 24 BuildLineMixin, ActionResource, path_to_slave, path_to_authzfail 25 from buildbot import util28 32 33 @defer.inlineCallbacks4635 res = yield self.getAuthz(request).actionAllowed(self.action, 36 request, 37 self.slave) 38 39 url = None 40 if res: 41 self.slave.setGraceful(True) 42 url = path_to_slave(request, self.slave) 43 else: 44 url = path_to_authzfail(request) 45 defer.returnValue(url)49 addSlash = False 5311655 return "Buildbot: %s" % self.slavename5658 s = self.getStatus(req) 59 slave = s.getSlave(self.slavename) 60 if path == "shutdown": 61 return ShutdownActionResource(slave) 62 return Redirect(path_to_slave(req, slave))63 65 s = self.getStatus(request) 66 slave = s.getSlave(self.slavename) 67 68 my_builders = [] 69 for bname in s.getBuilderNames(): 70 b = s.getBuilder(bname) 71 for bs in b.getSlaves(): 72 if bs.getName() == self.slavename: 73 my_builders.append(b) 74 75 # Current builds 76 current_builds = [] 77 for b in my_builders: 78 for cb in b.getCurrentBuilds(): 79 if cb.getSlavename() == self.slavename: 80 current_builds.append(self.get_line_values(request, cb)) 81 82 try: 83 max_builds = int(request.args.get('numbuilds')[0]) 84 except: 85 max_builds = 10 86 87 recent_builds = [] 88 n = 0 89 for rb in s.generateFinishedBuilds(builders=[b.getName() for b in my_builders]): 90 if rb.getSlavename() == self.slavename: 91 n += 1 92 recent_builds.append(self.get_line_values(request, rb)) 93 if n > max_builds: 94 break 95 96 # connects over the last hour 97 slave = s.getSlave(self.slavename) 98 connect_count = slave.getConnectCount() 99 100 ctx.update(dict(slave=slave, 101 slavename = self.slavename, 102 current = current_builds, 103 recent = recent_builds, 104 shutdown_url = request.childLink("shutdown"), 105 authz = self.getAuthz(request), 106 this_url = "../../../" + path_to_slave(request, slave), 107 access_uri = slave.getAccessURI()), 108 admin = unicode(slave.getAdmin() or '', 'utf-8'), 109 host = unicode(slave.getHost() or '', 'utf-8'), 110 slave_version = slave.getVersion(), 111 show_builder_column = True, 112 connect_count = connect_count) 113 template = request.site.buildbot_service.templates.get_template("buildslave.html") 114 data = template.render(**ctx) 115 return data119 pageTitle = "BuildSlaves" 120 addSlash = True 121174123 s = self.getStatus(request) 124 125 #?no_builders=1 disables build column 126 show_builder_column = not (request.args.get('no_builders', '0')[0])=='1' 127 ctx['show_builder_column'] = show_builder_column 128 129 used_by_builder = {} 130 for bname in s.getBuilderNames(): 131 b = s.getBuilder(bname) 132 for bs in b.getSlaves(): 133 slavename = bs.getName() 134 if slavename not in used_by_builder: 135 used_by_builder[slavename] = [] 136 used_by_builder[slavename].append(bname) 137 138 slaves = ctx['slaves'] = [] 139 for name in util.naturalSort(s.getSlaveNames()): 140 info = {} 141 slaves.append(info) 142 slave = s.getSlave(name) 143 slave_status = s.botmaster.slaves[name].slave_status 144 info['running_builds'] = len(slave_status.getRunningBuilds()) 145 info['link'] = request.childLink(urllib.quote(name,'')) 146 info['name'] = name 147 148 if show_builder_column: 149 info['builders'] = [] 150 for b in used_by_builder.get(name, []): 151 info['builders'].append(dict(link=request.childLink("../builders/%s" % b), name=b)) 152 153 info['version'] = slave.getVersion() 154 info['connected'] = slave.isConnected() 155 info['connectCount'] = slave.getConnectCount() 156 157 info['admin'] = unicode(slave.getAdmin() or '', 'utf-8') 158 last = slave.lastMessageReceived() 159 if last: 160 info['last_heard_from_age'] = abbreviate_age(time.time() - last) 161 info['last_heard_from_time'] = time.strftime("%Y-%b-%d %H:%M:%S", 162 time.localtime(last)) 163 164 template = request.site.buildbot_service.templates.get_template("buildslaves.html") 165 data = template.render(**ctx) 166 return data167
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Nov 21 16:22:58 2012 | http://epydoc.sourceforge.net |