| OLD | NEW |
| (Empty) | |
| 1 #!/usr/bin/python |
| 2 |
| 3 # Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a |
| 5 # BSD-style license that can be found in the LICENSE file. |
| 6 |
| 7 """Download archived multivm or dartium builds. |
| 8 |
| 9 Usage: download_multivm.py revision target_directory |
| 10 """ |
| 11 |
| 12 import imp |
| 13 import os |
| 14 import platform |
| 15 import shutil |
| 16 import subprocess |
| 17 import sys |
| 18 |
| 19 # We are in [checkout dir]/src/dart/tools/dartium in a dartium/multivm checkout |
| 20 TOOLS_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| 21 SRC_DIR = os.path.dirname(os.path.dirname(TOOLS_DIR)) |
| 22 GS_BUCKET = 'gs://dartium-archive' |
| 23 if platform.system() == 'Windows': |
| 24 GSUTIL = 'e:\\b\\build\\scripts\\slave\\gsutil.bat' |
| 25 else: |
| 26 GSUTIL = '/b/build/scripts/slave/gsutil' |
| 27 if not os.path.exists(GSUTIL): |
| 28 GSUTIL = 'gsutil' |
| 29 |
| 30 def ExecuteCommand(cmd): |
| 31 print 'Executing: ' + ' '.join(cmd) |
| 32 subprocess.check_output(cmd) |
| 33 |
| 34 def main(): |
| 35 revision = sys.argv[1] |
| 36 target_dir = sys.argv[2] |
| 37 archive_dir = (os.environ['BUILDBOT_BUILDERNAME'] |
| 38 .replace('linux', 'lucid64') |
| 39 .replace('multivm', 'multivm-dartium')) |
| 40 utils = imp.load_source('utils', os.path.join(TOOLS_DIR, 'utils.py')) |
| 41 with utils.TempDir() as temp_dir: |
| 42 archive_file = archive_dir + '-' + revision + '.zip' |
| 43 gs_source = '/'.join([GS_BUCKET, archive_dir, archive_file]) |
| 44 zip_file = os.path.join(temp_dir, archive_file) |
| 45 ExecuteCommand([GSUTIL, 'cp', gs_source, zip_file]) |
| 46 |
| 47 unzip_dir = zip_file.replace('.zip', '') |
| 48 if platform.system() == 'Windows': |
| 49 executable = os.path.join(SRC_DIR, 'third_party', 'lzma_sdk', |
| 50 'Executable', '7za.exe') |
| 51 ExecuteCommand([executable, 'x', '-aoa', '-o' + temp_dir, zip_file]) |
| 52 else: |
| 53 ExecuteCommand(['unzip', zip_file, '-d', temp_dir]) |
| 54 |
| 55 if os.path.exists(target_dir): |
| 56 shutil.rmtree(target_dir) |
| 57 shutil.move(unzip_dir, target_dir) |
| 58 |
| 59 if __name__ == '__main__': |
| 60 sys.exit(main()) |
| OLD | NEW |