| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 """Issue reboot command according to platform type.""" | 50 """Issue reboot command according to platform type.""" |
| 51 if sys.platform.startswith('win'): | 51 if sys.platform.startswith('win'): |
| 52 subprocess.call(['shutdown', '-r', '-f', '-t', '1']) | 52 subprocess.call(['shutdown', '-r', '-f', '-t', '1']) |
| 53 elif sys.platform in ('darwin', 'posix', 'linux2'): | 53 elif sys.platform in ('darwin', 'posix', 'linux2'): |
| 54 subprocess.call(['sudo', 'shutdown', '-r', 'now']) | 54 subprocess.call(['sudo', 'shutdown', '-r', 'now']) |
| 55 else: | 55 else: |
| 56 raise NotImplementedError('Implement IssueReboot function ' | 56 raise NotImplementedError('Implement IssueReboot function ' |
| 57 'for %s' % sys.platform) | 57 'for %s' % sys.platform) |
| 58 | 58 |
| 59 | 59 |
| 60 def SigTerm(*args): | 60 def SigTerm(*_args): |
| 61 """Receive a SIGTERM and do nothing.""" | 61 """Receive a SIGTERM and do nothing.""" |
| 62 Log('SigTerm: Received SIGTERM, doing nothing.') | 62 Log('SigTerm: Received SIGTERM, doing nothing.') |
| 63 | 63 |
| 64 | 64 |
| 65 def UpdateSignals(): | 65 def UpdateSignals(): |
| 66 """Override the twisted SIGTERM handler with our own. | 66 """Override the twisted SIGTERM handler with our own. |
| 67 | 67 |
| 68 Ensure that the signal module is available and do nothing if it is not. | 68 Ensure that the signal module is available and do nothing if it is not. |
| 69 """ | 69 """ |
| 70 try: | 70 try: |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 python_path.append(os.path.join(BUILD_DIR, 'third_party', tw_ver)) | 427 python_path.append(os.path.join(BUILD_DIR, 'third_party', tw_ver)) |
| 428 sys.path = python_path[-2:] + sys.path | 428 sys.path = python_path[-2:] + sys.path |
| 429 | 429 |
| 430 os.environ['PYTHONPATH'] = ( | 430 os.environ['PYTHONPATH'] = ( |
| 431 os.pathsep.join(python_path) + os.pathsep + os.environ['PYTHONPATH']) | 431 os.pathsep.join(python_path) + os.pathsep + os.environ['PYTHONPATH']) |
| 432 | 432 |
| 433 os.environ['CHROME_HEADLESS'] = '1' | 433 os.environ['CHROME_HEADLESS'] = '1' |
| 434 os.environ['PAGER'] = 'cat' | 434 os.environ['PAGER'] = 'cat' |
| 435 | 435 |
| 436 # Platform-specific initialization. | 436 # Platform-specific initialization. |
| 437 | |
| 438 if sys.platform.startswith('win'): | 437 if sys.platform.startswith('win'): |
| 439 # list of all variables that we want to keep | 438 # list of all variables that we want to keep |
| 440 env_var = [ | 439 env_var = [ |
| 441 'APPDATA', | 440 'APPDATA', |
| 442 'BUILDBOT_ARCHIVE_FORCE_SSH', | 441 'BUILDBOT_ARCHIVE_FORCE_SSH', |
| 443 'CHROME_HEADLESS', | 442 'CHROME_HEADLESS', |
| 444 'CHROMIUM_BUILD', | 443 'CHROMIUM_BUILD', |
| 445 'COMMONPROGRAMFILES', | 444 'COMMONPROGRAMFILES', |
| 446 'COMMONPROGRAMFILES(X86)', | 445 'COMMONPROGRAMFILES(X86)', |
| 447 'COMMONPROGRAMW6432', | 446 'COMMONPROGRAMW6432', |
| (...skipping 29 matching lines...) Expand all Loading... |
| 477 'USERNAME', | 476 'USERNAME', |
| 478 'USERDOMAIN', | 477 'USERDOMAIN', |
| 479 'USERPROFILE', | 478 'USERPROFILE', |
| 480 'VS100COMNTOOLS', | 479 'VS100COMNTOOLS', |
| 481 'VS110COMNTOOLS', | 480 'VS110COMNTOOLS', |
| 482 'WINDIR', | 481 'WINDIR', |
| 483 ] | 482 ] |
| 484 | 483 |
| 485 remove_all_vars_except(os.environ, env_var) | 484 remove_all_vars_except(os.environ, env_var) |
| 486 | 485 |
| 487 # Extend the env variables with the chrome-specific settings. | 486 # Extend the env variables with the chrome-specific settings. Tailor the |
| 487 # slave process' (and derivative tasks') PATH environment variable. |
| 488 slave_path = [ | 488 slave_path = [ |
| 489 depot_tools, | 489 depot_tools, |
| 490 # Reuse the python executable used to start this script. | 490 # Reuse the python executable used to start this script. |
| 491 os.path.dirname(sys.executable), | 491 os.path.dirname(sys.executable), |
| 492 os.path.join(os.environ['SYSTEMROOT'], 'system32'), | 492 os.path.join(os.environ['SYSTEMROOT'], 'system32'), |
| 493 os.path.join(os.environ['SYSTEMROOT'], 'system32', 'WBEM'), | 493 os.path.join(os.environ['SYSTEMROOT'], 'system32', 'WBEM'), |
| 494 # Use os.sep to make this absolute, not relative. | 494 # Use os.sep to make this absolute, not relative. |
| 495 os.path.join(os.environ['SYSTEMDRIVE'], os.sep, 'Program Files', | 495 os.path.join(os.environ['SYSTEMDRIVE'], os.sep, 'Program Files', |
| 496 '7-Zip'), | 496 '7-Zip'), |
| 497 # TODO(hinoka): Remove this when its no longer needed crbug.com/481695 | 497 # TODO(hinoka): Remove this when its no longer needed crbug.com/481695 |
| 498 os.path.join(os.environ['SYSTEMDRIVE'], os.sep, 'cmake', 'bin'), | 498 os.path.join(os.environ['SYSTEMDRIVE'], os.sep, 'cmake', 'bin'), |
| 499 ] | 499 ] |
| 500 |
| 501 # Include Windows PowerShell in PATH, if defined. |
| 502 def which_path(cmd): |
| 503 path = chromium_utils.Which(cmd) |
| 504 return ([os.path.dirname(os.path.abspath(path))] if path else []) |
| 505 slave_path += which_path('powershell.exe') |
| 506 |
| 500 # build_internal/tools contains tools we can't redistribute. | 507 # build_internal/tools contains tools we can't redistribute. |
| 501 tools = os.path.join(ROOT_DIR, 'build_internal', 'tools') | 508 tools = os.path.join(ROOT_DIR, 'build_internal', 'tools') |
| 502 if os.path.isdir(tools): | 509 if os.path.isdir(tools): |
| 503 slave_path.append(os.path.abspath(tools)) | 510 slave_path.append(os.path.abspath(tools)) |
| 504 os.environ['PATH'] = os.pathsep.join(slave_path) | 511 os.environ['PATH'] = os.pathsep.join(slave_path) |
| 505 os.environ['LOGNAME'] = os.environ['USERNAME'] | 512 os.environ['LOGNAME'] = os.environ['USERNAME'] |
| 506 | 513 |
| 507 elif sys.platform in ('darwin', 'posix', 'linux2'): | 514 elif sys.platform in ('darwin', 'posix', 'linux2'): |
| 508 # list of all variables that we want to keep | 515 # list of all variables that we want to keep |
| 509 env_var = [ | 516 env_var = [ |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 if subprocess.call( | 633 if subprocess.call( |
| 627 [GetGClientPath(), 'sync', '--force', '--break_repo_locks'], | 634 [GetGClientPath(), 'sync', '--force', '--break_repo_locks'], |
| 628 env=EnvWithDepotTools()) != 0: | 635 env=EnvWithDepotTools()) != 0: |
| 629 print >> sys.stderr, ( | 636 print >> sys.stderr, ( |
| 630 '(%s) `gclient sync` failed; proceeding anyway...' % sys.argv[0]) | 637 '(%s) `gclient sync` failed; proceeding anyway...' % sys.argv[0]) |
| 631 os.execv(sys.executable, [sys.executable] + sys.argv + [skip_sync_arg]) | 638 os.execv(sys.executable, [sys.executable] + sys.argv + [skip_sync_arg]) |
| 632 | 639 |
| 633 # Remove skip_sync_arg from arg list. Needed because twistd. | 640 # Remove skip_sync_arg from arg list. Needed because twistd. |
| 634 sys.argv.remove(skip_sync_arg) | 641 sys.argv.remove(skip_sync_arg) |
| 635 main() | 642 main() |
| OLD | NEW |