Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 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 """Wrapper around common repo's gs_utils.py with buildbot-specific overrides.""" | |
| 7 | |
| 8 # System-level imports | |
| 9 import os | |
| 10 import sys | |
| 11 | |
| 12 # Make sure the "common" repo is in PYTHON_PATH | |
| 13 _BUILDBOT_PATH = os.path.realpath(os.path.join( | |
| 14 os.path.dirname(os.path.abspath(__file__)), | |
| 15 os.pardir, os.pardir, os.pardir)) | |
| 16 _COMMON_REPO_PATH = os.path.join(_BUILDBOT_PATH, 'common') | |
| 17 if not _COMMON_REPO_PATH in sys.path: | |
| 18 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
| |
| 19 | |
| 20 # Local imports | |
| 21 from py.utils import gs_utils as superclass_module | |
| 22 | |
| 23 _DEFAULT_BOTO_FILE_PATH = os.path.join( | |
| 24 _BUILDBOT_PATH, 'third_party', 'chromium_buildbot', 'site_config', '.boto') | |
| 25 _GS_PREFIX = 'gs://' | |
| 26 | |
| 27 | |
| 28 class GSUtils(superclass_module.GSUtils): | |
| 29 """Wrapper around common repo's GSUtils with buildbot-specific overrides.""" | |
| 30 | |
| 31 # The ACLs to use while copying playback (SKP) files to Google Storage. | |
| 32 # They should not be world-readable! | |
| 33 # | |
| 34 # TODO(rmistry): Change "playback" variable names to something that makes more | |
| 35 # sense to Eric. | |
| 36 PLAYBACK_CANNED_ACL = superclass_module.GSUtils.PredefinedACL.PRIVATE | |
| 37 PLAYBACK_FINEGRAINED_ACL_LIST = [ | |
| 38 (superclass_module.GSUtils.IdType.GROUP_BY_DOMAIN, 'google.com', | |
| 39 superclass_module.GSUtils.Permission.READ), | |
| 40 ] | |
| 41 | |
| 42 def __init__(self, boto_file_path=_DEFAULT_BOTO_FILE_PATH): | |
| 43 """Override constructor to use buildbot credentials by default.""" | |
| 44 super(GSUtils, self).__init__(boto_file_path=boto_file_path) | |
| 45 | |
| 46 @staticmethod | |
| 47 def with_gs_prefix(bucket_name): | |
| 48 """Returns the bucket_name with _GS_PREFIX at the front. | |
| 49 | |
| 50 If _GS_PREFIX is already there, returns bucket_name as is. | |
| 51 | |
| 52 Examples: | |
| 53 bucket1 -> gs://bucket1 | |
| 54 gs://bucket2 -> gs://bucket2 | |
| 55 """ | |
| 56 if bucket_name.startswith(_GS_PREFIX): | |
| 57 return bucket_name | |
| 58 else: | |
| 59 return _GS_PREFIX + str(bucket_name) | |
| 60 | |
| 61 @staticmethod | |
| 62 def without_gs_prefix(bucket_name): | |
| 63 """Returns the bucket_name without _GS_PREFIX at the front. | |
| 64 | |
| 65 If bucket_name does not start with _GS_PREFIX, returns bucket_name as is. | |
| 66 | |
| 67 Examples: | |
| 68 bucket1 -> bucket1 | |
| 69 gs://bucket2 -> bucket2 | |
| 70 """ | |
| 71 if bucket_name.startswith(_GS_PREFIX): | |
| 72 return bucket_name[len(_GS_PREFIX):] | |
| 73 else: | |
| 74 return bucket_name | |
| OLD | NEW |