OLD | NEW |
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 |
11 | 11 |
12 import argparse | 12 import argparse |
13 import os | 13 import os |
14 import shlex | 14 import shlex |
15 import shutil | 15 import shutil |
16 import subprocess | 16 import subprocess |
17 import sys | 17 import sys |
18 | 18 |
19 SKIA_DIR = os.path.abspath(os.path.realpath(os.path.join( | 19 INFRA_BOTS_DIR = os.path.abspath(os.path.realpath(os.path.join( |
20 os.path.dirname(os.path.abspath(__file__)), | 20 os.path.dirname(os.path.abspath(__file__)), os.pardir))) |
21 os.pardir, os.pardir, os.pardir))) | |
22 INFRA_BOTS_DIR = os.path.join(SKIA_DIR, 'infra', 'bots') | |
23 sys.path.insert(0, INFRA_BOTS_DIR) | 21 sys.path.insert(0, INFRA_BOTS_DIR) |
24 import utils | 22 import utils |
25 import zip_utils | 23 import zip_utils |
26 | 24 |
27 | 25 |
28 ASSETS_DIR = os.path.join(INFRA_BOTS_DIR, 'assets') | 26 ASSETS_DIR = os.path.join(INFRA_BOTS_DIR, 'assets') |
29 DEFAULT_GS_BUCKET = 'skia-buildbots' | 27 DEFAULT_GS_BUCKET = 'skia-buildbots' |
30 GS_SUBDIR_TMPL = 'gs://%s/assets/%s' | 28 GS_SUBDIR_TMPL = 'gs://%s/assets/%s' |
31 GS_PATH_TMPL = '%s/%s.zip' | 29 GS_PATH_TMPL = '%s/%s.zip' |
| 30 SKIA_DIR = os.path.abspath(os.path.join(INFRA_BOTS_DIR, os.pardir, os.pardir)) |
32 VERSION_FILENAME = 'VERSION' | 31 VERSION_FILENAME = 'VERSION' |
33 ZIP_BLACKLIST = ['.git', '.svn', '*.pyc', '.DS_STORE'] | 32 ZIP_BLACKLIST = ['.git', '.svn', '*.pyc', '.DS_STORE'] |
34 | 33 |
35 | 34 |
36 class _GSWrapper(object): | 35 class _GSWrapper(object): |
37 """Wrapper object for interacting with Google Storage.""" | 36 """Wrapper object for interacting with Google Storage.""" |
38 def __init__(self, gsutil): | 37 def __init__(self, gsutil): |
39 gsutil = os.path.abspath(gsutil) if gsutil else 'gsutil' | 38 gsutil = os.path.abspath(gsutil) if gsutil else 'gsutil' |
40 self._gsutil = [gsutil] | 39 self._gsutil = [gsutil] |
41 if gsutil.endswith('.py'): | 40 if gsutil.endswith('.py'): |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 if not os.path.isdir(self._dir): | 164 if not os.path.isdir(self._dir): |
166 raise Exception('Asset %s does not exist!' % self._name) | 165 raise Exception('Asset %s does not exist!' % self._name) |
167 | 166 |
168 # Remove the asset. | 167 # Remove the asset. |
169 subprocess.check_call([utils.GIT, 'rm', '-rf', self._dir]) | 168 subprocess.check_call([utils.GIT, 'rm', '-rf', self._dir]) |
170 if os.path.isdir(self._dir): | 169 if os.path.isdir(self._dir): |
171 shutil.rmtree(self._dir) | 170 shutil.rmtree(self._dir) |
172 | 171 |
173 # We *could* remove all uploaded versions of the asset in Google Storage but | 172 # We *could* remove all uploaded versions of the asset in Google Storage but |
174 # we choose not to be that destructive. | 173 # we choose not to be that destructive. |
OLD | NEW |