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 """Tool for managing assets.""" | 9 """Tool for managing assets.""" |
10 | 10 |
11 | 11 |
12 import argparse | 12 import argparse |
13 import asset_utils | 13 import asset_utils |
14 import os | 14 import os |
15 import shutil | 15 import shutil |
16 import subprocess | 16 import subprocess |
17 import sys | 17 import sys |
18 | 18 |
19 FILE_DIR = os.path.dirname(os.path.abspath(__file__)) | 19 FILE_DIR = os.path.dirname(os.path.abspath(__file__)) |
20 INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir)) | 20 INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir)) |
21 | 21 |
22 sys.path.insert(0, INFRA_BOTS_DIR) | 22 sys.path.insert(0, INFRA_BOTS_DIR) |
23 import utils | 23 import utils |
24 | 24 |
25 | 25 |
26 def add(args): | 26 def add(args): |
27 """Add a new asset.""" | 27 """Add a new asset.""" |
28 asset_utils.Asset.add(args.asset_name) | 28 asset_utils.Asset.add(args.asset_name, asset_utils.MultiStore()) |
29 | 29 |
30 | 30 |
31 def remove(args): | 31 def remove(args): |
32 """Remove an asset.""" | 32 """Remove an asset.""" |
33 asset_utils.Asset(args.asset_name).remove() | 33 asset_utils.Asset(args.asset_name, asset_utils.MultiStore()).remove() |
34 | 34 |
35 | 35 |
36 def download(args): | 36 def download(args): |
37 """Download the current version of an asset.""" | 37 """Download the current version of an asset.""" |
38 asset = asset_utils.Asset(args.asset_name, gsutil=args.gsutil) | 38 asset = asset_utils.Asset(args.asset_name, asset_utils.MultiStore()) |
39 asset.download_current_version(args.target_dir) | 39 asset.download_current_version(args.target_dir) |
40 | 40 |
41 | 41 |
42 def upload(args): | 42 def upload(args): |
43 """Upload a new version of the asset.""" | 43 """Upload a new version of the asset.""" |
44 asset = asset_utils.Asset(args.asset_name, gsutil=args.gsutil) | 44 asset = asset_utils.Asset(args.asset_name, asset_utils.MultiStore()) |
45 asset.upload_new_version(args.target_dir, commit=args.commit) | 45 asset.upload_new_version(args.target_dir, commit=args.commit) |
46 | 46 |
47 | 47 |
48 def main(argv): | 48 def main(argv): |
49 parser = argparse.ArgumentParser(description='Tool for managing assets.') | 49 parser = argparse.ArgumentParser(description='Tool for managing assets.') |
50 subs = parser.add_subparsers(help='Commands:') | 50 subs = parser.add_subparsers(help='Commands:') |
51 | 51 |
52 prs_add = subs.add_parser('add', help='Add a new asset.') | 52 prs_add = subs.add_parser('add', help='Add a new asset.') |
53 prs_add.set_defaults(func=add) | 53 prs_add.set_defaults(func=add) |
54 prs_add.add_argument('asset_name', help='Name of the asset.') | 54 prs_add.add_argument('asset_name', help='Name of the asset.') |
(...skipping 16 matching lines...) Expand all Loading... |
71 prs_upload.add_argument('--target_dir', '-t', required=True) | 71 prs_upload.add_argument('--target_dir', '-t', required=True) |
72 prs_upload.add_argument('--gsutil') | 72 prs_upload.add_argument('--gsutil') |
73 prs_upload.add_argument('--commit', action='store_true') | 73 prs_upload.add_argument('--commit', action='store_true') |
74 | 74 |
75 args = parser.parse_args(argv) | 75 args = parser.parse_args(argv) |
76 args.func(args) | 76 args.func(args) |
77 | 77 |
78 | 78 |
79 if __name__ == '__main__': | 79 if __name__ == '__main__': |
80 main(sys.argv[1:]) | 80 main(sys.argv[1:]) |
OLD | NEW |