download_tester.py 1.3 KB
Newer Older
Adam Barth's avatar
Adam Barth committed
1 2 3 4 5 6 7 8 9
#!/usr/bin/env python
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import argparse
import os
import subprocess
import sys
10
import zipfile
Adam Barth's avatar
Adam Barth committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

def download(base_url, out_dir, name):
    url = '%s/%s' % (base_url, name)
    dst = os.path.join(out_dir, name)
    print 'Downloading', url
    subprocess.call([ 'curl', '-o', dst, url ])

def main():
    parser = argparse.ArgumentParser(description='Downloads test artifacts from Google storage')
    parser.add_argument('revision_file')
    parser.add_argument('out_dir')
    args = parser.parse_args()

    out_dir = args.out_dir
    if not os.path.exists(out_dir):
        os.makedirs(out_dir)

    revision = None
    with open(args.revision_file, 'r') as f:
        revision = f.read()

32 33 34 35 36 37
    base_url = 'https://storage.googleapis.com/mojo/flutter/%s/linux-x64' % revision
    download(base_url, out_dir, 'artifacts.zip')

    artifacts_zip = zipfile.ZipFile(os.path.join(out_dir, 'artifacts.zip'))
    artifacts_zip.extractall(out_dir)
    artifacts_zip.close()
Adam Barth's avatar
Adam Barth committed
38 39 40 41 42 43

    subprocess.call([ 'chmod', 'a+x', os.path.join(out_dir, 'sky_shell' )])
    subprocess.call([ 'chmod', 'a+x', os.path.join(out_dir, 'sky_snapshot' )])

if __name__ == '__main__':
    sys.exit(main())