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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra/bots/assets/assets.py
diff --git a/infra/bots/assets/assets.py b/infra/bots/assets/assets.py
new file mode 100755
index 0000000000000000000000000000000000000000..538a41b58596cef57b2383b3e72f4ec4bfce8972
--- /dev/null
+++ b/infra/bots/assets/assets.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+"""Tool for managing assets."""
+
+
+import argparse
+import asset_utils
+import os
+import shutil
+import subprocess
+import sys
+
+FILE_DIR = os.path.dirname(os.path.abspath(__file__))
+INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir))
+
+sys.path.insert(0, INFRA_BOTS_DIR)
+import utils
+
+
+def add(args):
+ """Add a new asset."""
+ asset_utils.Asset.add(args.asset_name)
+
+
+def remove(args):
+ """Remove an asset."""
+ asset_utils.Asset(args.asset_name).remove()
+
+
+def download(args):
+ """Download the current version of an asset."""
+ asset = asset_utils.Asset(args.asset_name, gsutil=args.gsutil)
+ asset.download_current_version(args.target_dir)
+
+
+def upload(args):
+ """Upload a new version of the asset."""
+ asset = asset_utils.Asset(args.asset_name, gsutil=args.gsutil)
+ asset.upload_new_version(args.target_dir, commit=args.commit)
+
+
+def main(argv):
+ parser = argparse.ArgumentParser(description='Tool for managing assets.')
+ subs = parser.add_subparsers(help='Commands:')
+
+ prs_add = subs.add_parser('add', help='Add a new asset.')
+ prs_add.set_defaults(func=add)
+ prs_add.add_argument('asset_name', help='Name of the asset.')
+
+ prs_remove = subs.add_parser('remove', help='Remove an asset.')
+ prs_remove.set_defaults(func=remove)
+ prs_remove.add_argument('asset_name', help='Name of the asset.')
+
+ prs_download = subs.add_parser(
+ 'download', help='Download the current version of an asset.')
+ prs_download.set_defaults(func=download)
+ prs_download.add_argument('asset_name', help='Name of the asset.')
+ prs_download.add_argument('--target_dir', '-t', required=True)
+ prs_download.add_argument('--gsutil')
+
+ prs_upload = subs.add_parser(
+ 'upload', help='Upload a new version of an asset.')
+ prs_upload.set_defaults(func=upload)
+ prs_upload.add_argument('asset_name', help='Name of the asset.')
+ prs_upload.add_argument('--target_dir', '-t', required=True)
+ prs_upload.add_argument('--gsutil')
+ prs_upload.add_argument('--commit', action='store_true')
+
+ args = parser.parse_args(argv)
+ args.func(args)
+
+
+if __name__ == '__main__':
+ main(sys.argv[1:])
« 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