Add "svg" asset
BUG=skia:5628 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2235763002 Review-Url: https://codereview.chromium.org/2235763002
This commit is contained in:
parent
94b5c5a411
commit
d1cfb5bebe
1
infra/bots/assets/svg/VERSION
Normal file
1
infra/bots/assets/svg/VERSION
Normal file
@ -0,0 +1 @@
|
||||
0
|
26
infra/bots/assets/svg/common.py
Executable file
26
infra/bots/assets/svg/common.py
Executable file
@ -0,0 +1,26 @@
|
||||
#!/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.
|
||||
|
||||
|
||||
"""Common vars used by scripts in this directory."""
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
FILE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir))
|
||||
|
||||
sys.path.insert(0, INFRA_BOTS_DIR)
|
||||
from assets import assets
|
||||
|
||||
ASSET_NAME = os.path.basename(FILE_DIR)
|
||||
|
||||
|
||||
def run(cmd):
|
||||
"""Run a command, eg. "upload" or "download". """
|
||||
assets.main([cmd, ASSET_NAME] + sys.argv[1:])
|
44
infra/bots/assets/svg/create.py
Executable file
44
infra/bots/assets/svg/create.py
Executable file
@ -0,0 +1,44 @@
|
||||
#!/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.
|
||||
|
||||
|
||||
"""Create the asset."""
|
||||
|
||||
|
||||
import argparse
|
||||
import common
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
|
||||
SVG_TOOLS = os.path.join(common.INFRA_BOTS_DIR, os.pardir, os.pardir, 'tools',
|
||||
'svg')
|
||||
|
||||
|
||||
def create_asset(target_dir):
|
||||
"""Create the asset."""
|
||||
target_dir = os.path.realpath(target_dir)
|
||||
|
||||
if not os.path.exists(target_dir):
|
||||
os.makedirs(target_dir)
|
||||
|
||||
download_svgs_cmd = [
|
||||
'python', os.path.join(SVG_TOOLS, 'svg_downloader.py'),
|
||||
'--output_dir', target_dir,
|
||||
]
|
||||
subprocess.check_call(download_svgs_cmd)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--target_dir', '-t', required=True)
|
||||
args = parser.parse_args()
|
||||
create_asset(args.target_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
42
infra/bots/assets/svg/create_and_upload.py
Executable file
42
infra/bots/assets/svg/create_and_upload.py
Executable file
@ -0,0 +1,42 @@
|
||||
#!/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.
|
||||
|
||||
|
||||
"""Create the asset and upload it."""
|
||||
|
||||
|
||||
import argparse
|
||||
import common
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import utils
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--gsutil')
|
||||
args = parser.parse_args()
|
||||
|
||||
with utils.tmp_dir():
|
||||
cwd = os.getcwd()
|
||||
create_script = os.path.join(common.FILE_DIR, 'create.py')
|
||||
upload_script = os.path.join(common.FILE_DIR, 'upload.py')
|
||||
|
||||
try:
|
||||
subprocess.check_call(['python', create_script, '-t', cwd])
|
||||
cmd = ['python', upload_script, '-t', cwd]
|
||||
if args.gsutil:
|
||||
cmd.extend(['--gsutil', args.gsutil])
|
||||
subprocess.check_call(cmd)
|
||||
except subprocess.CalledProcessError:
|
||||
# Trap exceptions to avoid printing two stacktraces.
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
16
infra/bots/assets/svg/download.py
Executable file
16
infra/bots/assets/svg/download.py
Executable file
@ -0,0 +1,16 @@
|
||||
#!/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.
|
||||
|
||||
|
||||
"""Download the current version of the asset."""
|
||||
|
||||
|
||||
import common
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
common.run('download')
|
16
infra/bots/assets/svg/upload.py
Executable file
16
infra/bots/assets/svg/upload.py
Executable file
@ -0,0 +1,16 @@
|
||||
#!/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.
|
||||
|
||||
|
||||
"""Upload a new version of the asset."""
|
||||
|
||||
|
||||
import common
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
common.run('upload')
|
Loading…
Reference in New Issue
Block a user