6"""Upload DM output PNG files and JSON summary to Google Storage."""
15def main(dm_dir, build_number, builder_name):
16 """Upload DM output PNG files and JSON summary to Google Storage.
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)
23 current_dir = os.path.dirname(os.path.abspath(__file__))
24 sys.path.insert(0, os.path.join(current_dir,
"../../../common/py/utils"))
28 ACL = gs_utils.GSUtils.PredefinedACL.PRIVATE
30 gs_utils.GSUtils.IdType.GROUP_BY_DOMAIN,
32 gs_utils.GSUtils.Permission.READ
35 if not os.path.isfile(os.path.join(dm_dir,
'dm.json')):
36 sys.exit(
"no dm.json file found in output directory.")
39 tmp = tempfile.mkdtemp()
40 shutil.move(os.path.join(dm_dir,
'dm.json'),
41 os.path.join(tmp,
'dm.json'))
44 gs = gs_utils.GSUtils()
45 gs.upload_dir_contents(dm_dir,
48 upload_if = gs.UploadIf.IF_NEW,
50 fine_grained_acl_list = FINE_ACLS)
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),
64 gs.upload_dir_contents(tmp,
68 fine_grained_acl_list = FINE_ACLS)
72 shutil.move(os.path.join(tmp,
'dm.json'),
73 os.path.join(dm_dir,
'dm.json'))
76if '__main__' == __name__:
def main(dm_dir, build_number, builder_name)
static SkString join(const CommandLineFlags::StringArray &)