| 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 import collections | 5 import collections |
| 6 import os | 6 import os |
| 7 import random | 7 import random |
| 8 import re | 8 import re |
| 9 import sys | 9 import sys |
| 10 | 10 |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 key = builder.name | 697 key = builder.name |
| 698 elif None in prefs: | 698 elif None in prefs: |
| 699 # Second choice: Slaves that don't prefer any builders. | 699 # Second choice: Slaves that don't prefer any builders. |
| 700 key = None | 700 key = None |
| 701 else: | 701 else: |
| 702 # Third choice: Slaves that prefer other builders but have largest | 702 # Third choice: Slaves that prefer other builders but have largest |
| 703 # capacity left. If several groups of slaves with equal capacity exist, | 703 # capacity left. If several groups of slaves with equal capacity exist, |
| 704 # one group will be chosen arbitrarily, the actual slave will be chosen | 704 # one group will be chosen arbitrarily, the actual slave will be chosen |
| 705 # randomly. | 705 # randomly. |
| 706 key = prefs.most_common()[0][0] | 706 key = prefs.most_common()[0][0] |
| 707 return self._choice( | 707 result = self._choice( |
| 708 [s for s in slave_builders | 708 [s for s in slave_builders |
| 709 if s.slave.properties.getProperty('preferred_builder') == key]) | 709 if s.slave.properties.getProperty('preferred_builder') == key]) |
| 710 | 710 |
| 711 log.msg('Assigning slave to %s. Preferred: %s. Chose %s.' % ( |
| 712 builder.name, |
| 713 [s.slave.properties.getProperty('preferred_builder') |
| 714 for s in slave_builders], |
| 715 result)) |
| 716 |
| 717 return result |
| 718 |
| 711 | 719 |
| 712 def SetMasterProcessName(): | 720 def SetMasterProcessName(): |
| 713 """Sets the name of this process to the name of the master. Linux only.""" | 721 """Sets the name of this process to the name of the master. Linux only.""" |
| 714 | 722 |
| 715 if sys.platform != 'linux2': | 723 if sys.platform != 'linux2': |
| 716 return | 724 return |
| 717 | 725 |
| 718 command_line.set_command_line("master: %s" % GetMastername()) | 726 command_line.set_command_line("master: %s" % GetMastername()) |
| OLD | NEW |