| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Utility functions used by the bisect tool. | 5 """Utility functions used by the bisect tool. |
| 6 | 6 |
| 7 This includes functions related to checking out the depot and outputting | 7 This includes functions related to checking out the depot and outputting |
| 8 annotations for the Buildbot waterfall. | 8 annotations for the Buildbot waterfall. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 _CleanupPreviousGitRuns(path_to_dir) | 468 _CleanupPreviousGitRuns(path_to_dir) |
| 469 # Checks out the master branch, throws an exception if git command fails. | 469 # Checks out the master branch, throws an exception if git command fails. |
| 470 CheckRunGit(['checkout', '-f', 'master'], cwd=path_to_dir) | 470 CheckRunGit(['checkout', '-f', 'master'], cwd=path_to_dir) |
| 471 if not _CreateAndChangeToSourceDirectory(opts.working_directory): | 471 if not _CreateAndChangeToSourceDirectory(opts.working_directory): |
| 472 raise RuntimeError('Could not create bisect directory.') | 472 raise RuntimeError('Could not create bisect directory.') |
| 473 | 473 |
| 474 if not SetupGitDepot(opts, custom_deps): | 474 if not SetupGitDepot(opts, custom_deps): |
| 475 raise RuntimeError('Failed to grab source.') | 475 raise RuntimeError('Failed to grab source.') |
| 476 | 476 |
| 477 | 477 |
| 478 def RunProcess(command): | 478 def RunProcess(command, cwd=None, shell=False): |
| 479 """Runs an arbitrary command. | 479 """Runs an arbitrary command. |
| 480 | 480 |
| 481 If output from the call is needed, use RunProcessAndRetrieveOutput instead. | 481 If output from the call is needed, use RunProcessAndRetrieveOutput instead. |
| 482 | 482 |
| 483 Args: | 483 Args: |
| 484 command: A list containing the command and args to execute. | 484 command: A list containing the command and args to execute. |
| 485 | 485 |
| 486 Returns: | 486 Returns: |
| 487 The return code of the call. | 487 The return code of the call. |
| 488 """ | 488 """ |
| 489 # On Windows, use shell=True to get PATH interpretation. | 489 # On Windows, use shell=True to get PATH interpretation. |
| 490 shell = IsWindowsHost() | 490 shell = shell or IsWindowsHost() |
| 491 return subprocess.call(command, shell=shell) | 491 return subprocess.call(command, cwd=cwd, shell=shell) |
| 492 | 492 |
| 493 | 493 |
| 494 def RunProcessAndRetrieveOutput(command, cwd=None): | 494 def RunProcessAndRetrieveOutput(command, cwd=None): |
| 495 """Runs an arbitrary command, returning its output and return code. | 495 """Runs an arbitrary command, returning its output and return code. |
| 496 | 496 |
| 497 Since output is collected via communicate(), there will be no output until | 497 Since output is collected via communicate(), there will be no output until |
| 498 the call terminates. If you need output while the program runs (ie. so | 498 the call terminates. If you need output while the program runs (ie. so |
| 499 that the buildbot doesn't terminate the script), consider RunProcess(). | 499 that the buildbot doesn't terminate the script), consider RunProcess(). |
| 500 | 500 |
| 501 Args: | 501 Args: |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 platform = os.environ.get('PROCESSOR_ARCHITECTURE') | 554 platform = os.environ.get('PROCESSOR_ARCHITECTURE') |
| 555 return platform and platform in ['AMD64', 'I64'] | 555 return platform and platform in ['AMD64', 'I64'] |
| 556 | 556 |
| 557 | 557 |
| 558 def IsLinuxHost(): | 558 def IsLinuxHost(): |
| 559 return sys.platform.startswith('linux') | 559 return sys.platform.startswith('linux') |
| 560 | 560 |
| 561 | 561 |
| 562 def IsMacHost(): | 562 def IsMacHost(): |
| 563 return sys.platform.startswith('darwin') | 563 return sys.platform.startswith('darwin') |
| OLD | NEW |