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

Side by Side Diff: infra/bots/common.py

Issue 2167763002: Add "skp" asset (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Backpedal: Don't get rid of old SKPs yet Created 4 years, 5 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
« no previous file with comments | « infra/bots/assets/skp/upload.py ('k') | infra/bots/download_skps.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2016 Google Inc.
4 #
5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file.
7
8
9 import os
10 import shutil
11 import subprocess
12
13
14 GS_GM_BUCKET = 'chromium-skia-gm'
15
16 GS_SUBDIR_TMPL_SKP = 'playback_%s/skps'
17
18 VERSION_FILE_SKP = 'SKP_VERSION'
19
20
21 def download_dir(skia_dir, tmp_dir, version_file, gs_path_tmpl, dst_dir):
22 # Ensure that the tmp_dir exists.
23 if not os.path.isdir(tmp_dir):
24 os.makedirs(tmp_dir)
25
26 # Get the expected version.
27 with open(os.path.join(skia_dir, version_file)) as f:
28 expected_version = f.read().rstrip()
29
30 print 'Expected %s = %s' % (version_file, expected_version)
31
32 # Get the actually-downloaded version, if we have one.
33 actual_version_file = os.path.join(tmp_dir, version_file)
34 try:
35 with open(actual_version_file) as f:
36 actual_version = f.read().rstrip()
37 except IOError:
38 actual_version = -1
39
40 print 'Actual %s = %s' % (version_file, actual_version)
41
42 # If we don't have the desired version, download it.
43 if actual_version != expected_version:
44 if actual_version != -1:
45 os.remove(actual_version_file)
46 if os.path.isdir(dst_dir):
47 shutil.rmtree(dst_dir)
48 os.makedirs(dst_dir)
49 gs_path = 'gs://%s/%s/*' % (GS_GM_BUCKET, gs_path_tmpl % expected_version)
50 print 'Downloading from %s' % gs_path
51 subprocess.check_call(['gsutil', 'cp', '-R', gs_path, dst_dir])
52 with open(actual_version_file, 'w') as f:
53 f.write(expected_version)
OLDNEW
« no previous file with comments | « infra/bots/assets/skp/upload.py ('k') | infra/bots/download_skps.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698