OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 """Upload results from running skimage.""" | |
7 | |
8 import build_step | |
9 import os | |
10 import posixpath | |
11 # Must be imported after build_step, which adds site_config to the python path. | |
12 import skia_vars | |
13 import sys | |
14 | |
15 from utils import gs_utils | |
16 from utils import old_gs_utils | |
17 from utils import sync_bucket_subdir | |
18 from build_step import BuildStep | |
19 | |
20 SKP_TIMEOUT_MULTIPLIER = 8 | |
21 | |
22 class UploadSKImageResults(BuildStep): | |
23 | |
24 def __init__( | |
25 self, | |
26 timeout=build_step.DEFAULT_TIMEOUT * SKP_TIMEOUT_MULTIPLIER, | |
27 no_output_timeout=( | |
28 build_step.DEFAULT_NO_OUTPUT_TIMEOUT * SKP_TIMEOUT_MULTIPLIER), | |
29 **kwargs): | |
30 """Constructs an UploadSKImageResults BuildStep instance. | |
31 | |
32 timeout: maximum time allowed for this BuildStep. The default value here is | |
33 increased because there could be a lot of images | |
34 to be copied over to Google Storage. | |
35 no_output_timeout: maximum time allowed for this BuildStep to run without | |
36 any output. | |
37 """ | |
38 build_step.BuildStep.__init__(self, timeout=timeout, | |
39 no_output_timeout=no_output_timeout, | |
40 **kwargs) | |
41 | |
42 self._dest_gsbase = (self._args.get('dest_gsbase') or | |
43 sync_bucket_subdir.DEFAULT_PERFDATA_GS_BASE) | |
44 | |
45 def _Run(self): | |
46 # Copy actual-results.json to skimage/actuals | |
47 print '\n\n====Uploading skimage actual-results to Google Storage====\n\n' | |
48 src_dir = os.path.abspath(os.path.join(self._skimage_out_dir, | |
49 self._builder_name)) | |
50 bucket_url = gs_utils.GSUtils.with_gs_prefix( | |
51 skia_vars.GetGlobalVariable('googlestorage_bucket')) | |
52 dest_dir = posixpath.join( | |
53 bucket_url, 'skimage', 'actuals', self._builder_name) | |
54 http_header_lines = ['Cache-Control:public,max-age=3600'] | |
55 old_gs_utils.upload_dir_contents(local_src_dir=src_dir, | |
56 remote_dest_dir=dest_dir, | |
57 gs_acl='public-read', | |
58 http_header_lines=http_header_lines) | |
59 | |
60 # Copy actual images to Google Storage at skimage/output. This will merge | |
61 # with the existing files. | |
62 print '\n\n========Uploading skimage results to Google Storage=======\n\n' | |
63 src_dir = os.path.abspath(os.path.join(self._skimage_out_dir, 'images')) | |
64 dest_dir = posixpath.join( | |
65 bucket_url, 'skimage', 'output', 'images') | |
66 if os.path.isdir(src_dir) and os.listdir(src_dir): | |
67 old_gs_utils.upload_dir_contents( | |
68 local_src_dir=src_dir, remote_dest_dir=dest_dir, | |
69 gs_acl=gs_utils.GSUtils.PLAYBACK_CANNED_ACL) | |
70 | |
71 if '__main__' == __name__: | |
72 sys.exit(BuildStep.RunBuildStep(UploadSKImageResults)) | |
OLD | NEW |