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

Side by Side Diff: slave/skia_slave_scripts/upload_rendered_skps.py

Issue 405653004: add ACL-setting code to upload_rendered_skps.py (Closed) Base URL: https://skia.googlesource.com/buildbot.git@master
Patch Set: add comment Created 6 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Uploads the results of render_skps.py.""" 6 """Uploads the results of render_skps.py."""
7 7
8 import os 8 import os
9 import posixpath 9 import posixpath
10 import sys 10 import sys
11 11
12 from build_step import BuildStep, PLAYBACK_CANNED_ACL 12 from build_step import BuildStep, BOTO_CREDENTIALS_FILE
13 from utils import old_gs_utils as gs_utils 13 from build_step import PLAYBACK_CANNED_ACL, PLAYBACK_FINEGRAINED_ACL_LIST
14 from py.utils import gs_utils
15 from utils import old_gs_utils
14 import skia_vars 16 import skia_vars
15 17
16 GS_SUMMARIES_BUCKET = 'gs://chromium-skia-skp-summaries' 18 GS_SUMMARIES_BUCKET = 'gs://chromium-skia-skp-summaries'
17 SUBDIR_NAME = 'rendered-skps' 19 SUBDIR_NAME = 'rendered-skps'
18 20
19 21
20 class UploadRenderedSKPs(BuildStep): 22 class UploadRenderedSKPs(BuildStep):
21 23
22 def __init__(self, attempts=3, **kwargs): 24 def __init__(self, attempts=3, **kwargs):
23 super(UploadRenderedSKPs, self).__init__( 25 super(UploadRenderedSKPs, self).__init__(
24 attempts=attempts, **kwargs) 26 attempts=attempts, **kwargs)
25 27
26 def _Run(self): 28 def _Run(self):
27 # Upload individual image files to Google Storage. 29 # Upload individual image files to Google Storage.
28 # 30 #
29 # TODO(epoger): Add a "noclobber" mode to gs_utils.upload_dir_contents() 31 # TODO(epoger): Add a "noclobber" mode to gs_utils.upload_dir_contents()
30 # and use it here so we don't re-upload image files we already have 32 # and use it here so we don't re-upload image files we already have
31 # in Google Storage. 33 # in Google Storage.
32 # 34 #
33 # TODO(epoger): Change ACLs of files uploaded to Google Storage to 35 gs_bucket = skia_vars.GetGlobalVariable('googlestorage_bucket')
epoger 2014/07/18 21:10:25 Actually, I guess now (before we start uploading t
borenet 2014/07/18 22:11:12 Sounds good to me, although I don't know why we ne
epoger 2014/07/21 13:42:51 I don't know either, but hinoka@ asked us to in ht
rmistry 2014/07/21 13:56:52 Since these buckets are created under the c-i-t um
borenet 2014/07/21 14:07:46 Rules is rules I guess.
34 # google.com:READ . See _SetGoogleReadACLs() in 36 if gs_bucket.startswith('gs://'):
35 # https://skia.googlesource.com/buildbot/+/master/slave/skia_slave_scripts/ 37 gs_bucket = gs_bucket[5:]
borenet 2014/07/18 22:11:12 GS_PREFIX = 'gs://' if gs_bucket.startswith(GS_PRE
epoger 2014/07/21 13:42:51 Done.
36 # webpages_playback.py 38 gs = gs_utils.GSUtils(BOTO_CREDENTIALS_FILE)
39
37 src_dir = os.path.abspath(self.playback_actual_images_dir) 40 src_dir = os.path.abspath(self.playback_actual_images_dir)
38 if os.listdir(src_dir): 41 if os.listdir(src_dir):
39 dest_dir = posixpath.join( 42 print 'Uploading image files from %s to bucket=%s, dir=%s' % (
40 skia_vars.GetGlobalVariable('googlestorage_bucket'), SUBDIR_NAME) 43 src_dir, gs_bucket, SUBDIR_NAME)
41 print 'Uploading image files from %s to %s.' % (src_dir, dest_dir) 44 gs.upload_dir_contents(
42 gs_utils.upload_dir_contents( 45 source_dir=src_dir, dest_bucket=gs_bucket, dest_dir=SUBDIR_NAME,
43 local_src_dir=src_dir, remote_dest_dir=dest_dir, 46 predefined_acl=PLAYBACK_CANNED_ACL,
44 gs_acl=PLAYBACK_CANNED_ACL) 47 fine_grained_acl_list=PLAYBACK_FINEGRAINED_ACL_LIST)
45 else: 48 else:
46 print ('No image files in %s, so skipping upload to Google Storage.' % 49 print ('Skipping upload to Google Storage, because no image files in %s' %
47 src_dir) 50 src_dir)
48 51
49 # Upload image summaries (checksums) to Google Storage. 52 # Upload image summaries (checksums) to Google Storage.
50 src_dir = os.path.abspath(self.playback_actual_summaries_dir) 53 src_dir = os.path.abspath(self.playback_actual_summaries_dir)
51 filenames = os.listdir(src_dir) 54 filenames = os.listdir(src_dir)
52 if filenames: 55 if filenames:
53 dest_dir = posixpath.join(GS_SUMMARIES_BUCKET, self._args['builder_name']) 56 dest_dir = posixpath.join(GS_SUMMARIES_BUCKET, self._args['builder_name'])
54 print ('Uploading %d image summaries from %s to %s: %s' % ( 57 print ('Uploading %d image summaries from %s to %s: %s' % (
55 len(filenames), src_dir, dest_dir, filenames)) 58 len(filenames), src_dir, dest_dir, filenames))
56 for filename in filenames: 59 for filename in filenames:
57 src_path = os.path.join(src_dir, filename) 60 src_path = os.path.join(src_dir, filename)
58 dest_path = posixpath.join(dest_dir, filename) 61 dest_path = posixpath.join(dest_dir, filename)
59 gs_utils.upload_file( 62 # It's important to only upload the summary file when it has changed,
63 # because we use the history of the file in Google Storage to tell us
64 # when any of the results changed.
65 #
66 # TODO(epoger): Once gs_utils.upload_file() supports only_if_modified
67 # parameter, start using it, so we can set fine_grained_acl_list like
68 # we do above... we'll need that for google.com users to be able to
69 # download the summary files.
70 old_gs_utils.upload_file(
60 local_src_path=src_path, remote_dest_path=dest_path, 71 local_src_path=src_path, remote_dest_path=dest_path,
61 gs_acl=PLAYBACK_CANNED_ACL, only_if_modified=True) 72 gs_acl=PLAYBACK_CANNED_ACL, only_if_modified=True)
62 else: 73 else:
63 print ('No image summaries in %s, so skipping upload to Google Storage.' % 74 print ('Skipping upload to Google Storage, because no image summaries '
64 src_dir) 75 'in %s' % src_dir)
65 76
66 if '__main__' == __name__: 77 if '__main__' == __name__:
67 sys.exit(BuildStep.RunBuildStep(UploadRenderedSKPs)) 78 sys.exit(BuildStep.RunBuildStep(UploadRenderedSKPs))
OLDNEW
« slave/skia_slave_scripts/build_step.py ('K') | « slave/skia_slave_scripts/build_step.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698