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

Side by Side Diff: tools/auto_bisect/bisect_utils.py

Issue 1001033004: Fix style in tools/auto_bisect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 9 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
« no previous file with comments | « tools/auto_bisect/bisect_results_test.py ('k') | tools/auto_bisect/fetch_build_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 spec = ''.join([l for l in spec.splitlines()]) 318 spec = ''.join([l for l in spec.splitlines()])
319 319
320 if 'android' in opts.target_platform: 320 if 'android' in opts.target_platform:
321 spec += GCLIENT_SPEC_ANDROID 321 spec += GCLIENT_SPEC_ANDROID
322 322
323 return_code = RunGClient( 323 return_code = RunGClient(
324 ['config', '--spec=%s' % spec], cwd=cwd) 324 ['config', '--spec=%s' % spec], cwd=cwd)
325 return return_code 325 return return_code
326 326
327 327
328
329 def OnAccessError(func, path, _): 328 def OnAccessError(func, path, _):
330 """Error handler for shutil.rmtree. 329 """Error handler for shutil.rmtree.
331 330
332 Source: http://goo.gl/DEYNCT 331 Source: http://goo.gl/DEYNCT
333 332
334 If the error is due to an access error (read only file), it attempts to add 333 If the error is due to an access error (read only file), it attempts to add
335 write permissions, then retries. 334 write permissions, then retries.
336 335
337 If the error is for another reason it re-raises the error. 336 If the error is for another reason it re-raises the error.
338 337
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 def CheckRunGit(command, cwd=None): 423 def CheckRunGit(command, cwd=None):
425 """Run a git subcommand, returning its output and return code. Asserts if 424 """Run a git subcommand, returning its output and return code. Asserts if
426 the return code of the call is non-zero. 425 the return code of the call is non-zero.
427 426
428 Args: 427 Args:
429 command: A list containing the args to git. 428 command: A list containing the args to git.
430 429
431 Returns: 430 Returns:
432 A tuple of the output and return code. 431 A tuple of the output and return code.
433 """ 432 """
434 (output, return_code) = RunGit(command, cwd=cwd) 433 output, return_code = RunGit(command, cwd=cwd)
435 434
436 assert not return_code, 'An error occurred while running'\ 435 assert not return_code, 'An error occurred while running'\
437 ' "git %s"' % ' '.join(command) 436 ' "git %s"' % ' '.join(command)
438 return output 437 return output
439 438
440 439
441 def RunGit(command, cwd=None): 440 def RunGit(command, cwd=None):
442 """Run a git subcommand, returning its output and return code. 441 """Run a git subcommand, returning its output and return code.
443 442
444 Args: 443 Args:
(...skipping 11 matching lines...) Expand all
456 """Sets up a subdirectory 'bisect' and then retrieves a copy of the depot 455 """Sets up a subdirectory 'bisect' and then retrieves a copy of the depot
457 there using gclient. 456 there using gclient.
458 457
459 Args: 458 Args:
460 opts: The options parsed from the command line through parse_args(). 459 opts: The options parsed from the command line through parse_args().
461 custom_deps: A dictionary of additional dependencies to add to .gclient. 460 custom_deps: A dictionary of additional dependencies to add to .gclient.
462 """ 461 """
463 if CheckIfBisectDepotExists(opts): 462 if CheckIfBisectDepotExists(opts):
464 path_to_dir = os.path.join(os.path.abspath(opts.working_directory), 463 path_to_dir = os.path.join(os.path.abspath(opts.working_directory),
465 BISECT_DIR, 'src') 464 BISECT_DIR, 'src')
466 (output, _) = RunGit(['rev-parse', '--is-inside-work-tree'], 465 output, _ = RunGit(['rev-parse', '--is-inside-work-tree'], cwd=path_to_dir)
467 cwd=path_to_dir)
468 if output.strip() == 'true': 466 if output.strip() == 'true':
469 # Before checking out master, cleanup up any leftover index.lock files. 467 # Before checking out master, cleanup up any leftover index.lock files.
470 _CleanupPreviousGitRuns(path_to_dir) 468 _CleanupPreviousGitRuns(path_to_dir)
471 # 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.
472 CheckRunGit(['checkout', '-f', 'master'], cwd=path_to_dir) 470 CheckRunGit(['checkout', '-f', 'master'], cwd=path_to_dir)
473 if not _CreateAndChangeToSourceDirectory(opts.working_directory): 471 if not _CreateAndChangeToSourceDirectory(opts.working_directory):
474 raise RuntimeError('Could not create bisect directory.') 472 raise RuntimeError('Could not create bisect directory.')
475 473
476 if not SetupGitDepot(opts, custom_deps): 474 if not SetupGitDepot(opts, custom_deps):
477 raise RuntimeError('Failed to grab source.') 475 raise RuntimeError('Failed to grab source.')
(...skipping 30 matching lines...) Expand all
508 506
509 Returns: 507 Returns:
510 A tuple of the output and return code. 508 A tuple of the output and return code.
511 """ 509 """
512 if cwd: 510 if cwd:
513 original_cwd = os.getcwd() 511 original_cwd = os.getcwd()
514 os.chdir(cwd) 512 os.chdir(cwd)
515 513
516 # On Windows, use shell=True to get PATH interpretation. 514 # On Windows, use shell=True to get PATH interpretation.
517 shell = IsWindowsHost() 515 shell = IsWindowsHost()
518 proc = subprocess.Popen(command, shell=shell, stdout=subprocess.PIPE, 516 proc = subprocess.Popen(
517 command, shell=shell, stdout=subprocess.PIPE,
519 stderr=subprocess.STDOUT) 518 stderr=subprocess.STDOUT)
520 (output, _) = proc.communicate() 519 output, _ = proc.communicate()
521 520
522 if cwd: 521 if cwd:
523 os.chdir(original_cwd) 522 os.chdir(original_cwd)
524 523
525 return (output, proc.returncode) 524 return (output, proc.returncode)
526 525
527 526
528 def IsStringInt(string_to_check): 527 def IsStringInt(string_to_check):
529 """Checks whether or not the given string can be converted to an int.""" 528 """Checks whether or not the given string can be converted to an int."""
530 try: 529 try:
(...skipping 24 matching lines...) Expand all
555 platform = os.environ.get('PROCESSOR_ARCHITECTURE') 554 platform = os.environ.get('PROCESSOR_ARCHITECTURE')
556 return platform and platform in ['AMD64', 'I64'] 555 return platform and platform in ['AMD64', 'I64']
557 556
558 557
559 def IsLinuxHost(): 558 def IsLinuxHost():
560 return sys.platform.startswith('linux') 559 return sys.platform.startswith('linux')
561 560
562 561
563 def IsMacHost(): 562 def IsMacHost():
564 return sys.platform.startswith('darwin') 563 return sys.platform.startswith('darwin')
OLDNEW
« no previous file with comments | « tools/auto_bisect/bisect_results_test.py ('k') | tools/auto_bisect/fetch_build_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698