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

Unified Diff: slave/skia_slave_scripts/utils/gs_utils.py

Issue 405653004: add ACL-setting code to upload_rendered_skps.py (Closed) Base URL: https://skia.googlesource.com/buildbot.git@master
Patch Set: created local gs_utils wrapper module Created 6 years, 5 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 | « slave/skia_slave_scripts/upload_skimage_results.py ('k') | slave/skia_slave_scripts/webpages_playback.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: slave/skia_slave_scripts/utils/gs_utils.py
diff --git a/slave/skia_slave_scripts/utils/gs_utils.py b/slave/skia_slave_scripts/utils/gs_utils.py
new file mode 100644
index 0000000000000000000000000000000000000000..dcd156b3f74b908d9f88aa0e4aab806c8c2f950c
--- /dev/null
+++ b/slave/skia_slave_scripts/utils/gs_utils.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+# Copyright (c) 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.
+
+"""Wrapper around common repo's gs_utils.py with buildbot-specific overrides."""
+
+# System-level imports
+import os
+import sys
+
+# Make sure the "common" repo is in PYTHON_PATH
+_BUILDBOT_PATH = os.path.realpath(os.path.join(
+ os.path.dirname(os.path.abspath(__file__)),
+ os.pardir, os.pardir, os.pardir))
+_COMMON_REPO_PATH = os.path.join(_BUILDBOT_PATH, 'common')
+if not _COMMON_REPO_PATH in sys.path:
+ sys.path.insert(0, _COMMON_REPO_PATH)
borenet 2014/07/21 20:22:28 Doesn't fix_pythonpath take care of this?
epoger 2014/07/21 20:26:51 What fix_pythonpath? As far as I know, there's no
borenet 2014/07/21 20:31:31 Yep, I see that now. I added one to skia/tools, b
+
+# Local imports
+from py.utils import gs_utils as superclass_module
+
+_DEFAULT_BOTO_FILE_PATH = os.path.join(
+ _BUILDBOT_PATH, 'third_party', 'chromium_buildbot', 'site_config', '.boto')
+_GS_PREFIX = 'gs://'
+
+
+class GSUtils(superclass_module.GSUtils):
+ """Wrapper around common repo's GSUtils with buildbot-specific overrides."""
+
+ # The ACLs to use while copying playback (SKP) files to Google Storage.
+ # They should not be world-readable!
+ #
+ # TODO(rmistry): Change "playback" variable names to something that makes more
+ # sense to Eric.
+ PLAYBACK_CANNED_ACL = superclass_module.GSUtils.PredefinedACL.PRIVATE
+ PLAYBACK_FINEGRAINED_ACL_LIST = [
+ (superclass_module.GSUtils.IdType.GROUP_BY_DOMAIN, 'google.com',
+ superclass_module.GSUtils.Permission.READ),
+ ]
+
+ def __init__(self, boto_file_path=_DEFAULT_BOTO_FILE_PATH):
+ """Override constructor to use buildbot credentials by default."""
+ super(GSUtils, self).__init__(boto_file_path=boto_file_path)
+
+ @staticmethod
+ def with_gs_prefix(bucket_name):
+ """Returns the bucket_name with _GS_PREFIX at the front.
+
+ If _GS_PREFIX is already there, returns bucket_name as is.
+
+ Examples:
+ bucket1 -> gs://bucket1
+ gs://bucket2 -> gs://bucket2
+ """
+ if bucket_name.startswith(_GS_PREFIX):
+ return bucket_name
+ else:
+ return _GS_PREFIX + str(bucket_name)
+
+ @staticmethod
+ def without_gs_prefix(bucket_name):
+ """Returns the bucket_name without _GS_PREFIX at the front.
+
+ If bucket_name does not start with _GS_PREFIX, returns bucket_name as is.
+
+ Examples:
+ bucket1 -> bucket1
+ gs://bucket2 -> bucket2
+ """
+ if bucket_name.startswith(_GS_PREFIX):
+ return bucket_name[len(_GS_PREFIX):]
+ else:
+ return bucket_name
« no previous file with comments | « slave/skia_slave_scripts/upload_skimage_results.py ('k') | slave/skia_slave_scripts/webpages_playback.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698