OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """ Set of basic operations/utilities that are used by the build. """ | 5 """ Set of basic operations/utilities that are used by the build. """ |
6 | 6 |
7 import copy | 7 import copy |
8 import errno | 8 import errno |
9 import fnmatch | 9 import fnmatch |
10 import glob | 10 import glob |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 if testing_slavename: | 1011 if testing_slavename: |
1012 return testing_slavename | 1012 return testing_slavename |
1013 return socket.getfqdn().split('.', 1)[0].lower() | 1013 return socket.getfqdn().split('.', 1)[0].lower() |
1014 | 1014 |
1015 | 1015 |
1016 def EntryToSlaveName(entry): | 1016 def EntryToSlaveName(entry): |
1017 """Produces slave name from the slaves config dict.""" | 1017 """Produces slave name from the slaves config dict.""" |
1018 return entry.get('slavename') or entry.get('hostname') | 1018 return entry.get('slavename') or entry.get('hostname') |
1019 | 1019 |
1020 | 1020 |
1021 def GetActiveMaster(slavename=None): | 1021 def GetActiveMaster(slavename=None, default=None): |
1022 """Parses all the slaves.cfg and returns the name of the active master | 1022 """Parses all the slaves.cfg and returns the name of the active master |
1023 determined by the hostname. Returns None otherwise. | 1023 determined by the hostname. Returns None otherwise. |
1024 | 1024 |
1025 It will be matched against *both* the 'slavename' and 'hostname' fields | 1025 It will be matched against *both* the 'slavename' and 'hostname' fields |
1026 in slaves.cfg. | 1026 in slaves.cfg. |
1027 """ | 1027 """ |
1028 slavename = slavename or GetActiveSlavename() | 1028 slavename = slavename or GetActiveSlavename() |
1029 for slave in GetAllSlaves(): | 1029 for slave in GetAllSlaves(): |
1030 if slavename == EntryToSlaveName(slave): | 1030 if slavename == EntryToSlaveName(slave): |
1031 return slave['master'] | 1031 return slave['master'] |
| 1032 return default |
1032 | 1033 |
1033 | 1034 |
1034 def ParsePythonCfg(cfg_filepath): | 1035 def ParsePythonCfg(cfg_filepath): |
1035 """Retrieves data from a python config file.""" | 1036 """Retrieves data from a python config file.""" |
1036 if not os.path.exists(cfg_filepath): | 1037 if not os.path.exists(cfg_filepath): |
1037 return None | 1038 return None |
1038 base_path = os.path.dirname(os.path.abspath(cfg_filepath)) | 1039 base_path = os.path.dirname(os.path.abspath(cfg_filepath)) |
1039 old_sys_path = sys.path | 1040 old_sys_path = sys.path |
1040 sys.path = sys.path + [base_path] | 1041 sys.path = sys.path + [base_path] |
1041 old_cwd = os.getcwd() | 1042 old_cwd = os.getcwd() |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 'This is almost certainly incorrect.' % (build_dir, platform_key)) | 1204 'This is almost certainly incorrect.' % (build_dir, platform_key)) |
1204 if use_out: | 1205 if use_out: |
1205 legacy_path = 'out' | 1206 legacy_path = 'out' |
1206 else: | 1207 else: |
1207 legacy_path = legacy_paths[platform_key] | 1208 legacy_path = legacy_paths[platform_key] |
1208 build_dir = os.path.join(os.path.dirname(build_dir), legacy_path) | 1209 build_dir = os.path.join(os.path.dirname(build_dir), legacy_path) |
1209 print >> sys.stderr, ('Assuming you meant "%s"' % build_dir) | 1210 print >> sys.stderr, ('Assuming you meant "%s"' % build_dir) |
1210 bad = True | 1211 bad = True |
1211 | 1212 |
1212 return (build_dir, bad) | 1213 return (build_dir, bad) |
OLD | NEW |