| OLD | NEW |
| (Empty) |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 | |
| 6 """Utilities for working with slaves.cfg files.""" | |
| 7 | |
| 8 | |
| 9 import os | |
| 10 | |
| 11 | |
| 12 def _slaves_cfg_path(master_name): | |
| 13 def _make_path(master_name, build_dir): | |
| 14 return os.path.abspath(os.path.join( | |
| 15 os.path.abspath(os.path.dirname(__file__)), os.pardir, os.pardir, | |
| 16 os.pardir, os.pardir, build_dir, 'masters', | |
| 17 'master.' + master_name, 'slaves.cfg')) | |
| 18 path = _make_path(master_name, 'build') | |
| 19 if os.path.isfile(path): | |
| 20 return path | |
| 21 path = _make_path(master_name, 'build_internal') | |
| 22 if os.path.isfile(path): | |
| 23 return path | |
| 24 return None | |
| 25 | |
| 26 | |
| 27 def get(master_name): | |
| 28 """Return a dictionary of the buildslaves for the given master. | |
| 29 | |
| 30 Keys are slavenames and values are the unmodified slave dicts from the | |
| 31 slaves.cfg file for the given master. | |
| 32 """ | |
| 33 variables = {} | |
| 34 execfile(_slaves_cfg_path(master_name), variables) | |
| 35 slaves_cfg = {} | |
| 36 for slave_dict in variables['slaves']: | |
| 37 slaves_cfg[slave_dict['hostname']] = slave_dict | |
| 38 return slaves_cfg | |
| 39 | |
| OLD | NEW |