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.""" | 9 """Create the asset.""" |
10 | 10 |
11 | 11 |
12 import argparse | 12 import argparse |
| 13 import subprocess |
13 | 14 |
| 15 GO_URL = "https://storage.googleapis.com/golang/go1.6.3.linux-amd64.tar.gz" |
14 | 16 |
15 def create_asset(target_dir): | 17 def create_asset(target_dir): |
16 """Create the asset.""" | 18 """Create the asset.""" |
17 raise NotImplementedError('Implement me!') | 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() |
18 | 23 |
19 | 24 |
20 def main(): | 25 def main(): |
21 parser = argparse.ArgumentParser() | 26 parser = argparse.ArgumentParser() |
22 parser.add_argument('--target_dir', '-t', required=True) | 27 parser.add_argument('--target_dir', '-t', required=True) |
23 args = parser.parse_args() | 28 args = parser.parse_args() |
24 create_asset(args.target_dir) | 29 create_asset(args.target_dir) |
25 | 30 |
26 | 31 |
27 if __name__ == '__main__': | 32 if __name__ == '__main__': |
28 main() | 33 main() |
OLD | NEW |