OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import os | 6 import os |
7 import subprocess | 7 import subprocess |
| 8 import sys |
8 import urllib2 | 9 import urllib2 |
9 | 10 |
10 sky_lib_dir = os.path.dirname(os.path.abspath(__file__)) | 11 def main(): |
11 assets_dir = os.path.join(sky_lib_dir, 'assets') | 12 sky_lib_dir = os.path.dirname(os.path.abspath(__file__)) |
12 sha1_path = os.path.join(assets_dir, 'material-design-icons.sha1') | 13 assets_dir = os.path.join(sky_lib_dir, 'assets') |
13 | 14 |
14 with open(sha1_path, 'r') as f: | 15 if (os.path.isdir(os.path.join(assets_dir, 'material-design-icons'))): |
15 sha1 = f.read() | 16 return |
16 | 17 |
17 tgz_path = os.path.join(assets_dir, 'material-design-icons.tgz') | 18 sha1_path = os.path.join(assets_dir, 'material-design-icons.sha1') |
18 url = 'https://storage.googleapis.com/mojo/material-design-icons/%s' % sha1 | |
19 response = urllib2.urlopen(url) | |
20 | 19 |
21 with open(tgz_path, 'wb') as f: | 20 with open(sha1_path, 'r') as f: |
22 f.write(response.read()) | 21 sha1 = f.read() |
23 | 22 |
24 output_path = os.path.join(assets_dir, tgz_path) | 23 tgz_path = os.path.join(assets_dir, 'material-design-icons.tgz') |
25 subprocess.call([ | 24 url = 'https://storage.googleapis.com/mojo/material-design-icons/%s' % sha1 |
26 'tar', '-xzf', output_path, '-C', assets_dir | 25 response = urllib2.urlopen(url) |
27 ]) | |
28 | 26 |
29 os.unlink(tgz_path) | 27 with open(tgz_path, 'wb') as f: |
| 28 f.write(response.read()) |
| 29 |
| 30 output_path = os.path.join(assets_dir, tgz_path) |
| 31 subprocess.call([ |
| 32 'tar', '-xzf', output_path, '-C', assets_dir |
| 33 ]) |
| 34 |
| 35 os.unlink(tgz_path) |
| 36 |
| 37 if __name__ == '__main__': |
| 38 sys.exit(main()) |
OLD | NEW |