Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: slave/run_slave.py

Issue 2094713002: Include PowerShell in Windows PATH, if available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 python_path.append(os.path.join(BUILD_DIR, 'third_party', bb_ver)) 426 python_path.append(os.path.join(BUILD_DIR, 'third_party', bb_ver))
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 # Get the current PATH.
437 path_elements = os.environ['PATH'].split(os.pathsep)
438 def get_path_element(phrase):
hinoka 2016/06/23 22:17:55 This function does something pretty unexpected (to
dnj (Google) 2016/06/24 03:24:51 Done.
439 for e in path_elements:
440 if phrase in e:
Ryan Tseng 2016/06/23 16:45:30 if phrase in e.listdir()?
dnj (Google) 2016/06/24 03:24:51 "e" is a string here.
441 return [e]
442 return []
443
436 # Platform-specific initialization. 444 # Platform-specific initialization.
437
438 if sys.platform.startswith('win'): 445 if sys.platform.startswith('win'):
439 # list of all variables that we want to keep 446 # list of all variables that we want to keep
440 env_var = [ 447 env_var = [
441 'APPDATA', 448 'APPDATA',
442 'BUILDBOT_ARCHIVE_FORCE_SSH', 449 'BUILDBOT_ARCHIVE_FORCE_SSH',
443 'CHROME_HEADLESS', 450 'CHROME_HEADLESS',
444 'CHROMIUM_BUILD', 451 'CHROMIUM_BUILD',
445 'COMMONPROGRAMFILES', 452 'COMMONPROGRAMFILES',
446 'COMMONPROGRAMFILES(X86)', 453 'COMMONPROGRAMFILES(X86)',
447 'COMMONPROGRAMW6432', 454 'COMMONPROGRAMW6432',
(...skipping 29 matching lines...) Expand all
477 'USERNAME', 484 'USERNAME',
478 'USERDOMAIN', 485 'USERDOMAIN',
479 'USERPROFILE', 486 'USERPROFILE',
480 'VS100COMNTOOLS', 487 'VS100COMNTOOLS',
481 'VS110COMNTOOLS', 488 'VS110COMNTOOLS',
482 'WINDIR', 489 'WINDIR',
483 ] 490 ]
484 491
485 remove_all_vars_except(os.environ, env_var) 492 remove_all_vars_except(os.environ, env_var)
486 493
487 # Extend the env variables with the chrome-specific settings. 494 # Extend the env variables with the chrome-specific settings. Tailor the
495 # slave process' (and derivative tasks') PATH environment variable.
488 slave_path = [ 496 slave_path = [
489 depot_tools, 497 depot_tools,
490 # Reuse the python executable used to start this script. 498 # Reuse the python executable used to start this script.
491 os.path.dirname(sys.executable), 499 os.path.dirname(sys.executable),
492 os.path.join(os.environ['SYSTEMROOT'], 'system32'), 500 os.path.join(os.environ['SYSTEMROOT'], 'system32'),
493 os.path.join(os.environ['SYSTEMROOT'], 'system32', 'WBEM'), 501 os.path.join(os.environ['SYSTEMROOT'], 'system32', 'WBEM'),
494 # Use os.sep to make this absolute, not relative. 502 # Use os.sep to make this absolute, not relative.
495 os.path.join(os.environ['SYSTEMDRIVE'], os.sep, 'Program Files', 503 os.path.join(os.environ['SYSTEMDRIVE'], os.sep, 'Program Files',
496 '7-Zip'), 504 '7-Zip'),
497 # TODO(hinoka): Remove this when its no longer needed crbug.com/481695 505 # TODO(hinoka): Remove this when its no longer needed crbug.com/481695
498 os.path.join(os.environ['SYSTEMDRIVE'], os.sep, 'cmake', 'bin'), 506 os.path.join(os.environ['SYSTEMDRIVE'], os.sep, 'cmake', 'bin'),
499 ] 507 ]
508
509 # Include Windows PowerShell in PATH, if defined.
hinoka 2016/06/23 22:17:55 # It does so by searching for a path entry that co
dnj (Google) 2016/06/24 03:24:51 Done.
510 slave_path += get_path_element('WindowsPowerShell')
511
500 # build_internal/tools contains tools we can't redistribute. 512 # build_internal/tools contains tools we can't redistribute.
501 tools = os.path.join(ROOT_DIR, 'build_internal', 'tools') 513 tools = os.path.join(ROOT_DIR, 'build_internal', 'tools')
502 if os.path.isdir(tools): 514 if os.path.isdir(tools):
503 slave_path.append(os.path.abspath(tools)) 515 slave_path.append(os.path.abspath(tools))
504 os.environ['PATH'] = os.pathsep.join(slave_path) 516 os.environ['PATH'] = os.pathsep.join(slave_path)
505 os.environ['LOGNAME'] = os.environ['USERNAME'] 517 os.environ['LOGNAME'] = os.environ['USERNAME']
506 518
507 elif sys.platform in ('darwin', 'posix', 'linux2'): 519 elif sys.platform in ('darwin', 'posix', 'linux2'):
508 # list of all variables that we want to keep 520 # list of all variables that we want to keep
509 env_var = [ 521 env_var = [
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 if subprocess.call( 638 if subprocess.call(
627 [GetGClientPath(), 'sync', '--force', '--break_repo_locks'], 639 [GetGClientPath(), 'sync', '--force', '--break_repo_locks'],
628 env=EnvWithDepotTools()) != 0: 640 env=EnvWithDepotTools()) != 0:
629 print >> sys.stderr, ( 641 print >> sys.stderr, (
630 '(%s) `gclient sync` failed; proceeding anyway...' % sys.argv[0]) 642 '(%s) `gclient sync` failed; proceeding anyway...' % sys.argv[0])
631 os.execv(sys.executable, [sys.executable] + sys.argv + [skip_sync_arg]) 643 os.execv(sys.executable, [sys.executable] + sys.argv + [skip_sync_arg])
632 644
633 # Remove skip_sync_arg from arg list. Needed because twistd. 645 # Remove skip_sync_arg from arg list. Needed because twistd.
634 sys.argv.remove(skip_sync_arg) 646 sys.argv.remove(skip_sync_arg)
635 main() 647 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698