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

Side by Side Diff: platform_tools/android/tradefed/upload_dm_results.py

Issue 979153002: Add custom dm upload script to be used by the android framework (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
borenet 2015/03/05 15:48:47 Nit: 2 lines between top-level items.
djsollen 2015/03/05 15:52:26 Done.
8 import datetime
9 import os
10 import shutil
11 import sys
12 import tempfile
13
14 def main(dm_dir, build_number, builder_name):
15 """Upload DM output PNG files and JSON summary to Google Storage.
16
17 dm_dir: path to PNG files and JSON summary (str)
18 build_number: nth build on this builder (str or int)
19 builder_name: name of this builder (str)
20 """
21 # import gs_utils
22 current_dir = os.path.dirname(os.path.abspath(__file__))
23 sys.path.insert(0, os.path.join(current_dir, "../../../common/py/utils"))
24 import gs_utils
25
26 # Private, but Google-readable.
27 ACL = gs_utils.GSUtils.PredefinedACL.PRIVATE
28 FINE_ACLS = [(
29 gs_utils.GSUtils.IdType.GROUP_BY_DOMAIN,
30 'google.com',
31 gs_utils.GSUtils.Permission.READ
32 )]
33
34 # Move dm.json to its own directory to make uploading it easier.
35 tmp = tempfile.mkdtemp()
36 shutil.move(os.path.join(dm_dir, 'dm.json'),
37 os.path.join(tmp, 'dm.json'))
38
39 # Only images are left in dm_dir. Upload any new ones.
40 gs = gs_utils.GSUtils()
41 gs.upload_dir_contents(dm_dir,
42 'skia-android-dm',
43 'dm-images-v1',
44 upload_if = gs.UploadIf.IF_NEW,
45 predefined_acl = ACL,
46 fine_grained_acl_list = FINE_ACLS)
47
48
49 # /dm-json-v1/year/month/day/hour/git-hash/builder/build-number/dm.json
borenet 2015/03/05 15:48:47 This is not accurate. Why aren't we using the com
djsollen 2015/03/05 15:52:26 Updated the comment. Also we don't need the git h
borenet 2015/03/05 15:53:56 Ok.
50 now = datetime.datetime.utcnow()
51 summary_dest_dir = '/'.join(['dm-json-v1',
52 str(now.year ).zfill(4),
53 str(now.month).zfill(2),
54 str(now.day ).zfill(2),
55 str(now.hour ).zfill(2),
56 str(build_number),
57 builder_name])
58
59 # Upload the JSON summary.
60 gs.upload_dir_contents(tmp,
61 'skia-android-dm',
62 summary_dest_dir,
63 predefined_acl = ACL,
64 fine_grained_acl_list = FINE_ACLS)
65
66
67 # Just for hygiene, put dm.json back.
68 shutil.move(os.path.join(tmp, 'dm.json'),
69 os.path.join(dm_dir, 'dm.json'))
70 os.rmdir(tmp)
71
72 if '__main__' == __name__:
73 main(*sys.argv[1:])
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698