blob: f0d987e646b6a752d019e7405e9c118c7b7aa1a2 [file] [log] [blame]
#!/usr/bin/env python
# Copyright (c) 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import shutil
import subprocess
import sys
import urllib2
def main():
sky_lib_dir = os.path.dirname(os.path.abspath(__file__))
assets_dir = os.path.join(sky_lib_dir, 'assets')
icons_dir = os.path.join(assets_dir, 'material-design-icons')
existing_sha1_path = os.path.join(icons_dir, 'material-design-icons.sha1')
existing_sha1 = None
if os.path.isfile(existing_sha1_path):
with open(existing_sha1_path, 'r') as f:
existing_sha1 = f.read()
sha1_path = os.path.join(assets_dir, 'material-design-icons.sha1')
with open(sha1_path, 'r') as f:
sha1 = f.read()
if existing_sha1 == sha1:
return
print "Downloading missing material design icons"
tgz_path = os.path.join(assets_dir, 'material-design-icons.tgz')
url = 'https://storage.googleapis.com/mojo/material-design-icons/%s' % sha1
response = urllib2.urlopen(url)
with open(tgz_path, 'wb') as f:
f.write(response.read())
shutil.rmtree(icons_dir, ignore_errors=True)
output_path = os.path.join(assets_dir, tgz_path)
subprocess.call([
'tar', '-xzf', output_path, '-C', assets_dir
])
subprocess.call([
'cp', sha1_path, icons_dir
])
os.unlink(tgz_path)
if __name__ == '__main__':
sys.exit(main())