Debian Codegraph @

infra/bots/assets/win_toolchain/create_and_upload.py

raw
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 os
14 import subprocess
15 import sys
16 import tempfile
17 import create
18
19
20 FILE_DIR = os.path.dirname(os.path.abspath(__file__))
21 ASSET = os.path.basename(FILE_DIR)
22
23
24 def main():
25 parser = argparse.ArgumentParser()
26 parser.add_argument('--src_dir', '-s', required=True)
27 args = parser.parse_args()
28 # Pass src_dir to the creation script via an environment variable, since
29 # we're calling the script via `sk` and not directly.
30 os.environ[create.ENV_VAR] = args.src_dir
31
32 sk = os.path.realpath(os.path.join(
33 FILE_DIR, os.pardir, os.pardir, os.pardir, os.pardir, 'bin', 'sk'))
34 if os.name == 'nt':
35 sk += '.exe'
36 if not os.path.isfile(sk):
37 raise Exception('`sk` not found at %s; maybe you need to run bin/fetch-sk?')
38
39 # Upload the asset.
40 subprocess.check_call([sk, 'asset', 'upload', ASSET], cwd=FILE_DIR)
41
42
43 if __name__ == '__main__':
44 main()