| 1 |
#!/usr/bin/env python |
| 2 |
# |
| 3 |
# Copyright 2017 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 |
"""Create the asset and upload it.""" |
| 10 |
|
| 11 |
|
| 12 |
import argparse |
| 13 |
import os |
| 14 |
import subprocess |
| 15 |
import sys |
| 16 |
|
| 17 |
FILE_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 18 |
INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir)) |
| 19 |
sys.path.insert(0, INFRA_BOTS_DIR) |
| 20 |
import utils |
| 21 |
|
| 22 |
|
| 23 |
def main(): |
| 24 |
parser = argparse.ArgumentParser() |
| 25 |
parser.add_argument('--gsutil') |
| 26 |
args = parser.parse_args() |
| 27 |
|
| 28 |
with utils.tmp_dir(): |
| 29 |
cwd = os.getcwd() |
| 30 |
create_script = os.path.join(FILE_DIR, 'create.py') |
| 31 |
upload_script = os.path.join(FILE_DIR, 'upload.py') |
| 32 |
|
| 33 |
try: |
| 34 |
subprocess.check_call(['python3', create_script, '-t', cwd]) |
| 35 |
cmd = ['python3', upload_script, '-t', cwd] |
| 36 |
if args.gsutil: |
| 37 |
cmd.extend(['--gsutil', args.gsutil]) |
| 38 |
subprocess.check_call(cmd) |
| 39 |
except subprocess.CalledProcessError: |
| 40 |
# Trap exceptions to avoid printing two stacktraces. |
| 41 |
sys.exit(1) |
| 42 |
|
| 43 |
|
| 44 |
if __name__ == '__main__': |
| 45 |
main() |