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

Side by Side Diff: webrtc/tools/testing/download_apprtc_appengine_and_mercurial.py

Issue 2882073003: Update testing tools (AppRTC, Go) to new versions (Closed)
Patch Set: Move readme Created 3 years, 7 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
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 #
4 # Use of this source code is governed by a BSD-style license
5 # that can be found in the LICENSE file in the root of the source
6 # tree. An additional intellectual property rights grant can be found
7 # in the file PATENTS. All contributing project authors may
8 # be found in the AUTHORS file in the root of the source tree.
9
10 """Downloads the appengine SDK from WebRTC storage and unpacks it.
11
12 Requires that depot_tools is installed and in the PATH.
13
14 It downloads compressed files in the directory where the script lives.
15 This is because the precondition is that the script lives in the same
16 directory of the .sha1 files.
17 """
18
19 import glob
20 import os
21 import sys
22 import subprocess
23
24 import utils
25
26
27 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
28
29 def _DownloadResources(dir_to_scan_for_sha1):
30 print 'Downloading files in %s...' % dir_to_scan_for_sha1
31
32 extension = 'bat' if 'win32' in sys.platform else 'py'
33 cmd = ['download_from_google_storage.%s' % extension,
34 '--bucket=chromium-webrtc-resources',
35 '--directory', dir_to_scan_for_sha1]
36 subprocess.check_call(cmd)
37
38
39 def _StripVersionNumberFromMercurialFolder(output_dir):
40 unpacked_name = glob.glob(os.path.join(output_dir, 'mercurial*'))
41 assert len(unpacked_name) == 1, 'Should have precisely one mercurial!'
42 os.rename(unpacked_name[0], os.path.join(output_dir, 'mercurial'))
43
44
45 def main(argv):
46 if len(argv) == 1:
47 return 'Usage: %s <output_dir>' % argv[0]
48
49 output_dir = argv[1]
50 appengine_zip_path = os.path.join(SCRIPT_DIR, 'google-appengine.zip')
51 old_appengine_sha1 = utils.ComputeSHA1(appengine_zip_path)
52
53 mercurial_tar_path = os.path.join(SCRIPT_DIR, 'mercurial-src.tar.gz')
54 old_mercurial_sha1 = utils.ComputeSHA1(mercurial_tar_path)
55
56 apprtc_zip_path = os.path.join(SCRIPT_DIR, 'prebuilt_apprtc.zip')
57 old_apprtc_sha1 = utils.ComputeSHA1(apprtc_zip_path)
58
59 _DownloadResources(SCRIPT_DIR)
60
61 if old_appengine_sha1 != utils.ComputeSHA1(appengine_zip_path):
62 utils.RemoveDirectory(os.path.join(output_dir, 'google_appengine'))
63 utils.UnpackArchiveTo(appengine_zip_path, output_dir)
64
65 if old_mercurial_sha1 != utils.ComputeSHA1(mercurial_tar_path):
66 utils.RemoveDirectory(os.path.join(output_dir, 'mercurial'))
67 utils.UnpackArchiveTo(mercurial_tar_path, output_dir)
68 _StripVersionNumberFromMercurialFolder(output_dir)
69
70 if old_apprtc_sha1 != utils.ComputeSHA1(apprtc_zip_path):
71 utils.RemoveDirectory(os.path.join(output_dir, 'apprtc'))
72 utils.UnpackArchiveTo(apprtc_zip_path, output_dir)
73
74 if __name__ == '__main__':
75 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698