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"""Create the asset and upload it.""" 10 11 12import argparse 13import common 14import os 15import subprocess 16import sys 17import utils 18 19 20def main(): 21 parser = argparse.ArgumentParser() 22 parser.add_argument('--chrome_src_path', '-c', required=True) 23 parser.add_argument('--browser_executable', '-e', required=True) 24 parser.add_argument('--gsutil') 25 args = parser.parse_args() 26 27 with utils.tmp_dir(): 28 cwd = os.getcwd() 29 create_script = os.path.join(common.FILE_DIR, 'create.py') 30 upload_script = os.path.join(common.FILE_DIR, 'upload.py') 31 32 try: 33 subprocess.check_call(['python', create_script, '--target_dir', cwd, 34 '--chrome_src_path', args.chrome_src_path, 35 '--browser_executable', args.browser_executable]) 36 cmd = ['python', upload_script, '-t', cwd] 37 if args.gsutil: 38 cmd.extend(['--gsutil', args.gsutil]) 39 subprocess.check_call(cmd) 40 except subprocess.CalledProcessError: 41 # Trap exceptions to avoid printing two stacktraces. 42 sys.exit(1) 43 44 45if __name__ == '__main__': 46 main() 47