Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: sky/sdk/lib/download_material_design_icons

Issue 1223843014: Update material design icons (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: alphabetize Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/sdk/lib/assets/material-design-icons.sha1 ('k') | sky/sdk/lib/mojo/net/image_cache.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 shutil
7 import subprocess 8 import subprocess
8 import sys 9 import sys
9 import urllib2 10 import urllib2
10 11
11 def main(): 12 def main():
12 sky_lib_dir = os.path.dirname(os.path.abspath(__file__)) 13 sky_lib_dir = os.path.dirname(os.path.abspath(__file__))
13 assets_dir = os.path.join(sky_lib_dir, 'assets') 14 assets_dir = os.path.join(sky_lib_dir, 'assets')
15 icons_dir = os.path.join(assets_dir, 'material-design-icons')
16 existing_sha1_path = os.path.join(icons_dir, 'material-design-icons.sha1')
14 17
15 if (os.path.isdir(os.path.join(assets_dir, 'material-design-icons'))): 18 existing_sha1 = None
16 return 19 if os.path.isfile(existing_sha1_path):
20 with open(existing_sha1_path, 'r') as f:
21 existing_sha1 = f.read()
17 22
18 sha1_path = os.path.join(assets_dir, 'material-design-icons.sha1') 23 sha1_path = os.path.join(assets_dir, 'material-design-icons.sha1')
19 24
20 with open(sha1_path, 'r') as f: 25 with open(sha1_path, 'r') as f:
21 sha1 = f.read() 26 sha1 = f.read()
22 27
28 if existing_sha1 == sha1:
29 return
30
31 print "Downloading missing material design icons"
32
23 tgz_path = os.path.join(assets_dir, 'material-design-icons.tgz') 33 tgz_path = os.path.join(assets_dir, 'material-design-icons.tgz')
24 url = 'https://storage.googleapis.com/mojo/material-design-icons/%s' % sha1 34 url = 'https://storage.googleapis.com/mojo/material-design-icons/%s' % sha1
25 response = urllib2.urlopen(url) 35 response = urllib2.urlopen(url)
26 36
27 with open(tgz_path, 'wb') as f: 37 with open(tgz_path, 'wb') as f:
28 f.write(response.read()) 38 f.write(response.read())
29 39
40 shutil.rmtree(icons_dir)
41
30 output_path = os.path.join(assets_dir, tgz_path) 42 output_path = os.path.join(assets_dir, tgz_path)
31 subprocess.call([ 43 subprocess.call([
32 'tar', '-xzf', output_path, '-C', assets_dir 44 'tar', '-xzf', output_path, '-C', assets_dir
33 ]) 45 ])
34 46
47 subprocess.call([
48 'cp', sha1_path, icons_dir
49 ])
50
35 os.unlink(tgz_path) 51 os.unlink(tgz_path)
36 52
37 if __name__ == '__main__': 53 if __name__ == '__main__':
38 sys.exit(main()) 54 sys.exit(main())
OLDNEW
« no previous file with comments | « sky/sdk/lib/assets/material-design-icons.sha1 ('k') | sky/sdk/lib/mojo/net/image_cache.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698