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 """ Initialize the environment variables and start the buildbot slave. | 6 """ Initialize the environment variables and start the buildbot slave. |
7 """ | 7 """ |
8 | 8 |
9 import os | 9 import os |
10 import shutil | 10 import shutil |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 # Delete old slave directories. | 190 # Delete old slave directories. |
191 if d not in wanted_dirs: | 191 if d not in wanted_dirs: |
192 Log('Deleting unwanted directory %s' % d) | 192 Log('Deleting unwanted directory %s' % d) |
193 if not is_testing: | 193 if not is_testing: |
194 chromium_utils.RemoveDirectory(os.path.join(self.basedir, d)) | 194 chromium_utils.RemoveDirectory(os.path.join(self.basedir, d)) |
195 return retval | 195 return retval |
196 Bot.new_remote_setBuilderList = cleanup | 196 Bot.new_remote_setBuilderList = cleanup |
197 Bot.remote_setBuilderList = Bot.new_remote_setBuilderList | 197 Bot.remote_setBuilderList = Bot.new_remote_setBuilderList |
198 | 198 |
199 | 199 |
200 def FixSubversionConfig(): | |
201 if sys.platform == 'win32': | |
202 dest = os.path.join(os.environ['APPDATA'], 'Subversion', 'config') | |
203 else: | |
204 dest = os.path.join(os.environ['HOME'], '.subversion', 'config') | |
205 shutil.copyfile('config', dest) | |
206 | |
207 | |
208 def GetActiveMaster(slave_bootstrap, config_bootstrap, active_slavename): | 200 def GetActiveMaster(slave_bootstrap, config_bootstrap, active_slavename): |
209 master_name = os.environ.get( | 201 master_name = os.environ.get( |
210 'TESTING_MASTER', chromium_utils.GetActiveMaster(active_slavename)) | 202 'TESTING_MASTER', chromium_utils.GetActiveMaster(active_slavename)) |
211 if not master_name: | 203 if not master_name: |
212 raise RuntimeError('*** Failed to detect the active master') | 204 raise RuntimeError('*** Failed to detect the active master') |
213 slave_bootstrap.ImportMasterConfigs(master_name) | 205 slave_bootstrap.ImportMasterConfigs(master_name) |
214 if hasattr(config_bootstrap.Master, 'active_master'): | 206 if hasattr(config_bootstrap.Master, 'active_master'): |
215 # pylint: disable=E1101 | 207 # pylint: disable=E1101 |
216 return config_bootstrap.Master.active_master | 208 return config_bootstrap.Master.active_master |
217 if master_name and getattr(config_bootstrap.Master, master_name): | 209 if master_name and getattr(config_bootstrap.Master, master_name): |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 except (OSError, subprocess.CalledProcessError) as e: | 467 except (OSError, subprocess.CalledProcessError) as e: |
476 Log('WARNING: Could not get git version information: %r' % e) | 468 Log('WARNING: Could not get git version information: %r' % e) |
477 git_version = '?' | 469 git_version = '?' |
478 os.environ.setdefault('GIT_USER_AGENT', '%s git/%s %s' % ( | 470 os.environ.setdefault('GIT_USER_AGENT', '%s git/%s %s' % ( |
479 sys.platform, git_version.rstrip().split()[-1], socket.getfqdn())) | 471 sys.platform, git_version.rstrip().split()[-1], socket.getfqdn())) |
480 # This may be redundant, unless this is imported and main is called. | 472 # This may be redundant, unless this is imported and main is called. |
481 UseBotoPath() | 473 UseBotoPath() |
482 | 474 |
483 # This envrionment is defined only when testing the slave on a dev machine. | 475 # This envrionment is defined only when testing the slave on a dev machine. |
484 is_testing = 'TESTING_MASTER' in os.environ | 476 is_testing = 'TESTING_MASTER' in os.environ |
485 if not is_testing: | |
486 # Don't overwrite the ~/.subversion/config file when TESTING_MASTER is set. | |
487 FixSubversionConfig() | |
488 HotPatchSlaveBuilder(is_testing) | 477 HotPatchSlaveBuilder(is_testing) |
489 | 478 |
490 import twisted.scripts.twistd as twistd | 479 import twisted.scripts.twistd as twistd |
491 twistd.run() | 480 twistd.run() |
492 shutdown_file = os.path.join(os.path.dirname(__file__), 'shutdown.stamp') | 481 shutdown_file = os.path.join(os.path.dirname(__file__), 'shutdown.stamp') |
493 if os.path.isfile(shutdown_file): | 482 if os.path.isfile(shutdown_file): |
494 # If this slave is being shut down gracefully, don't reboot it. | 483 # If this slave is being shut down gracefully, don't reboot it. |
495 try: | 484 try: |
496 os.remove(shutdown_file) | 485 os.remove(shutdown_file) |
497 # Only disable reboot if the file can be removed. Otherwise, the slave | 486 # Only disable reboot if the file can be removed. Otherwise, the slave |
(...skipping 25 matching lines...) Expand all Loading... |
523 if skip_sync_arg not in sys.argv: | 512 if skip_sync_arg not in sys.argv: |
524 UseBotoPath() | 513 UseBotoPath() |
525 if subprocess.call([GetGClientPath(), 'sync', '--force']) != 0: | 514 if subprocess.call([GetGClientPath(), 'sync', '--force']) != 0: |
526 print >> sys.stderr, ( | 515 print >> sys.stderr, ( |
527 '(%s) `gclient sync` failed; proceeding anyway...' % sys.argv[0]) | 516 '(%s) `gclient sync` failed; proceeding anyway...' % sys.argv[0]) |
528 os.execv(sys.executable, [sys.executable] + sys.argv + [skip_sync_arg]) | 517 os.execv(sys.executable, [sys.executable] + sys.argv + [skip_sync_arg]) |
529 | 518 |
530 # Remove skip_sync_arg from arg list. Needed because twistd. | 519 # Remove skip_sync_arg from arg list. Needed because twistd. |
531 sys.argv.remove(skip_sync_arg) | 520 sys.argv.remove(skip_sync_arg) |
532 main() | 521 main() |
OLD | NEW |