| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2016 Google Inc. | 3 # Copyright 2016 Google Inc. |
| 4 # | 4 # |
| 5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
| 7 | 7 |
| 8 | 8 |
| 9 """Create the asset and upload it.""" | 9 """Create the asset and upload it.""" |
| 10 | 10 |
| 11 | 11 |
| 12 import argparse | 12 import argparse |
| 13 import common | 13 import common |
| 14 import os | 14 import os |
| 15 import subprocess | 15 import subprocess |
| 16 import sys | 16 import sys |
| 17 import utils | 17 import utils |
| 18 | 18 |
| 19 | 19 |
| 20 def main(): | 20 def main(): |
| 21 parser = argparse.ArgumentParser() | 21 parser = argparse.ArgumentParser() |
| 22 parser.add_argument('--android_sdk_root') | |
| 23 parser.add_argument('--gsutil') | 22 parser.add_argument('--gsutil') |
| 23 parser.add_argument('--chrome_path') |
| 24 parser.add_argument('--msvs_version', required=True) |
| 24 args = parser.parse_args() | 25 args = parser.parse_args() |
| 25 | 26 |
| 26 with utils.tmp_dir(): | 27 with utils.tmp_dir(): |
| 27 cwd = os.getcwd() | 28 cwd = os.getcwd() |
| 28 create_script = os.path.join(common.FILE_DIR, 'create.py') | 29 create_script = os.path.join(common.FILE_DIR, 'create.py') |
| 29 upload_script = os.path.join(common.FILE_DIR, 'upload.py') | 30 upload_script = os.path.join(common.FILE_DIR, 'upload.py') |
| 30 | 31 |
| 31 try: | 32 try: |
| 32 cmd = ['python', create_script, '-t', cwd] | 33 cmd = ['python', create_script, |
| 33 if args.android_sdk_root: | 34 '-t', cwd, |
| 34 cmd.extend(['--android_sdk_root', args.android_sdk_root]) | 35 '--msvs_version', args.msvs_version] |
| 36 if args.chrome_path: |
| 37 cmd.extend(['--chrome_path', args.chrome_path]) |
| 35 subprocess.check_call(cmd) | 38 subprocess.check_call(cmd) |
| 36 | |
| 37 cmd = ['python', upload_script, '-t', cwd] | 39 cmd = ['python', upload_script, '-t', cwd] |
| 38 if args.gsutil: | 40 if args.gsutil: |
| 39 cmd.extend(['--gsutil', args.gsutil]) | 41 cmd.extend(['--gsutil', args.gsutil]) |
| 40 subprocess.check_call(cmd) | 42 subprocess.check_call(cmd) |
| 41 except subprocess.CalledProcessError: | 43 except subprocess.CalledProcessError: |
| 42 # Trap exceptions to avoid printing two stacktraces. | 44 # Trap exceptions to avoid printing two stacktraces. |
| 43 sys.exit(1) | 45 sys.exit(1) |
| 44 | 46 |
| 45 | 47 |
| 46 if __name__ == '__main__': | 48 if __name__ == '__main__': |
| 47 main() | 49 main() |
| OLD | NEW |