diff options
author | rmistry <rmistry@google.com> | 2016-09-15 09:33:08 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-15 09:33:08 -0700 |
commit | 5caf398cacbfd48118a6e925f7145360cb1fb587 (patch) | |
tree | da4dc75b024fe7bc429946808d9b0a743a71b07f /infra/bots/assets | |
parent | e715d2daf738d16599222b9ddf07e3ab1f1b2493 (diff) |
Add ability to create and upload SVGs from a local dir
BUG=skia:5757
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2346663003
Review-Url: https://codereview.chromium.org/2346663003
Diffstat (limited to 'infra/bots/assets')
-rwxr-xr-x | infra/bots/assets/svg/create.py | 13 | ||||
-rwxr-xr-x | infra/bots/assets/svg/create_and_upload.py | 7 |
2 files changed, 17 insertions, 3 deletions
diff --git a/infra/bots/assets/svg/create.py b/infra/bots/assets/svg/create.py index 543831a8b5..2b9df463e5 100755 --- a/infra/bots/assets/svg/create.py +++ b/infra/bots/assets/svg/create.py @@ -13,31 +13,40 @@ import argparse import common import subprocess import os +import shutil SVG_TOOLS = os.path.join(common.INFRA_BOTS_DIR, os.pardir, os.pardir, 'tools', 'svg') -def create_asset(target_dir): +def create_asset(local_svgs_dir, target_dir): """Create the asset.""" target_dir = os.path.realpath(target_dir) if not os.path.exists(target_dir): os.makedirs(target_dir) + # Download the SVGs specified in tools/svg/svgs.txt download_svgs_cmd = [ 'python', os.path.join(SVG_TOOLS, 'svg_downloader.py'), '--output_dir', target_dir, ] subprocess.check_call(download_svgs_cmd) + # Copy over the SVGs from local_svgs_dir (if any). + if local_svgs_dir and os.path.exists(local_svgs_dir): + for svg_filename in os.listdir(local_svgs_dir): + shutil.copy(src=os.path.join(local_svgs_dir, svg_filename), + dst=os.path.join(target_dir, svg_filename)) + def main(): parser = argparse.ArgumentParser() + parser.add_argument('--local_svgs_dir', '-l', default='') parser.add_argument('--target_dir', '-t', required=True) args = parser.parse_args() - create_asset(args.target_dir) + create_asset(args.local_svgs_dir, args.target_dir) if __name__ == '__main__': diff --git a/infra/bots/assets/svg/create_and_upload.py b/infra/bots/assets/svg/create_and_upload.py index 1356447477..2075979b86 100755 --- a/infra/bots/assets/svg/create_and_upload.py +++ b/infra/bots/assets/svg/create_and_upload.py @@ -19,6 +19,9 @@ import utils def main(): parser = argparse.ArgumentParser() + parser.add_argument( + '--local_svgs_dir', '-l', default='', + help='Directory containing additional SVGs we want to upload.') parser.add_argument('--gsutil') args = parser.parse_args() @@ -28,7 +31,9 @@ def main(): upload_script = os.path.join(common.FILE_DIR, 'upload.py') try: - subprocess.check_call(['python', create_script, '-t', cwd]) + subprocess.check_call(['python', create_script, + '-t', cwd, + '-l', args.local_svgs_dir]) cmd = ['python', upload_script, '-t', cwd] if args.gsutil: cmd.extend(['--gsutil', args.gsutil]) |