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

Side by Side Diff: tools/bisect-perf-regression.py

Issue 306023008: Use python fallback for unzipping in extracting build on mac if file is greater than 4GB (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 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 """Performance Test Bisect Tool 6 """Performance Test Bisect Tool
7 7
8 This script bisects a series of changelists using binary search. It starts at 8 This script bisects a series of changelists using binary search. It starts at
9 a bad revision where a performance metric has regressed, and asks for a last 9 a bad revision where a performance metric has regressed, and asks for a last
10 known-good revision. It will then binary search across this revision range by 10 known-good revision. It will then binary search across this revision range by
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 515
516 # This is copied from Chromium's project build/scripts/common/chromium_utils.py. 516 # This is copied from Chromium's project build/scripts/common/chromium_utils.py.
517 def ExtractZip(filename, output_dir, verbose=True): 517 def ExtractZip(filename, output_dir, verbose=True):
518 """ Extract the zip archive in the output directory.""" 518 """ Extract the zip archive in the output directory."""
519 MaybeMakeDirectory(output_dir) 519 MaybeMakeDirectory(output_dir)
520 520
521 # On Linux and Mac, we use the unzip command as it will 521 # On Linux and Mac, we use the unzip command as it will
522 # handle links and file bits (executable), which is much 522 # handle links and file bits (executable), which is much
523 # easier then trying to do that with ZipInfo options. 523 # easier then trying to do that with ZipInfo options.
524 # 524 #
525 # The Mac Version of unzip unfortunately does not support Zip64, whereas
526 # the python module does, so we have to fallback to the python zip module
527 # on Mac if the filesize is greater than 4GB.
528 #
525 # On Windows, try to use 7z if it is installed, otherwise fall back to python 529 # On Windows, try to use 7z if it is installed, otherwise fall back to python
526 # zip module and pray we don't have files larger than 512MB to unzip. 530 # zip module and pray we don't have files larger than 512MB to unzip.
527 unzip_cmd = None 531 unzip_cmd = None
528 if IsMac() or IsLinux(): 532 if ((IsMac() and os.path.getsize(filename) < 4 * 1024 * 1024 * 1024)
533 or IsLinux()):
529 unzip_cmd = ['unzip', '-o'] 534 unzip_cmd = ['unzip', '-o']
530 elif IsWindows() and os.path.exists('C:\\Program Files\\7-Zip\\7z.exe'): 535 elif IsWindows() and os.path.exists('C:\\Program Files\\7-Zip\\7z.exe'):
531 unzip_cmd = ['C:\\Program Files\\7-Zip\\7z.exe', 'x', '-y'] 536 unzip_cmd = ['C:\\Program Files\\7-Zip\\7z.exe', 'x', '-y']
532 537
533 if unzip_cmd: 538 if unzip_cmd:
534 # Make sure path is absolute before changing directories. 539 # Make sure path is absolute before changing directories.
535 filepath = os.path.abspath(filename) 540 filepath = os.path.abspath(filename)
536 saved_dir = os.getcwd() 541 saved_dir = os.getcwd()
537 os.chdir(output_dir) 542 os.chdir(output_dir)
538 command = unzip_cmd + [filepath] 543 command = unzip_cmd + [filepath]
539 result = RunProcess(command) 544 result = RunProcess(command)
540 os.chdir(saved_dir) 545 os.chdir(saved_dir)
541 if result: 546 if result:
542 raise IOError('unzip failed: %s => %s' % (str(command), result)) 547 raise IOError('unzip failed: %s => %s' % (str(command), result))
543 else: 548 else:
544 assert IsWindows() 549 assert IsWindows() or IsMac()
545 zf = zipfile.ZipFile(filename) 550 zf = zipfile.ZipFile(filename)
546 for name in zf.namelist(): 551 for name in zf.namelist():
547 if verbose: 552 if verbose:
548 print 'Extracting %s' % name 553 print 'Extracting %s' % name
549 zf.extract(name, output_dir) 554 zf.extract(name, output_dir)
555 if IsMac():
556 # Restore permission bits.
557 os.chmod(os.path.join(output_dir, name),
558 zf.getinfo(name).external_attr >> 16L)
550 559
551 560
552 def RunProcess(command): 561 def RunProcess(command):
553 """Runs an arbitrary command. 562 """Runs an arbitrary command.
554 563
555 If output from the call is needed, use RunProcessAndRetrieveOutput instead. 564 If output from the call is needed, use RunProcessAndRetrieveOutput instead.
556 565
557 Args: 566 Args:
558 command: A list containing the command and args to execute. 567 command: A list containing the command and args to execute.
559 568
(...skipping 3344 matching lines...) Expand 10 before | Expand all | Expand 10 after
3904 # The perf dashboard scrapes the "results" step in order to comment on 3913 # The perf dashboard scrapes the "results" step in order to comment on
3905 # bugs. If you change this, please update the perf dashboard as well. 3914 # bugs. If you change this, please update the perf dashboard as well.
3906 bisect_utils.OutputAnnotationStepStart('Results') 3915 bisect_utils.OutputAnnotationStepStart('Results')
3907 print 'Error: %s' % e.message 3916 print 'Error: %s' % e.message
3908 if opts.output_buildbot_annotations: 3917 if opts.output_buildbot_annotations:
3909 bisect_utils.OutputAnnotationStepClosed() 3918 bisect_utils.OutputAnnotationStepClosed()
3910 return 1 3919 return 1
3911 3920
3912 if __name__ == '__main__': 3921 if __name__ == '__main__':
3913 sys.exit(main()) 3922 sys.exit(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