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 12 import argparse 13 import common 14 import os 15 import subprocess 16 import sys 17 import utils 18 19 20 def main(): 21 parser = argparse.ArgumentParser() 22 parser.add_argument('--gsutil') 23 parser.add_argument('--chrome_path') 24 parser.add_argument('--msvs_version', required=True) 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 cmd = ['python', create_script, 34 '-t', cwd, 35 '--msvs_version', args.msvs_version] 36 if args.chrome_path: 37 cmd.extend(['--chrome_path', args.chrome_path]) 38 subprocess.check_call(cmd) 39 cmd = ['python', upload_script, '-t', cwd] 40 if args.gsutil: 41 cmd.extend(['--gsutil', args.gsutil]) 42 subprocess.check_call(cmd) 43 except subprocess.CalledProcessError: 44 # Trap exceptions to avoid printing two stacktraces. 45 sys.exit(1) 46 47 48 if __name__ == '__main__': 49 main() 50