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

Side by Side Diff: infra/bots/recipe_modules/skia/resources/upload_dm_results.py

Issue 2198173002: Re-organize Skia recipes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix missing dependency Created 4 years, 4 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
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2014 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 DM output PNG files and JSON summary to Google Storage."""
7
8 import datetime
9 import json
10 import os
11 import shutil
12 import sys
13 import tempfile
14
15 def main(dm_dir, git_hash, builder_name, build_number, try_issue, import_path):
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 git_hash: this build's Git hash (str)
20 builder_name: name of this builder (str)
21 build_number: nth build on this builder (str or int)
22 try_issue: Rietveld issue if this is a try job (str, int, or None)
23 import_path: Path to import the gs_utils package (str)
24 """
25 # import gs_utils
26 sys.path.insert(0, import_path)
27 import gs_utils
28
29 # Private, but Google-readable.
30 ACL = gs_utils.GSUtils.PredefinedACL.PRIVATE
31 FINE_ACLS = [(
32 gs_utils.GSUtils.IdType.GROUP_BY_DOMAIN,
33 'google.com',
34 gs_utils.GSUtils.Permission.READ
35 )]
36
37 # Move dm.json and verbose.log to their own directory for easy upload.
38 tmp = tempfile.mkdtemp()
39 shutil.move(os.path.join(dm_dir, 'dm.json'),
40 os.path.join(tmp, 'dm.json'))
41 shutil.move(os.path.join(dm_dir, 'verbose.log'),
42 os.path.join(tmp, 'verbose.log'))
43
44 # Make sure the JSON file parses correctly.
45 json_file_name = os.path.join(tmp, 'dm.json')
46 with open(json_file_name) as jsonFile:
47 try:
48 json.load(jsonFile)
49 except ValueError:
50 json_content = open(json_file_name).read()
51 print >> sys.stderr, "Invalid JSON: \n\n%s\n" % json_content
52 raise
53
54 # Only images are left in dm_dir. Upload any new ones.
55 gs = gs_utils.GSUtils()
56 bucket, image_dest_dir = 'chromium-skia-gm', 'dm-images-v1'
57 print 'Uploading images to gs://' + bucket + '/' + image_dest_dir
58 gs.upload_dir_contents(dm_dir,
59 bucket,
60 image_dest_dir,
61 upload_if = gs.UploadIf.ALWAYS,
62 predefined_acl = ACL,
63 fine_grained_acl_list = FINE_ACLS)
64
65
66 # /dm-json-v1/year/month/day/hour/git-hash/builder/build-number/dm.json
67 now = datetime.datetime.utcnow()
68 summary_dest_dir = '/'.join(['dm-json-v1',
69 str(now.year ).zfill(4),
70 str(now.month).zfill(2),
71 str(now.day ).zfill(2),
72 str(now.hour ).zfill(2),
73 git_hash,
74 builder_name,
75 str(build_number)])
76
77 # Trybot results are further siloed by CL.
78 if try_issue:
79 summary_dest_dir = '/'.join(['trybot', summary_dest_dir, str(try_issue)])
80
81 # Upload the JSON summary and verbose.log.
82 print 'Uploading logs to gs://' + bucket + '/' + summary_dest_dir
83 gs.upload_dir_contents(tmp,
84 bucket,
85 summary_dest_dir,
86 predefined_acl = ACL,
87 fine_grained_acl_list = FINE_ACLS)
88
89
90 # Just for hygiene, put dm.json and verbose.log back.
91 shutil.move(os.path.join(tmp, 'dm.json'),
92 os.path.join(dm_dir, 'dm.json'))
93 shutil.move(os.path.join(tmp, 'verbose.log'),
94 os.path.join(dm_dir, 'verbose.log'))
95 os.rmdir(tmp)
96
97 if '__main__' == __name__:
98 main(*sys.argv[1:])
OLDNEW
« no previous file with comments | « infra/bots/recipe_modules/skia/resources/upload_bench_results.py ('k') | infra/bots/recipe_modules/skia/ssh_devices.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698