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.""" 10 11 12import argparse 13import subprocess 14 15GO_URL = "https://dl.google.com/go/go1.11.linux-amd64.tar.gz" 16 17def create_asset(target_dir): 18 """Create the asset.""" 19 p1 = subprocess.Popen(["curl", GO_URL], stdout=subprocess.PIPE) 20 p2 = subprocess.Popen(["tar", "-C", target_dir, "-xzf" "-"], stdin=p1.stdout) 21 p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. 22 _,_ = p2.communicate() 23 24 25def main(): 26 parser = argparse.ArgumentParser() 27 parser.add_argument('--target_dir', '-t', required=True) 28 args = parser.parse_args() 29 create_asset(args.target_dir) 30 31 32if __name__ == '__main__': 33 main() 34