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 os 13import subprocess 14import sys 15import tempfile 16 17 18FILE_DIR = os.path.dirname(os.path.abspath(__file__)) 19ASSET = os.path.basename(FILE_DIR) 20 21 22def main(): 23 sk = os.path.realpath(os.path.join( 24 FILE_DIR, os.pardir, os.pardir, os.pardir, os.pardir, 'bin', 'sk')) 25 if os.name == 'nt': 26 sk += '.exe' 27 if not os.path.isfile(sk): 28 raise Exception('`sk` not found at %s; maybe you need to run bin/fetch-sk?') 29 30 # CIPD is picky about where files are downloaded. Use a subdirectory of the 31 # asset dir rather than /tmp. 32 tmp_prefix = os.path.join(FILE_DIR, '.') 33 with tempfile.TemporaryDirectory(prefix=tmp_prefix) as tmp: 34 subprocess.check_call([sk, 'asset', 'download', ASSET, tmp], cwd=FILE_DIR) 35 # Allow the user to modify the contents of the target dir. 36 input('Previous SKImage contents have been downloaded. Please make ' 37 'your desired changes in the following directory and press enter ' 38 'to continue:\n%s\n' % tmp) 39 subprocess.check_call([sk, 'asset', 'upload', '--in', tmp, ASSET], 40 cwd=FILE_DIR) 41 42 43if __name__ == '__main__': 44 main() 45