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

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

Issue 2069543002: Add asset management scripts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add asset_utils_test Created 4 years, 6 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 | « infra/bots/assets/asset_utils_test.py ('k') | infra/bots/assets/scripts/common.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2016 Google Inc.
4 #
5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file.
7
8
9 """Tool for managing assets."""
10
11
12 import argparse
13 import asset_utils
14 import os
15 import shutil
16 import subprocess
17 import sys
18
19 FILE_DIR = os.path.dirname(os.path.abspath(__file__))
20 INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir))
21
22 sys.path.insert(0, INFRA_BOTS_DIR)
23 import utils
24
25
26 def add(args):
27 """Add a new asset."""
28 asset_utils.Asset.add(args.asset_name)
29
30
31 def remove(args):
32 """Remove an asset."""
33 asset_utils.Asset(args.asset_name).remove()
34
35
36 def download(args):
37 """Download the current version of an asset."""
38 asset = asset_utils.Asset(args.asset_name, gsutil=args.gsutil)
39 asset.download_current_version(args.target_dir)
40
41
42 def upload(args):
43 """Upload a new version of the asset."""
44 asset = asset_utils.Asset(args.asset_name, gsutil=args.gsutil)
45 asset.upload_new_version(args.target_dir, commit=args.commit)
46
47
48 def main(argv):
49 parser = argparse.ArgumentParser(description='Tool for managing assets.')
50 subs = parser.add_subparsers(help='Commands:')
51
52 prs_add = subs.add_parser('add', help='Add a new asset.')
53 prs_add.set_defaults(func=add)
54 prs_add.add_argument('asset_name', help='Name of the asset.')
55
56 prs_remove = subs.add_parser('remove', help='Remove an asset.')
57 prs_remove.set_defaults(func=remove)
58 prs_remove.add_argument('asset_name', help='Name of the asset.')
59
60 prs_download = subs.add_parser(
61 'download', help='Download the current version of an asset.')
62 prs_download.set_defaults(func=download)
63 prs_download.add_argument('asset_name', help='Name of the asset.')
64 prs_download.add_argument('--target_dir', '-t', required=True)
65 prs_download.add_argument('--gsutil')
66
67 prs_upload = subs.add_parser(
68 'upload', help='Upload a new version of an asset.')
69 prs_upload.set_defaults(func=upload)
70 prs_upload.add_argument('asset_name', help='Name of the asset.')
71 prs_upload.add_argument('--target_dir', '-t', required=True)
72 prs_upload.add_argument('--gsutil')
73 prs_upload.add_argument('--commit', action='store_true')
74
75 args = parser.parse_args(argv)
76 args.func(args)
77
78
79 if __name__ == '__main__':
80 main(sys.argv[1:])
OLDNEW
« no previous file with comments | « infra/bots/assets/asset_utils_test.py ('k') | infra/bots/assets/scripts/common.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698