Chromium Code Reviews| Index: slave/run_slave.py |
| diff --git a/slave/run_slave.py b/slave/run_slave.py |
| index 72c5021ec502f20334d466093b1d046b363e5c9a..779f7c959953b3d53a6670ac36a8edc5bee181b2 100755 |
| --- a/slave/run_slave.py |
| +++ b/slave/run_slave.py |
| @@ -57,7 +57,7 @@ def IssueReboot(): |
| 'for %s' % sys.platform) |
| -def SigTerm(*args): |
| +def SigTerm(*_args): |
| """Receive a SIGTERM and do nothing.""" |
| Log('SigTerm: Received SIGTERM, doing nothing.') |
| @@ -433,8 +433,18 @@ def main(): |
| os.environ['CHROME_HEADLESS'] = '1' |
| os.environ['PAGER'] = 'cat' |
| - # Platform-specific initialization. |
| + # Split the path into its components. |
| + path_components = os.environ['PATH'].split(os.pathsep) |
| + # This function identifies a PATH component that has the supplied phrase in |
| + # one of its directories. |
| + def get_path_component_containing(phrase): |
|
agable
2016/06/24 18:29:16
This function is only used once, and is defined ne
dnj (Google)
2016/06/24 18:39:59
My thought was that it is OS-independent and seeme
|
| + phrase = phrase.lower() |
| + for c in path_components: |
| + if any(phrase == d.lower() for d in c.split(os.sep)): |
| + return [c] |
| + return [] |
| + # Platform-specific initialization. |
| if sys.platform.startswith('win'): |
| # list of all variables that we want to keep |
| env_var = [ |
| @@ -484,7 +494,8 @@ def main(): |
| remove_all_vars_except(os.environ, env_var) |
| - # Extend the env variables with the chrome-specific settings. |
| + # Extend the env variables with the chrome-specific settings. Tailor the |
| + # slave process' (and derivative tasks') PATH environment variable. |
| slave_path = [ |
| depot_tools, |
| # Reuse the python executable used to start this script. |
| @@ -497,6 +508,13 @@ def main(): |
| # TODO(hinoka): Remove this when its no longer needed crbug.com/481695 |
| os.path.join(os.environ['SYSTEMDRIVE'], os.sep, 'cmake', 'bin'), |
| ] |
| + |
| + # Include Windows PowerShell in PATH, if defined. It does this by looking |
| + # through the system path for an element containing a directory named |
| + # "WindowsPowerShell", which is assumed to be the component adding |
| + # PowerShell to the PATH. |
| + slave_path += get_path_component_containing('WindowsPowerShell') |
| + |
| # build_internal/tools contains tools we can't redistribute. |
| tools = os.path.join(ROOT_DIR, 'build_internal', 'tools') |
| if os.path.isdir(tools): |