OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Dumps a list of known slaves, along with their OS and master.""" | 6 """Dumps a list of known slaves, along with their OS and master.""" |
7 | 7 |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 path = os.path.join(os.path.dirname(__file__), os.path.pardir) | 10 path = os.path.join(os.path.dirname(__file__), os.path.pardir) |
11 sys.path.append(path) | 11 sys.path.append(path) |
12 from common import chromium_utils | 12 from common import chromium_utils |
13 | 13 |
14 | 14 |
15 def main(): | 15 def main(): |
16 slaves = [] | 16 # remove slaves with blank or no hostname |
17 for master in chromium_utils.ListMasters(cue='slaves.cfg'): | 17 slaves = filter(lambda x: x.get('hostname'), chromium_utils.GetAllSlaves()) |
18 masterbase = os.path.basename(master) | 18 slaves.sort(key=lambda x: (x.get('mastername'), x['hostname'])) |
19 master_slaves = {} | 19 for slave in slaves: |
20 execfile(os.path.join(master, 'slaves.cfg'), master_slaves) | 20 builder = slave.get('builder') or '?' |
21 for slave in master_slaves.get('slaves', []): | 21 if type(builder) is not list: |
22 slave['master'] = masterbase | 22 builder = [builder] |
23 slaves.extend(master_slaves.get('slaves', [])) | 23 for b in sorted(builder): |
24 for slave in sorted(slaves, cmp=None, key=lambda x : x.get('hostname', '')): | 24 print '%-30s %-35s %-35s %-10s' % ( |
25 slavename = slave.get('hostname') | 25 slave['hostname'], |
26 if not slavename: | 26 slave.get('mastername', '?'), |
27 continue | 27 b, |
28 master = slave.get('master', '?') | 28 slave.get('os', '?')) |
29 builder = slave.get('builder', '?') | |
30 if builder == []: | |
31 builder = '?' | |
32 osname = slave.get('os', '?') | |
33 if type(builder) is list: | |
34 for b in sorted(builder): | |
35 print '%-30s %-35s %-35s %-10s' % (slavename, master, b, osname) | |
36 else: | |
37 print '%-30s %-35s %-35s %-10s' % (slavename, master, builder, osname) | |
38 | 29 |
39 | 30 |
40 if __name__ == '__main__': | 31 if __name__ == '__main__': |
41 main() | 32 main() |
OLD | NEW |