| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 #!/usr/bin/python | 
|  | 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 
|  | 3 # Use of this source code is governed by a BSD-style license that can be | 
|  | 4 # found in the LICENSE file. | 
|  | 5 | 
|  | 6 """Downloads the appengine SDK from WebRTC storage and unpacks it. | 
|  | 7 | 
|  | 8 Requires that depot_tools is installed and in the PATH. This script expects | 
|  | 9 to run with Chrome's base dir as the working directory, e.g. where the .gclient | 
|  | 10 file is. This is what should happen if this script is invoked as a hook action. | 
|  | 11 """ | 
|  | 12 | 
|  | 13 import os | 
|  | 14 import shutil | 
|  | 15 import sys | 
|  | 16 import subprocess | 
|  | 17 import zipfile | 
|  | 18 | 
|  | 19 | 
|  | 20 def _DownloadAppEngineZipFile(webrtc_deps_path): | 
|  | 21   print 'Downloading files in %s...' % webrtc_deps_path | 
|  | 22 | 
|  | 23   extension = 'bat' if 'win32' in sys.platform else 'py' | 
|  | 24   cmd = ['download_from_google_storage.%s' % extension, | 
|  | 25          '--bucket=chromium-webrtc-resources', | 
|  | 26          '--directory', webrtc_deps_path] | 
|  | 27   subprocess.check_call(cmd) | 
|  | 28 | 
|  | 29 | 
|  | 30 # This is necessary since Windows won't allow us to unzip onto an existing dir. | 
|  | 31 def _DeleteOldAppEngineDir(): | 
|  | 32   app_engine_dir = 'google_appengine' | 
|  | 33   print 'Deleting %s in %s...' % (app_engine_dir, os.getcwd()) | 
|  | 34   shutil.rmtree(app_engine_dir, ignore_errors=True) | 
|  | 35 | 
|  | 36 | 
|  | 37 def _Unzip(path): | 
|  | 38   print 'Unzipping %s in %s...' % (path, os.getcwd()) | 
|  | 39   zip_file = zipfile.ZipFile(path) | 
|  | 40   try: | 
|  | 41     zip_file.extractall() | 
|  | 42   finally: | 
|  | 43     zip_file.close() | 
|  | 44 | 
|  | 45 | 
|  | 46 def main(argv): | 
|  | 47   if len(argv) == 1: | 
|  | 48     return 'Usage: %s <path to webrtc.DEPS>' % argv[0] | 
|  | 49 | 
|  | 50   webrtc_deps_path = argv[1] | 
|  | 51   _DownloadAppEngineZipFile(webrtc_deps_path) | 
|  | 52   _DeleteOldAppEngineDir() | 
|  | 53   _Unzip(os.path.join(webrtc_deps_path, 'google-appengine.zip')) | 
|  | 54 | 
|  | 55 | 
|  | 56 if __name__ == '__main__': | 
|  | 57   sys.exit(main(sys.argv)) | 
| OLD | NEW | 
|---|