| 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 """This module contains functions for fetching and extracting archived builds. | 5 """This module contains functions for fetching and extracting archived builds. |
| 6 | 6 |
| 7 The builds may be stored in different places by different types of builders; | 7 The builds may be stored in different places by different types of builders; |
| 8 for example, builders on tryserver.chromium.perf stores builds in one place, | 8 for example, builders on tryserver.chromium.perf stores builds in one place, |
| 9 while builders on chromium.linux store builds in another. | 9 while builders on chromium.linux store builds in another. |
| 10 | 10 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 Args: | 123 Args: |
| 124 revision: A git commit hash or other revision string. | 124 revision: A git commit hash or other revision string. |
| 125 deps_patch_sha: SHA1 hash of a DEPS file patch. | 125 deps_patch_sha: SHA1 hash of a DEPS file patch. |
| 126 | 126 |
| 127 Returns: | 127 Returns: |
| 128 The archive file name. | 128 The archive file name. |
| 129 """ | 129 """ |
| 130 base_name = 'full-build-%s' % self._PlatformName() | 130 base_name = 'full-build-%s' % self._PlatformName() |
| 131 if deps_patch_sha: | 131 if deps_patch_sha: |
| 132 revision = '%s_%s' % (revision , deps_patch_sha) | 132 revision = '%s_%s' % (revision, deps_patch_sha) |
| 133 return '%s_%s.zip' % (base_name, revision) | 133 return '%s_%s.zip' % (base_name, revision) |
| 134 | 134 |
| 135 def _PlatformName(self): | 135 def _PlatformName(self): |
| 136 """Return a string to be used in paths for the platform.""" | 136 """Return a string to be used in paths for the platform.""" |
| 137 if self._platform in ('win', 'win64'): | 137 if self._platform in ('win', 'win64'): |
| 138 # Build archive for win64 is still stored with "win32" in the name. | 138 # Build archive for win64 is still stored with "win32" in the name. |
| 139 return 'win32' | 139 return 'win32' |
| 140 if self._platform in ('linux', 'android'): | 140 if self._platform in ('linux', 'android'): |
| 141 # Android builds are also stored with "linux" in the name. | 141 # Android builds are also stored with "linux" in the name. |
| 142 return 'linux' | 142 return 'linux' |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 (bisect_utils.IsMacHost() | 257 (bisect_utils.IsMacHost() |
| 258 and os.path.getsize(filename) < mac_zip_size_limit)): | 258 and os.path.getsize(filename) < mac_zip_size_limit)): |
| 259 unzip_command = ['unzip', '-o'] | 259 unzip_command = ['unzip', '-o'] |
| 260 _UnzipUsingCommand(unzip_command, filename, output_dir) | 260 _UnzipUsingCommand(unzip_command, filename, output_dir) |
| 261 return | 261 return |
| 262 | 262 |
| 263 # On Windows, try to use 7z if it is installed, otherwise fall back to the | 263 # On Windows, try to use 7z if it is installed, otherwise fall back to the |
| 264 # Python zipfile module. If 7z is not installed, then this may fail if the | 264 # Python zipfile module. If 7z is not installed, then this may fail if the |
| 265 # zip file is larger than 512MB. | 265 # zip file is larger than 512MB. |
| 266 sevenzip_path = r'C:\Program Files\7-Zip\7z.exe' | 266 sevenzip_path = r'C:\Program Files\7-Zip\7z.exe' |
| 267 if (bisect_utils.IsWindowsHost() and os.path.exists(sevenzip_path)): | 267 if bisect_utils.IsWindowsHost() and os.path.exists(sevenzip_path): |
| 268 unzip_command = [sevenzip_path, 'x', '-y'] | 268 unzip_command = [sevenzip_path, 'x', '-y'] |
| 269 _UnzipUsingCommand(unzip_command, filename, output_dir) | 269 _UnzipUsingCommand(unzip_command, filename, output_dir) |
| 270 return | 270 return |
| 271 | 271 |
| 272 _UnzipUsingZipFile(filename, output_dir, verbose) | 272 _UnzipUsingZipFile(filename, output_dir, verbose) |
| 273 | 273 |
| 274 | 274 |
| 275 def _UnzipUsingCommand(unzip_command, filename, output_dir): | 275 def _UnzipUsingCommand(unzip_command, filename, output_dir): |
| 276 """Extracts a zip file using an external command. | 276 """Extracts a zip file using an external command. |
| 277 | 277 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 deps_patch_sha=args.deps_patch_sha) | 348 deps_patch_sha=args.deps_patch_sha) |
| 349 | 349 |
| 350 print 'Build has been downloaded to and extracted in %s.' % args.output_dir | 350 print 'Build has been downloaded to and extracted in %s.' % args.output_dir |
| 351 | 351 |
| 352 return 0 | 352 return 0 |
| 353 | 353 |
| 354 | 354 |
| 355 if __name__ == '__main__': | 355 if __name__ == '__main__': |
| 356 sys.exit(Main(sys.argv)) | 356 sys.exit(Main(sys.argv)) |
| 357 | 357 |
| OLD | NEW |