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

Side by Side Diff: tools/get_archive.py

Issue 22893043: Modify get_archive script to optionally download debug Dartium (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address efortuna comment Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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/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) 2011, 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
(...skipping 14 matching lines...) Expand all
25 # Change into the dart directory as we want the project to be rooted here. 25 # Change into the dart directory as we want the project to be rooted here.
26 dart_src = NormJoin(os.path.dirname(sys.argv[0]), os.pardir) 26 dart_src = NormJoin(os.path.dirname(sys.argv[0]), os.pardir)
27 os.chdir(dart_src) 27 os.chdir(dart_src)
28 28
29 GSUTIL_DIR = os.path.join('third_party', 'gsutil') 29 GSUTIL_DIR = os.path.join('third_party', 'gsutil')
30 GSUTIL = GSUTIL_DIR + '/gsutil' 30 GSUTIL = GSUTIL_DIR + '/gsutil'
31 31
32 DRT_DIR = os.path.join('client', 'tests', 'drt') 32 DRT_DIR = os.path.join('client', 'tests', 'drt')
33 DRT_VERSION = os.path.join(DRT_DIR, 'LAST_VERSION') 33 DRT_VERSION = os.path.join(DRT_DIR, 'LAST_VERSION')
34 DRT_LATEST_PATTERN = ( 34 DRT_LATEST_PATTERN = (
35 'gs://dartium-archive/latest/drt-%(osname)s-inc-*.zip') 35 'gs://dartium-archive/latest/drt-%(osname)s-%(bot)s-*.zip')
36 DRT_PERMANENT_PATTERN = ('gs://dartium-archive/drt-%(osname)s-inc/drt-' 36 DRT_PERMANENT_PATTERN = ('gs://dartium-archive/drt-%(osname)s-%(bot)s/drt-'
37 '%(osname)s-inc-%(num1)s.%(num2)s.zip') 37 '%(osname)s-%(bot)s-%(num1)s.%(num2)s.zip')
38 38
39 DARTIUM_DIR = os.path.join('client', 'tests', 'dartium') 39 DARTIUM_DIR = os.path.join('client', 'tests', 'dartium')
40 DARTIUM_VERSION = os.path.join(DARTIUM_DIR, 'LAST_VERSION') 40 DARTIUM_VERSION = os.path.join(DARTIUM_DIR, 'LAST_VERSION')
41 DARTIUM_LATEST_PATTERN = ( 41 DARTIUM_LATEST_PATTERN = (
42 'gs://dartium-archive/latest/dartium-%(osname)s-inc-*.zip') 42 'gs://dartium-archive/latest/dartium-%(osname)s-%(bot)s-*.zip')
43 DARTIUM_PERMANENT_PATTERN = ('gs://dartium-archive/dartium-%(osname)s-inc/' 43 DARTIUM_PERMANENT_PATTERN = ('gs://dartium-archive/dartium-%(osname)s-%(bot)s/'
44 'dartium-%(osname)s-inc-%(num1)s.%(num2)s.zip') 44 'dartium-%(osname)s-%(bot)s-%(num1)s.%(num2)s.zip')
45 45
46 CHROMEDRIVER_DIR = os.path.join('tools', 'testing', 'dartium-chromedriver') 46 CHROMEDRIVER_DIR = os.path.join('tools', 'testing', 'dartium-chromedriver')
47 CHROMEDRIVER_VERSION = os.path.join(CHROMEDRIVER_DIR, 'LAST_VERSION') 47 CHROMEDRIVER_VERSION = os.path.join(CHROMEDRIVER_DIR, 'LAST_VERSION')
48 CHROMEDRIVER_LATEST_PATTERN = ( 48 CHROMEDRIVER_LATEST_PATTERN = (
49 'gs://dartium-archive/latest/chromedriver-%(osname)s-inc-*.zip') 49 'gs://dartium-archive/latest/chromedriver-%(osname)s-%(bot)s-*.zip')
50 CHROMEDRIVER_PERMANENT_PATTERN = ('gs://dartium-archive/chromedriver-%(osname)s' 50 CHROMEDRIVER_PERMANENT_PATTERN = ('gs://dartium-archive/chromedriver-%(osname)s'
51 '-inc/chromedriver-%(osname)s-inc-%(num1)s.' 51 '-%(bot)s/chromedriver-%(osname)s-%(bot)s-%(nu m1)s.'
52 '%(num2)s.zip') 52 '%(num2)s.zip')
53 53
54 SDK_DIR = os.path.join(utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32'), 54 SDK_DIR = os.path.join(utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32'),
55 'dart-sdk') 55 'dart-sdk')
56 SDK_VERSION = os.path.join(SDK_DIR, 'LAST_VERSION') 56 SDK_VERSION = os.path.join(SDK_DIR, 'LAST_VERSION')
57 SDK_LATEST_PATTERN = 'gs://dart-editor-archive-continuous/latest/VERSION' 57 SDK_LATEST_PATTERN = 'gs://dart-editor-archive-continuous/latest/VERSION'
58 # TODO(efortuna): Once the x64 VM also is optimized, select the version 58 # TODO(efortuna): Once the x64 VM also is optimized, select the version
59 # based on whether we are running on a 32-bit or 64-bit system. 59 # based on whether we are running on a 32-bit or 64-bit system.
60 SDK_PERMANENT = ('gs://dart-editor-archive-continuous/%(version_num)s/' + 60 SDK_PERMANENT = ('gs://dart-editor-archive-continuous/%(version_num)s/' +
61 'dartsdk-%(osname)s-32.zip') 61 'dartsdk-%(osname)s-32.zip')
62 62
63 # Dictionary storing the earliest revision of each download we have stored. 63 # Dictionary storing the earliest revision of each download we have stored.
64 LAST_VALID = {'dartium': 4285, 'chromedriver': 7823, 'sdk': 9761, 'drt': 5342} 64 LAST_VALID = {'dartium': 4285, 'chromedriver': 7823, 'sdk': 9761, 'drt': 5342}
65 65
66 sys.path.append(os.path.join(GSUTIL_DIR, 'boto')) 66 sys.path.append(os.path.join(GSUTIL_DIR, 'boto'))
67 import boto 67 import boto
68 68
69 69
70 def ExecuteCommand(*cmd): 70 def ExecuteCommand(*cmd):
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 * You need to do a one-time configuration step to access Google Storage. 117 * You need to do a one-time configuration step to access Google Storage.
118 * Please run this command and follow the instructions: 118 * Please run this command and follow the instructions:
119 * %s config 119 * %s config
120 * 120 *
121 * NOTE: When prompted you can leave "project-id" blank. Just hit enter. 121 * NOTE: When prompted you can leave "project-id" blank. Just hit enter.
122 ******************************************************************************* 122 *******************************************************************************
123 ''' % GSUTIL 123 ''' % GSUTIL
124 sys.exit(1) 124 sys.exit(1)
125 125
126 126
127 def GetDartiumRevision(name, directory, version_file, latest_pattern, 127 def GetDartiumRevision(name, bot, directory, version_file, latest_pattern,
128 permanent_prefix, revision_num=None): 128 permanent_prefix, revision_num=None):
129 """Get the latest binary that is stored in the dartium archive. 129 """Get the latest binary that is stored in the dartium archive.
130 130
131 Args: 131 Args:
132 name: the name of the desired download. 132 name: the name of the desired download.
133 directory: target directory (recreated) to install binary 133 directory: target directory (recreated) to install binary
134 version_file: name of file with the current version stamp 134 version_file: name of file with the current version stamp
135 latest_pattern: the google store url pattern pointing to the latest binary 135 latest_pattern: the google store url pattern pointing to the latest binary
136 permanent_prefix: stable google store folder used to download versions 136 permanent_prefix: stable google store folder used to download versions
137 revision_num: The desired revision number to retrieve. If revision_num is 137 revision_num: The desired revision number to retrieve. If revision_num is
138 None, we return the latest revision. If the revision number is specified 138 None, we return the latest revision. If the revision number is specified
139 but unavailable, find the nearest older revision and use that instead. 139 but unavailable, find the nearest older revision and use that instead.
140 """ 140 """
141 osdict = {'Darwin':'mac', 'Linux':'lucid64', 'Windows':'win'} 141 osdict = {'Darwin':'mac', 'Linux':'lucid64', 'Windows':'win'}
142 142
143 def FindPermanentUrl(out, osname, revision_num): 143 def FindPermanentUrl(out, osname, revision_num):
144 output_lines = out.split() 144 output_lines = out.split()
145 latest = output_lines[-1] 145 latest = output_lines[-1]
146 if not revision_num: 146 if not revision_num:
147 revision_num = latest[latest.rindex('-') + 1 : latest.index('.')] 147 revision_num = latest[latest.rindex('-') + 1 : latest.index('.')]
148 latest = (permanent_prefix[:permanent_prefix.rindex('/')] % { 'osname' : 148 latest = (permanent_prefix[:permanent_prefix.rindex('/')] % { 'osname' :
149 osname } + latest[latest.rindex('/'):]) 149 osname, 'bot' : bot } + latest[latest.rindex('/'):])
150 else: 150 else:
151 latest = (permanent_prefix % { 'osname' : osname, 'num1' : revision_num, 151 latest = (permanent_prefix % { 'osname' : osname, 'num1' : revision_num,
152 'num2' : revision_num }) 152 'num2' : revision_num, 'bot' : bot })
153 foundURL = False 153 foundURL = False
154 while not foundURL: 154 while not foundURL:
155 # Test to ensure this URL exists because the dartium-archive builds can 155 # Test to ensure this URL exists because the dartium-archive builds can
156 # have unusual numbering (a range of CL numbers) sometimes. 156 # have unusual numbering (a range of CL numbers) sometimes.
157 result, out = Gsutil('ls', permanent_prefix % {'osname' : osname, 157 result, out = Gsutil('ls', permanent_prefix % {'osname' : osname,
158 'num1': revision_num, 'num2': '*' }) 158 'num1': revision_num, 'num2': '*', 'bot': bot })
159 if result == 0: 159 if result == 0:
160 # First try to find one with the the second number the same as the 160 # First try to find one with the the second number the same as the
161 # requested number. 161 # requested number.
162 latest = out.split()[0] 162 latest = out.split()[0]
163 # Now test that the permissions are correct so you can actually 163 # Now test that the permissions are correct so you can actually
164 # download it. 164 # download it.
165 temp_dir = tempfile.mkdtemp() 165 temp_dir = tempfile.mkdtemp()
166 temp_zip = os.path.join(temp_dir, 'foo.zip') 166 temp_zip = os.path.join(temp_dir, 'foo.zip')
167 returncode, out = Gsutil('cp', latest, 'file://' + temp_zip) 167 returncode, out = Gsutil('cp', latest, 'file://' + temp_zip)
168 if returncode == 0: 168 if returncode == 0:
169 foundURL = True 169 foundURL = True
170 else: 170 else:
171 # Unable to download this item (most likely because something went 171 # Unable to download this item (most likely because something went
172 # wrong on the upload and the permissions are bad). Keep looking for 172 # wrong on the upload and the permissions are bad). Keep looking for
173 # a different URL. 173 # a different URL.
174 revision_num = int(revision_num) - 1 174 revision_num = int(revision_num) - 1
175 shutil.rmtree(temp_dir) 175 shutil.rmtree(temp_dir)
176 else: 176 else:
177 # Now try to find one with a nearby CL num. 177 # Now try to find one with a nearby CL num.
178 revision_num = int(revision_num) - 1 178 revision_num = int(revision_num) - 1
179 if revision_num <= 0: 179 if revision_num <= 0:
180 TooEarlyError() 180 TooEarlyError()
181 return latest 181 return latest
182 182
183 GetFromGsutil(name, directory, version_file, latest_pattern, osdict, 183 GetFromGsutil(name, directory, version_file, latest_pattern, osdict,
184 FindPermanentUrl, revision_num) 184 FindPermanentUrl, revision_num, bot)
185 185
186 186
187 def GetSdkRevision(name, directory, version_file, latest_pattern, 187 def GetSdkRevision(name, directory, version_file, latest_pattern,
188 permanent_prefix, revision_num): 188 permanent_prefix, revision_num):
189 """Get a revision of the SDK from the editor build archive. 189 """Get a revision of the SDK from the editor build archive.
190 190
191 Args: 191 Args:
192 name: the name of the desired download 192 name: the name of the desired download
193 directory: target directory (recreated) to install binary 193 directory: target directory (recreated) to install binary
194 version_file: name of file with the current version stamp 194 version_file: name of file with the current version stamp
(...skipping 14 matching lines...) Expand all
209 version_info = temp_file.read() 209 version_info = temp_file.read()
210 temp_file.close() 210 temp_file.close()
211 os.unlink(temp_file.name) 211 os.unlink(temp_file.name)
212 if version_info != '': 212 if version_info != '':
213 rev_num = json.loads(version_info)['revision'] 213 rev_num = json.loads(version_info)['revision']
214 else: 214 else:
215 print 'Unable to get latest version information.' 215 print 'Unable to get latest version information.'
216 return '' 216 return ''
217 latest = (permanent_prefix % { 'osname' : osname, 'version_num': rev_num}) 217 latest = (permanent_prefix % { 'osname' : osname, 'version_num': rev_num})
218 return latest 218 return latest
219 219
220 GetFromGsutil(name, directory, version_file, latest_pattern, osdict, 220 GetFromGsutil(name, directory, version_file, latest_pattern, osdict,
221 FindPermanentUrl, revision_num) 221 FindPermanentUrl, revision_num)
222 222
223 223
224 def GetFromGsutil(name, directory, version_file, latest_pattern, 224 def GetFromGsutil(name, directory, version_file, latest_pattern,
225 os_name_dict, get_permanent_url, revision_num = ''): 225 os_name_dict, get_permanent_url, revision_num = '', bot = None):
226 """Download and unzip the desired file from Google Storage. 226 """Download and unzip the desired file from Google Storage.
227 Args: 227 Args:
228 name: the name of the desired download 228 name: the name of the desired download
229 directory: target directory (recreated) to install binary 229 directory: target directory (recreated) to install binary
230 version_file: name of file with the current version stamp 230 version_file: name of file with the current version stamp
231 latest_pattern: the google store url pattern pointing to the latest binary 231 latest_pattern: the google store url pattern pointing to the latest binary
232 os_name_dict: a dictionary of operating system names and their corresponding 232 os_name_dict: a dictionary of operating system names and their corresponding
233 strings on the google storage site. 233 strings on the google storage site.
234 get_permanent_url: a function that accepts a listing of available files 234 get_permanent_url: a function that accepts a listing of available files
235 and the os name, and returns a permanent URL for downloading. 235 and the os name, and returns a permanent URL for downloading.
236 revision_num: the desired revision number to get (if not supplied, we get 236 revision_num: the desired revision number to get (if not supplied, we get
237 the latest revision) 237 the latest revision)
238 """ 238 """
239 system = platform.system() 239 system = platform.system()
240 try: 240 try:
241 osname = os_name_dict[system] 241 osname = os_name_dict[system]
242 except KeyError: 242 except KeyError:
243 print >>sys.stderr, ('WARNING: platform "%s" does not support' 243 print >>sys.stderr, ('WARNING: platform "%s" does not support'
244 '%s.') % (system, name) 244 '%s.') % (system, name)
245 return 0 245 return 0
246 246
247 EnsureConfig() 247 EnsureConfig()
248 248
249 # Query for the lastest version 249 # Query for the latest version
250 pattern = latest_pattern % { 'osname' : osname } 250 pattern = latest_pattern % { 'osname' : osname, 'bot' : bot }
251 result, out = Gsutil('ls', pattern) 251 result, out = Gsutil('ls', pattern)
252 if result == 0: 252 if result == 0:
253 # use permanent link instead, just in case the latest zip entry gets deleted 253 # use permanent link instead, just in case the latest zip entry gets deleted
254 # while we are downloading it. 254 # while we are downloading it.
255 latest = get_permanent_url(out, osname, revision_num) 255 latest = get_permanent_url(out, osname, revision_num)
256 else: # e.g. no access 256 else: # e.g. no access
257 print "Couldn't download %s: %s\n%s" % (name, pattern, out) 257 print "Couldn't download %s: %s\n%s" % (name, pattern, out)
258 if not os.path.exists(version_file): 258 if not os.path.exists(version_file):
259 print "Using %s will not work. Please try again later." % name 259 print "Using %s will not work. Please try again later." % name
260 return 0 260 return 0
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 return 323 return
324 shutil.copy('third_party/drt_resources/AHEM____.TTF', drt_dir) 324 shutil.copy('third_party/drt_resources/AHEM____.TTF', drt_dir)
325 325
326 326
327 def main(): 327 def main():
328 parser = optparse.OptionParser(usage='usage: %prog [options] download_name') 328 parser = optparse.OptionParser(usage='usage: %prog [options] download_name')
329 parser.add_option('-r', '--revision', dest='revision', 329 parser.add_option('-r', '--revision', dest='revision',
330 help='Desired revision number to retrieve for the SDK. If ' 330 help='Desired revision number to retrieve for the SDK. If '
331 'unspecified, retrieve the latest SDK build.', 331 'unspecified, retrieve the latest SDK build.',
332 action='store', default=None) 332 action='store', default=None)
333 parser.add_option('-d', '--debug', dest='debug',
334 help='Download a debug archive instead of a release.',
335 action='store_true', default=False)
333 args, positional = parser.parse_args() 336 args, positional = parser.parse_args()
334 337
335 if args.revision and int(args.revision) < LAST_VALID[positional[0]]: 338 if args.revision and int(args.revision) < LAST_VALID[positional[0]]:
336 return TooEarlyError() 339 return TooEarlyError()
337 340
341 # Use the incremental release bot ('dartium-*-inc') by default.
342 bot = 'inc'
343 if args.debug:
344 bot = 'debug'
345
338 if positional[0] == 'dartium': 346 if positional[0] == 'dartium':
339 GetDartiumRevision('Dartium', DARTIUM_DIR, DARTIUM_VERSION, 347 GetDartiumRevision('Dartium', bot, DARTIUM_DIR, DARTIUM_VERSION,
340 DARTIUM_LATEST_PATTERN, DARTIUM_PERMANENT_PATTERN, 348 DARTIUM_LATEST_PATTERN, DARTIUM_PERMANENT_PATTERN,
341 args.revision) 349 args.revision)
342 elif positional[0] == 'chromedriver': 350 elif positional[0] == 'chromedriver':
343 GetDartiumRevision('chromedriver', CHROMEDRIVER_DIR, CHROMEDRIVER_VERSION, 351 GetDartiumRevision('chromedriver', bot, CHROMEDRIVER_DIR, CHROMEDRIVER_VERSI ON,
344 CHROMEDRIVER_LATEST_PATTERN, 352 CHROMEDRIVER_LATEST_PATTERN,
345 CHROMEDRIVER_PERMANENT_PATTERN, args.revision) 353 CHROMEDRIVER_PERMANENT_PATTERN, args.revision)
346 elif positional[0] == 'sdk': 354 elif positional[0] == 'sdk':
347 GetSdkRevision('sdk', SDK_DIR, SDK_VERSION, SDK_LATEST_PATTERN, 355 GetSdkRevision('sdk', SDK_DIR, SDK_VERSION, SDK_LATEST_PATTERN,
348 SDK_PERMANENT, args.revision) 356 SDK_PERMANENT, args.revision)
349 elif positional[0] == 'drt': 357 elif positional[0] == 'drt':
350 GetDartiumRevision('content_shell', DRT_DIR, DRT_VERSION, 358 GetDartiumRevision('content_shell', bot, DRT_DIR, DRT_VERSION,
351 DRT_LATEST_PATTERN, DRT_PERMANENT_PATTERN, 359 DRT_LATEST_PATTERN, DRT_PERMANENT_PATTERN,
352 args.revision) 360 args.revision)
353 CopyDrtFont(DRT_DIR) 361 CopyDrtFont(DRT_DIR)
354 else: 362 else:
355 print ('Please specify the target you wish to download from Google Storage ' 363 print ('Please specify the target you wish to download from Google Storage '
356 '("drt", "dartium", "chromedriver", or "sdk")') 364 '("drt", "dartium", "chromedriver", or "sdk")')
357 365
358 if __name__ == '__main__': 366 if __name__ == '__main__':
359 sys.exit(main()) 367 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698