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

Side by Side Diff: infra/bots/assets/asset_utils.py

Issue 2351033004: Fix Win toolchain asset, fix script (Closed)
Patch Set: Fix Created 4 years, 3 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 | infra/bots/assets/win_toolchain/VERSION » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2016 Google Inc. 3 # Copyright 2016 Google Inc.
4 # 4 #
5 # Use of this source code is governed by a BSD-style license that can be 5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file. 6 # found in the LICENSE file.
7 7
8 8
9 """Utilities for managing assets.""" 9 """Utilities for managing assets."""
10 10
(...skipping 20 matching lines...) Expand all
31 DEFAULT_CIPD_SERVICE_URL = 'https://chrome-infra-packages.appspot.com' 31 DEFAULT_CIPD_SERVICE_URL = 'https://chrome-infra-packages.appspot.com'
32 32
33 DEFAULT_GS_BUCKET = 'skia-buildbots' 33 DEFAULT_GS_BUCKET = 'skia-buildbots'
34 GS_SUBDIR_TMPL = 'gs://%s/assets/%s' 34 GS_SUBDIR_TMPL = 'gs://%s/assets/%s'
35 GS_PATH_TMPL = '%s/%s.zip' 35 GS_PATH_TMPL = '%s/%s.zip'
36 36
37 TAG_PROJECT_SKIA = 'project:skia' 37 TAG_PROJECT_SKIA = 'project:skia'
38 TAG_VERSION_PREFIX = 'version:' 38 TAG_VERSION_PREFIX = 'version:'
39 TAG_VERSION_TMPL = '%s%%s' % TAG_VERSION_PREFIX 39 TAG_VERSION_TMPL = '%s%%s' % TAG_VERSION_PREFIX
40 40
41 WHICH = 'where' if sys.platform.startswith('win') else 'which'
42
41 VERSION_FILENAME = 'VERSION' 43 VERSION_FILENAME = 'VERSION'
42 ZIP_BLACKLIST = ['.git', '.svn', '*.pyc', '.DS_STORE'] 44 ZIP_BLACKLIST = ['.git', '.svn', '*.pyc', '.DS_STORE']
43 45
44 46
45 class CIPDStore(object): 47 class CIPDStore(object):
46 """Wrapper object for CIPD.""" 48 """Wrapper object for CIPD."""
47 def __init__(self, cipd_url=DEFAULT_CIPD_SERVICE_URL): 49 def __init__(self, cipd_url=DEFAULT_CIPD_SERVICE_URL):
48 cipd = 'cipd' 50 cipd = 'cipd'
49 platform = 'linux64' 51 platform = 'linux64'
50 if sys.platform == 'darwin': 52 if sys.platform == 'darwin':
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 ]) 141 ])
140 142
141 def delete_contents(self, name): 143 def delete_contents(self, name):
142 """Delete data for the given asset.""" 144 """Delete data for the given asset."""
143 self._run(['pkg-delete', CIPD_PACKAGE_NAME_TMPL % name]) 145 self._run(['pkg-delete', CIPD_PACKAGE_NAME_TMPL % name])
144 146
145 147
146 class GSStore(object): 148 class GSStore(object):
147 """Wrapper object for interacting with Google Storage.""" 149 """Wrapper object for interacting with Google Storage."""
148 def __init__(self, gsutil=None, bucket=DEFAULT_GS_BUCKET): 150 def __init__(self, gsutil=None, bucket=DEFAULT_GS_BUCKET):
149 gsutil = os.path.abspath(gsutil) if gsutil else 'gsutil' 151 if gsutil:
152 gsutil = os.path.abspath(gsutil)
153 else:
154 gsutil = subprocess.check_output([WHICH, 'gsutil']).rstrip()
150 self._gsutil = [gsutil] 155 self._gsutil = [gsutil]
151 if gsutil.endswith('.py'): 156 if gsutil.endswith('.py'):
152 self._gsutil = ['python', gsutil] 157 self._gsutil = ['python', gsutil]
153 self._gs_bucket = bucket 158 self._gs_bucket = bucket
154 159
155 def copy(self, src, dst): 160 def copy(self, src, dst):
156 """Copy src to dst.""" 161 """Copy src to dst."""
157 subprocess.check_call(self._gsutil + ['cp', src, dst]) 162 subprocess.check_call(self._gsutil + ['cp', src, dst])
158 163
159 def list(self, path): 164 def list(self, path):
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 raise Exception('Asset %s does not exist!' % self._name) 328 raise Exception('Asset %s does not exist!' % self._name)
324 329
325 # Cleanup the store. 330 # Cleanup the store.
326 if remove_in_store: 331 if remove_in_store:
327 self._store.delete_contents(self._name) 332 self._store.delete_contents(self._name)
328 333
329 # Remove the asset. 334 # Remove the asset.
330 subprocess.check_call([utils.GIT, 'rm', '-rf', self._dir]) 335 subprocess.check_call([utils.GIT, 'rm', '-rf', self._dir])
331 if os.path.isdir(self._dir): 336 if os.path.isdir(self._dir):
332 shutil.rmtree(self._dir) 337 shutil.rmtree(self._dir)
OLDNEW
« no previous file with comments | « no previous file | infra/bots/assets/win_toolchain/VERSION » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698