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

Side by Side Diff: download_appengine_and_mercurial.py

Issue 759163003: Add infrastructure to download golang and build AppRTC collider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/webrtc/webrtc.DEPS/
Patch Set: Created 6 years 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 | Annotate | Revision Log
« no previous file with comments | « build_mercurial_local.py ('k') | download_appengine_sdk.py » ('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/python 1 #!/usr/bin/python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 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 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 """Downloads the appengine SDK from WebRTC storage and unpacks it. 6 """Downloads the appengine SDK from WebRTC storage and unpacks it.
7 7
8 Requires that depot_tools is installed and in the PATH. This script expects 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 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. 10 file is. This is what should happen if this script is invoked as a hook action.
11 """ 11 """
12 12
13 import hashlib 13 import glob
14 import os 14 import os
15 import shutil
16 import sys 15 import sys
17 import subprocess 16 import subprocess
18 import zipfile
19 17
18 import utils
20 19
21 def _DownloadAppEngineZipFile(webrtc_deps_path): 20 def _DownloadResources(webrtc_deps_path):
22 print 'Downloading files in %s...' % webrtc_deps_path 21 print 'Downloading files in %s...' % webrtc_deps_path
23 22
24 extension = 'bat' if 'win32' in sys.platform else 'py' 23 extension = 'bat' if 'win32' in sys.platform else 'py'
25 cmd = ['download_from_google_storage.%s' % extension, 24 cmd = ['download_from_google_storage.%s' % extension,
26 '--bucket=chromium-webrtc-resources', 25 '--bucket=chromium-webrtc-resources',
27 '--directory', webrtc_deps_path] 26 '--directory', webrtc_deps_path]
28 subprocess.check_call(cmd) 27 subprocess.check_call(cmd)
29 28
30 29
31 def _ComputeSHA1(path): 30 def _StripVersionNumberFromMercurialFolder():
32 if not os.path.exists(path): 31 unpacked_name = glob.glob('mercurial*')
33 return 0 32 assert len(unpacked_name) == 1, 'Should have precisely one mercurial!'
34 33 os.rename(unpacked_name[0], 'mercurial')
35 sha1 = hashlib.sha1()
36 file_to_hash = open(path, 'rb')
37 try:
38 sha1.update(file_to_hash.read())
39 finally:
40 file_to_hash.close()
41
42 return sha1.hexdigest()
43
44
45 # This is necessary since Windows won't allow us to unzip onto an existing dir.
46 def _DeleteOldAppEngineDir():
47 app_engine_dir = 'google_appengine'
48 print 'Deleting %s in %s...' % (app_engine_dir, os.getcwd())
49 shutil.rmtree(app_engine_dir, ignore_errors=True)
50
51
52 def _Unzip(path):
53 print 'Unzipping %s in %s...' % (path, os.getcwd())
54 zip_file = zipfile.ZipFile(path)
55 try:
56 zip_file.extractall()
57 finally:
58 zip_file.close()
59 34
60 35
61 def main(argv): 36 def main(argv):
62 if len(argv) == 1: 37 if len(argv) == 1:
63 return 'Usage: %s <path to webrtc.DEPS>' % argv[0] 38 return 'Usage: %s <path to webrtc.DEPS>' % argv[0]
64 39
65 webrtc_deps_path = argv[1] 40 webrtc_deps_path = argv[1]
66 zip_path = os.path.join(webrtc_deps_path, 'google-appengine.zip') 41 appengine_zip_path = os.path.join(webrtc_deps_path, 'google-appengine.zip')
67 old_zip_sha1 = _ComputeSHA1(zip_path) 42 old_appengine_sha1 = utils.ComputeSHA1(appengine_zip_path)
68 43
69 _DownloadAppEngineZipFile(webrtc_deps_path) 44 mercurial_tar_path = os.path.join(webrtc_deps_path, 'mercurial-src.tar.gz')
45 old_mercurial_sha1 = utils.ComputeSHA1(mercurial_tar_path)
70 46
71 if old_zip_sha1 != _ComputeSHA1(zip_path): 47 _DownloadResources(webrtc_deps_path)
72 _DeleteOldAppEngineDir()
73 _Unzip(zip_path)
74 48
49 if old_appengine_sha1 != utils.ComputeSHA1(appengine_zip_path):
50 utils.DeleteDirNextToGclient('google_appengine')
51 utils.UnpackToWorkingDir(appengine_zip_path)
52
53 if old_mercurial_sha1 != utils.ComputeSHA1(mercurial_tar_path):
54 utils.DeleteDirNextToGclient('mercurial')
55 utils.UnpackToWorkingDir(mercurial_tar_path)
56 _StripVersionNumberFromMercurialFolder()
75 57
76 if __name__ == '__main__': 58 if __name__ == '__main__':
77 sys.exit(main(sys.argv)) 59 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build_mercurial_local.py ('k') | download_appengine_sdk.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698