OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
6 | 6 |
7 # Gets or updates a content shell (a nearly headless build of chrome). This is | 7 # Gets or updates a content shell (a nearly headless build of chrome). This is |
8 # used for running browser tests of client applications. | 8 # used for running browser tests of client applications. |
9 | 9 |
10 import json | 10 import json |
11 import optparse | 11 import optparse |
12 import os | 12 import os |
13 import platform | 13 import platform |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 if 'AWS_CREDENTIAL_FILE' in os.environ: | 89 if 'AWS_CREDENTIAL_FILE' in os.environ: |
90 config_paths.append(os.environ['AWS_CREDENTIAL_FILE']) | 90 config_paths.append(os.environ['AWS_CREDENTIAL_FILE']) |
91 for config_path in config_paths: | 91 for config_path in config_paths: |
92 if os.path.exists(config_path): | 92 if os.path.exists(config_path): |
93 return True | 93 return True |
94 | 94 |
95 return False | 95 return False |
96 | 96 |
97 | 97 |
98 def InRunhooks(): | 98 def InRunhooks(): |
99 '''True if this script was called by "gclient runhooks" or "gclient sync"''' | 99 """True if this script was called by "gclient runhooks" or "gclient sync\"""" |
100 return 'runhooks' in sys.argv | 100 return 'runhooks' in sys.argv |
101 | 101 |
102 | 102 |
103 def EnsureConfig(): | 103 def EnsureConfig(): |
104 # If ~/.boto doesn't exist, tell the user to run "gsutil config" | 104 # If ~/.boto doesn't exist, tell the user to run "gsutil config" |
105 if not HasBotoConfig(): | 105 if not HasBotoConfig(): |
106 print >>sys.stderr, ''' | 106 print >>sys.stderr, ''' |
107 ******************************************************************************* | 107 ******************************************************************************* |
108 * WARNING: Can't download content shell! This is required to test client apps. | 108 * WARNING: Can't download content shell! This is required to test client apps. |
109 * You need to do a one-time configuration step to access Google Storage. | 109 * You need to do a one-time configuration step to access Google Storage. |
(...skipping 15 matching lines...) Expand all Loading... |
125 directory: target directory (recreated) to install binary | 125 directory: target directory (recreated) to install binary |
126 version_file: name of file with the current version stamp | 126 version_file: name of file with the current version stamp |
127 latest_pattern: the google store url pattern pointing to the latest binary | 127 latest_pattern: the google store url pattern pointing to the latest binary |
128 permanent_prefix: stable google store folder used to download versions | 128 permanent_prefix: stable google store folder used to download versions |
129 revision_num: The desired revision number to retrieve. If revision_num is | 129 revision_num: The desired revision number to retrieve. If revision_num is |
130 None, we return the latest revision. If the revision number is specified | 130 None, we return the latest revision. If the revision number is specified |
131 but unavailable, find the nearest older revision and use that instead. | 131 but unavailable, find the nearest older revision and use that instead. |
132 """ | 132 """ |
133 osdict = {'Darwin':'mac', 'Linux':'lucid64', 'Windows':'win'} | 133 osdict = {'Darwin':'mac', 'Linux':'lucid64', 'Windows':'win'} |
134 | 134 |
135 def FindPermanentUrl(out, osname, revision_num): | 135 def FindPermanentUrl(out, osname, the_revision_num): |
136 output_lines = out.split() | 136 output_lines = out.split() |
137 latest = output_lines[-1] | 137 latest = output_lines[-1] |
138 if not revision_num: | 138 if not the_revision_num: |
139 revision_num = latest[latest.rindex('-') + 1 : latest.index('.')] | |
140 latest = (permanent_prefix[:permanent_prefix.rindex('/')] % { 'osname' : | 139 latest = (permanent_prefix[:permanent_prefix.rindex('/')] % { 'osname' : |
141 osname, 'bot' : bot } + latest[latest.rindex('/'):]) | 140 osname, 'bot' : bot } + latest[latest.rindex('/'):]) |
142 else: | 141 else: |
143 latest = (permanent_prefix % { 'osname' : osname, 'num1' : revision_num, | 142 latest = (permanent_prefix % { 'osname' : osname, 'num1' : the_revision_nu
m, |
144 'num2' : revision_num, 'bot' : bot }) | 143 'num2' : the_revision_num, 'bot' : bot }) |
145 foundURL = False | 144 foundURL = False |
146 while not foundURL: | 145 while not foundURL: |
147 # Test to ensure this URL exists because the dartium-archive builds can | 146 # Test to ensure this URL exists because the dartium-archive builds can |
148 # have unusual numbering (a range of CL numbers) sometimes. | 147 # have unusual numbering (a range of CL numbers) sometimes. |
149 result, out = Gsutil('ls', permanent_prefix % {'osname' : osname, | 148 result, out = Gsutil('ls', permanent_prefix % {'osname' : osname, |
150 'num1': revision_num, 'num2': '*', 'bot': bot }) | 149 'num1': the_revision_num, 'num2': '*', 'bot': bot }) |
151 if result == 0: | 150 if result == 0: |
152 # First try to find one with the the second number the same as the | 151 # First try to find one with the the second number the same as the |
153 # requested number. | 152 # requested number. |
154 latest = out.split()[0] | 153 latest = out.split()[0] |
155 # Now test that the permissions are correct so you can actually | 154 # Now test that the permissions are correct so you can actually |
156 # download it. | 155 # download it. |
157 temp_dir = tempfile.mkdtemp() | 156 temp_dir = tempfile.mkdtemp() |
158 temp_zip = os.path.join(temp_dir, 'foo.zip') | 157 temp_zip = os.path.join(temp_dir, 'foo.zip') |
159 returncode, out = Gsutil('cp', latest, 'file://' + temp_zip) | 158 returncode, out = Gsutil('cp', latest, 'file://' + temp_zip) |
160 if returncode == 0: | 159 if returncode == 0: |
161 foundURL = True | 160 foundURL = True |
162 else: | 161 else: |
163 # Unable to download this item (most likely because something went | 162 # Unable to download this item (most likely because something went |
164 # wrong on the upload and the permissions are bad). Keep looking for | 163 # wrong on the upload and the permissions are bad). Keep looking for |
165 # a different URL. | 164 # a different URL. |
166 revision_num = int(revision_num) - 1 | 165 the_revision_num = int(the_revision_num) - 1 |
167 shutil.rmtree(temp_dir) | 166 shutil.rmtree(temp_dir) |
168 else: | 167 else: |
169 # Now try to find one with a nearby CL num. | 168 # Now try to find one with a nearby CL num. |
170 revision_num = int(revision_num) - 1 | 169 the_revision_num = int(the_revision_num) - 1 |
171 if revision_num <= 0: | 170 if the_revision_num <= 0: |
172 TooEarlyError() | 171 TooEarlyError() |
173 return latest | 172 return latest |
174 | 173 |
175 GetFromGsutil(name, directory, version_file, latest_pattern, osdict, | 174 GetFromGsutil(name, directory, version_file, latest_pattern, osdict, |
176 FindPermanentUrl, revision_num, bot) | 175 FindPermanentUrl, revision_num, bot) |
177 | 176 |
178 | 177 |
179 def GetSdkRevision(name, directory, version_file, latest_pattern, | 178 def GetSdkRevision(name, directory, version_file, latest_pattern, |
180 permanent_prefix, revision_num): | 179 permanent_prefix, revision_num): |
181 """Get a revision of the SDK from the editor build archive. | 180 """Get a revision of the SDK from the editor build archive. |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 GetDartiumRevision('content_shell', bot, DRT_DIR, DRT_VERSION, | 350 GetDartiumRevision('content_shell', bot, DRT_DIR, DRT_VERSION, |
352 DRT_LATEST_PATTERN, DRT_PERMANENT_PATTERN, | 351 DRT_LATEST_PATTERN, DRT_PERMANENT_PATTERN, |
353 args.revision) | 352 args.revision) |
354 CopyDrtFont(DRT_DIR) | 353 CopyDrtFont(DRT_DIR) |
355 else: | 354 else: |
356 print ('Please specify the target you wish to download from Google Storage ' | 355 print ('Please specify the target you wish to download from Google Storage ' |
357 '("drt", "dartium", "chromedriver", or "sdk")') | 356 '("drt", "dartium", "chromedriver", or "sdk")') |
358 | 357 |
359 if __name__ == '__main__': | 358 if __name__ == '__main__': |
360 sys.exit(main()) | 359 sys.exit(main()) |
OLD | NEW |