15def main(dm_dir, build_number, builder_name):
16 """Upload DM output PNG files and JSON summary to Google Storage.
17
18 dm_dir: path to PNG files and JSON summary (str)
19 build_number: nth build on this builder (str or int)
20 builder_name: name of this builder (str)
21 """
22
23 current_dir = os.path.dirname(os.path.abspath(__file__))
24 sys.path.insert(0, os.path.join(current_dir, "../../../common/py/utils"))
25 import gs_utils
26
27
28 ACL = gs_utils.GSUtils.PredefinedACL.PRIVATE
29 FINE_ACLS = [(
30 gs_utils.GSUtils.IdType.GROUP_BY_DOMAIN,
31 'google.com',
32 gs_utils.GSUtils.Permission.READ
33 )]
34
35 if not os.path.isfile(os.path.join(dm_dir, 'dm.json')):
36 sys.exit("no dm.json file found in output directory.")
37
38
39 tmp = tempfile.mkdtemp()
40 shutil.move(os.path.join(dm_dir, 'dm.json'),
41 os.path.join(tmp, 'dm.json'))
42
43
44 gs = gs_utils.GSUtils()
45 gs.upload_dir_contents(dm_dir,
46 'skia-android-dm',
47 'dm-images-v1',
48 upload_if = gs.UploadIf.IF_NEW,
49 predefined_acl = ACL,
50 fine_grained_acl_list = FINE_ACLS)
51
52
53
54 now = datetime.datetime.utcnow()
55 summary_dest_dir =
'/'.
join([
'dm-json-v1',
56 str(now.year ).zfill(4),
57 str(now.month).zfill(2),
58 str(now.day ).zfill(2),
59 str(now.hour ).zfill(2),
60 str(build_number),
61 builder_name])
62
63
64 gs.upload_dir_contents(tmp,
65 'skia-android-dm',
66 summary_dest_dir,
67 predefined_acl = ACL,
68 fine_grained_acl_list = FINE_ACLS)
69
70
71
72 shutil.move(os.path.join(tmp, 'dm.json'),
73 os.path.join(dm_dir, 'dm.json'))
74 os.rmdir(tmp)
75
def main(dm_dir, build_number, builder_name)
static SkString join(const CommandLineFlags::StringArray &)