| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 """Utilities for all our deps-management stuff.""" | 6 """Utilities for all our deps-management stuff.""" |
| 7 | 7 |
| 8 import hashlib | 8 import hashlib |
| 9 import os | 9 import os |
| 10 import shutil | 10 import shutil |
| 11 import sys | 11 import sys |
| 12 import subprocess |
| 12 import tarfile | 13 import tarfile |
| 13 import zipfile | 14 import zipfile |
| 14 | 15 |
| 15 | 16 |
| 17 def DownloadFilesFromGoogleStorage(path): |
| 18 print 'Downloading files in %s...' % path |
| 19 |
| 20 extension = 'bat' if 'win32' in sys.platform else 'py' |
| 21 cmd = ['download_from_google_storage.%s' % extension, |
| 22 '--bucket=chromium-webrtc-resources', |
| 23 '--auto_platform', |
| 24 '--recursive', |
| 25 '--directory', path] |
| 26 subprocess.check_call(cmd) |
| 27 |
| 28 |
| 16 def ComputeSHA1(path): | 29 def ComputeSHA1(path): |
| 17 if not os.path.exists(path): | 30 if not os.path.exists(path): |
| 18 return 0 | 31 return 0 |
| 19 | 32 |
| 20 sha1 = hashlib.sha1() | 33 sha1 = hashlib.sha1() |
| 21 file_to_hash = open(path, 'rb') | 34 file_to_hash = open(path, 'rb') |
| 22 try: | 35 try: |
| 23 sha1.update(file_to_hash.read()) | 36 sha1.update(file_to_hash.read()) |
| 24 finally: | 37 finally: |
| 25 file_to_hash.close() | 38 file_to_hash.close() |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 76 |
| 64 def GetPlatform(): | 77 def GetPlatform(): |
| 65 if sys.platform.startswith('win'): | 78 if sys.platform.startswith('win'): |
| 66 return 'win' | 79 return 'win' |
| 67 if sys.platform.startswith('linux'): | 80 if sys.platform.startswith('linux'): |
| 68 return 'linux' | 81 return 'linux' |
| 69 if sys.platform.startswith('darwin'): | 82 if sys.platform.startswith('darwin'): |
| 70 return 'mac' | 83 return 'mac' |
| 71 raise Exception("Can't run on platform %s." % sys.platform) | 84 raise Exception("Can't run on platform %s." % sys.platform) |
| 72 | 85 |
| OLD | NEW |