OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2016 Google Inc. | 3 # Copyright 2016 Google Inc. |
4 # | 4 # |
5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
7 | 7 |
8 | 8 |
9 import os | 9 import os |
10 import shutil | 10 import shutil |
11 import subprocess | 11 import subprocess |
12 | 12 |
13 | 13 |
14 GS_GM_BUCKET = 'chromium-skia-gm' | 14 GS_GM_BUCKET = 'chromium-skia-gm' |
15 | 15 |
16 GS_SUBDIR_TMPL_SK_IMAGE = 'skimage/v%s' | |
17 GS_SUBDIR_TMPL_SKP = 'playback_%s/skps' | 16 GS_SUBDIR_TMPL_SKP = 'playback_%s/skps' |
18 | 17 |
19 VERSION_FILE_SK_IMAGE = 'SK_IMAGE_VERSION' | |
20 VERSION_FILE_SKP = 'SKP_VERSION' | 18 VERSION_FILE_SKP = 'SKP_VERSION' |
21 | 19 |
22 | 20 |
23 def download_dir(skia_dir, tmp_dir, version_file, gs_path_tmpl, dst_dir): | 21 def download_dir(skia_dir, tmp_dir, version_file, gs_path_tmpl, dst_dir): |
24 # Ensure that the tmp_dir exists. | 22 # Ensure that the tmp_dir exists. |
25 if not os.path.isdir(tmp_dir): | 23 if not os.path.isdir(tmp_dir): |
26 os.makedirs(tmp_dir) | 24 os.makedirs(tmp_dir) |
27 | 25 |
28 # Get the expected version. | 26 # Get the expected version. |
29 with open(os.path.join(skia_dir, version_file)) as f: | 27 with open(os.path.join(skia_dir, version_file)) as f: |
(...skipping 16 matching lines...) Expand all Loading... |
46 if actual_version != -1: | 44 if actual_version != -1: |
47 os.remove(actual_version_file) | 45 os.remove(actual_version_file) |
48 if os.path.isdir(dst_dir): | 46 if os.path.isdir(dst_dir): |
49 shutil.rmtree(dst_dir) | 47 shutil.rmtree(dst_dir) |
50 os.makedirs(dst_dir) | 48 os.makedirs(dst_dir) |
51 gs_path = 'gs://%s/%s/*' % (GS_GM_BUCKET, gs_path_tmpl % expected_version) | 49 gs_path = 'gs://%s/%s/*' % (GS_GM_BUCKET, gs_path_tmpl % expected_version) |
52 print 'Downloading from %s' % gs_path | 50 print 'Downloading from %s' % gs_path |
53 subprocess.check_call(['gsutil', 'cp', '-R', gs_path, dst_dir]) | 51 subprocess.check_call(['gsutil', 'cp', '-R', gs_path, dst_dir]) |
54 with open(actual_version_file, 'w') as f: | 52 with open(actual_version_file, 'w') as f: |
55 f.write(expected_version) | 53 f.write(expected_version) |
OLD | NEW |