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

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
8
9 import datetime
10 import os
11 import shutil
12 import sys
13 import tempfile
14
15 def 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 # import gs_utils
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 # Private, but Google-readable.
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 # Move dm.json to its own directory to make uploading it easier.
36 tmp = tempfile.mkdtemp()
37 shutil.move(os.path.join(dm_dir, 'dm.json'),
38 os.path.join(tmp, 'dm.json'))
39
40 # Only images are left in dm_dir. Upload any new ones.
41 gs = gs_utils.GSUtils()
42 gs.upload_dir_contents(dm_dir,
43 'skia-android-dm',
44 'dm-images-v1',
45 upload_if = gs.UploadIf.IF_NEW,
46 predefined_acl = ACL,
47 fine_grained_acl_list = FINE_ACLS)
48
49
50 # /dm-json-v1/year/month/day/hour/build-number/builder/dm.json
51 now = datetime.datetime.utcnow()
52 summary_dest_dir = '/'.join(['dm-json-v1',
53 str(now.year ).zfill(4),
54 str(now.month).zfill(2),
55 str(now.day ).zfill(2),
56 str(now.hour ).zfill(2),
57 str(build_number),
58 builder_name])
59
60 # Upload the JSON summary.
61 gs.upload_dir_contents(tmp,
62 'skia-android-dm',
63 summary_dest_dir,
64 predefined_acl = ACL,
65 fine_grained_acl_list = FINE_ACLS)
66
67
68 # Just for hygiene, put dm.json back.
69 shutil.move(os.path.join(tmp, 'dm.json'),
70 os.path.join(dm_dir, 'dm.json'))
71 os.rmdir(tmp)
72
73 if '__main__' == __name__:
74 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