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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: platform_tools/android/tradefed/upload_dm_results.py
diff --git a/platform_tools/android/tradefed/upload_dm_results.py b/platform_tools/android/tradefed/upload_dm_results.py
new file mode 100755
index 0000000000000000000000000000000000000000..9aac4075808240f6a1af91588e824e413fb16242
--- /dev/null
+++ b/platform_tools/android/tradefed/upload_dm_results.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Upload DM output PNG files and JSON summary to Google Storage."""
+
+
+import datetime
+import os
+import shutil
+import sys
+import tempfile
+
+def main(dm_dir, build_number, builder_name):
+ """Upload DM output PNG files and JSON summary to Google Storage.
+
+ dm_dir: path to PNG files and JSON summary (str)
+ build_number: nth build on this builder (str or int)
+ builder_name: name of this builder (str)
+ """
+ # import gs_utils
+ current_dir = os.path.dirname(os.path.abspath(__file__))
+ sys.path.insert(0, os.path.join(current_dir, "../../../common/py/utils"))
+ import gs_utils
+
+ # Private, but Google-readable.
+ ACL = gs_utils.GSUtils.PredefinedACL.PRIVATE
+ FINE_ACLS = [(
+ gs_utils.GSUtils.IdType.GROUP_BY_DOMAIN,
+ 'google.com',
+ gs_utils.GSUtils.Permission.READ
+ )]
+
+ # Move dm.json to its own directory to make uploading it easier.
+ tmp = tempfile.mkdtemp()
+ shutil.move(os.path.join(dm_dir, 'dm.json'),
+ os.path.join(tmp, 'dm.json'))
+
+ # Only images are left in dm_dir. Upload any new ones.
+ gs = gs_utils.GSUtils()
+ gs.upload_dir_contents(dm_dir,
+ 'skia-android-dm',
+ 'dm-images-v1',
+ upload_if = gs.UploadIf.IF_NEW,
+ predefined_acl = ACL,
+ fine_grained_acl_list = FINE_ACLS)
+
+
+ # /dm-json-v1/year/month/day/hour/build-number/builder/dm.json
+ now = datetime.datetime.utcnow()
+ summary_dest_dir = '/'.join(['dm-json-v1',
+ str(now.year ).zfill(4),
+ str(now.month).zfill(2),
+ str(now.day ).zfill(2),
+ str(now.hour ).zfill(2),
+ str(build_number),
+ builder_name])
+
+ # Upload the JSON summary.
+ gs.upload_dir_contents(tmp,
+ 'skia-android-dm',
+ summary_dest_dir,
+ predefined_acl = ACL,
+ fine_grained_acl_list = FINE_ACLS)
+
+
+ # Just for hygiene, put dm.json back.
+ shutil.move(os.path.join(tmp, 'dm.json'),
+ os.path.join(dm_dir, 'dm.json'))
+ os.rmdir(tmp)
+
+if '__main__' == __name__:
+ main(*sys.argv[1:])
« 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