| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import re | 5 import re |
| 6 | 6 |
| 7 from recipe_engine import recipe_api | 7 from recipe_engine import recipe_api |
| 8 | 8 |
| 9 class GSUtilApi(recipe_api.RecipeApi): | 9 class GSUtilApi(recipe_api.RecipeApi): |
| 10 def __call__(self, cmd, name=None, use_retry_wrapper=True, version=None, | 10 def __call__(self, cmd, name=None, use_retry_wrapper=True, version=None, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 Arguments: | 21 Arguments: |
| 22 cmd: list of (string) arguments to pass to gsutil. | 22 cmd: list of (string) arguments to pass to gsutil. |
| 23 Include gsutil-level options first (see 'gsutil help options'). | 23 Include gsutil-level options first (see 'gsutil help options'). |
| 24 name: the (string) name of the step to use. | 24 name: the (string) name of the step to use. |
| 25 Defaults to the first non-flag token in the cmd. | 25 Defaults to the first non-flag token in the cmd. |
| 26 """ | 26 """ |
| 27 if not name: | 27 if not name: |
| 28 name = (t for t in cmd if not t.startswith('-')).next() | 28 name = (t for t in cmd if not t.startswith('-')).next() |
| 29 full_name = 'gsutil ' + name | 29 full_name = 'gsutil ' + name |
| 30 | 30 |
| 31 gsutil_path = self.m.infra_paths['depot_tools'].join('gsutil.py') | 31 gsutil_path = self.m.path['depot_tools'].join('gsutil.py') |
| 32 cmd_prefix = [] | 32 cmd_prefix = [] |
| 33 | 33 |
| 34 if use_retry_wrapper: | 34 if use_retry_wrapper: |
| 35 # We pass the real gsutil_path to the wrapper so it doesn't have to do | 35 # We pass the real gsutil_path to the wrapper so it doesn't have to do |
| 36 # brittle path logic. | 36 # brittle path logic. |
| 37 cmd_prefix = ['--', gsutil_path] | 37 cmd_prefix = ['--', gsutil_path] |
| 38 gsutil_path = self.resource('gsutil_wrapper.py') | 38 gsutil_path = self.resource('gsutil_wrapper.py') |
| 39 | 39 |
| 40 if version: | 40 if version: |
| 41 cmd_prefix.extend(['--force-version', version]) | 41 cmd_prefix.extend(['--force-version', version]) |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 gsutil_download_path = self.package_repo_resource( | 145 gsutil_download_path = self.package_repo_resource( |
| 146 'scripts', 'slave', 'gsutil_download.py') | 146 'scripts', 'slave', 'gsutil_download.py') |
| 147 args = ['--poll', | 147 args = ['--poll', |
| 148 '--url', url, | 148 '--url', url, |
| 149 '--dst', destination, | 149 '--dst', destination, |
| 150 '--poll-interval', str(poll_interval), | 150 '--poll-interval', str(poll_interval), |
| 151 '--timeout', str(timeout)] | 151 '--timeout', str(timeout)] |
| 152 return self.m.python(name, | 152 return self.m.python(name, |
| 153 gsutil_download_path, | 153 gsutil_download_path, |
| 154 args, | 154 args, |
| 155 cwd=self.m.infra_paths['slave_build']) | 155 cwd=self.m.path['slave_build']) |
| 156 | 156 |
| 157 def _generate_metadata_args(self, metadata): | 157 def _generate_metadata_args(self, metadata): |
| 158 result = [] | 158 result = [] |
| 159 if metadata: | 159 if metadata: |
| 160 for k, v in sorted(metadata.iteritems(), key=lambda (k, _): k): | 160 for k, v in sorted(metadata.iteritems(), key=lambda (k, _): k): |
| 161 field = self._get_metadata_field(k) | 161 field = self._get_metadata_field(k) |
| 162 param = (field) if v is None else ('%s:%s' % (field, v)) | 162 param = (field) if v is None else ('%s:%s' % (field, v)) |
| 163 result += ['-h', param] | 163 result += ['-h', param] |
| 164 return result | 164 return result |
| 165 | 165 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 'Content-Language', | 202 'Content-Language', |
| 203 'Content-MD5', | 203 'Content-MD5', |
| 204 'Content-Type', | 204 'Content-Type', |
| 205 ): | 205 ): |
| 206 return name | 206 return name |
| 207 | 207 |
| 208 # Add provider prefix | 208 # Add provider prefix |
| 209 if not provider_prefix: | 209 if not provider_prefix: |
| 210 provider_prefix = 'x-goog-meta' | 210 provider_prefix = 'x-goog-meta' |
| 211 return '%s-%s' % (provider_prefix, name) | 211 return '%s-%s' % (provider_prefix, name) |
| OLD | NEW |