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

Side by Side Diff: tools/get_archive.py

Issue 10832149: Update script to switch through revision history successfully. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | tools/testing/perf_testing/run_perf_tests.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/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 DumpRenderTree (a nearly headless build of chrome). This is 7 # Gets or updates a DumpRenderTree (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 15 matching lines...) Expand all
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-inc-*.zip')
36 DRT_PERMANENT_PREFIX = 'gs://dartium-archive/drt-%(osname)s-inc' 36 DRT_PERMANENT_PATTERN = ('gs://dartium-archive/drt-%(osname)s-inc/drt-'
37 '%(osname)s-inc-%(num)s.%(num)s.zip')
37 38
38 DARTIUM_DIR = os.path.join('client', 'tests', 'dartium') 39 DARTIUM_DIR = os.path.join('client', 'tests', 'dartium')
39 DARTIUM_VERSION = os.path.join(DARTIUM_DIR, 'LAST_VERSION') 40 DARTIUM_VERSION = os.path.join(DARTIUM_DIR, 'LAST_VERSION')
40 DARTIUM_LATEST_PATTERN = ( 41 DARTIUM_LATEST_PATTERN = (
41 'gs://dartium-archive/latest/dartium-%(osname)s-inc-*.zip') 42 'gs://dartium-archive/latest/dartium-%(osname)s-inc-*.zip')
42 DARTIUM_PERMANENT_PREFIX = 'gs://dartium-archive/dartium-%(osname)s-inc' 43 DARTIUM_PERMANENT_PATTERN = ('gs://dartium-archive/dartium-%(osname)s-inc/'
44 'dartium-%(osname)s-inc-%(num)s.%(num)s.zip')
43 45
44 CHROMEDRIVER_DIR = os.path.join('tools', 'testing', 'dartium-chromedriver') 46 CHROMEDRIVER_DIR = os.path.join('tools', 'testing', 'dartium-chromedriver')
45 CHROMEDRIVER_VERSION = os.path.join(CHROMEDRIVER_DIR, 'LAST_VERSION') 47 CHROMEDRIVER_VERSION = os.path.join(CHROMEDRIVER_DIR, 'LAST_VERSION')
46 CHROMEDRIVER_LATEST_PATTERN = ( 48 CHROMEDRIVER_LATEST_PATTERN = (
47 'gs://dartium-archive/latest/chromedriver-%(osname)s-inc-*.zip') 49 'gs://dartium-archive/latest/chromedriver-%(osname)s-inc-*.zip')
48 CHROMEDRIVER_PERMANENT_PREFIX = ( 50 CHROMEDRIVER_PERMANENT_PATTERN = ('gs://dartium-archive/chromedriver-%(osname)s'
49 'gs://dartium-archive/chromedriver-%(osname)s-inc') 51 '-inc/chromedriver-%(osname)s-inc-%(num)s.'
52 '%(num)s.zip')
50 53
51 SDK_DIR = os.path.join(utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32'), 54 SDK_DIR = os.path.join(utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32'),
52 'dart-sdk') 55 'dart-sdk')
53 SDK_VERSION = os.path.join(SDK_DIR, 'LAST_VERSION') 56 SDK_VERSION = os.path.join(SDK_DIR, 'LAST_VERSION')
54 SDK_LATEST_PATTERN = 'gs://dart-editor-archive-continuous/latest/VERSION' 57 SDK_LATEST_PATTERN = 'gs://dart-editor-archive-continuous/latest/VERSION'
55 # 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
56 # 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.
57 SDK_PERMANENT = ('gs://dart-editor-archive-continuous/%(version_num)s/' + 60 SDK_PERMANENT = ('gs://dart-editor-archive-continuous/%(version_num)s/' +
58 'dartsdk-%(osname)s-32.zip') 61 'dartsdk-%(osname)s-32.zip')
59 62
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 * You need to do a one-time configuration step to access Google Storage. 114 * You need to do a one-time configuration step to access Google Storage.
112 * Please run this command and follow the instructions: 115 * Please run this command and follow the instructions:
113 * %s config 116 * %s config
114 * 117 *
115 * NOTE: When prompted you can leave "project-id" blank. Just hit enter. 118 * NOTE: When prompted you can leave "project-id" blank. Just hit enter.
116 ******************************************************************************* 119 *******************************************************************************
117 ''' % GSUTIL 120 ''' % GSUTIL
118 sys.exit(1) 121 sys.exit(1)
119 122
120 123
121 def get_dartium_latest(name, directory, version_file, latest_pattern, 124 def get_dartium_revision(name, directory, version_file, latest_pattern,
122 permanent_prefix): 125 permanent_prefix, revision_num=None):
123 """Get the latest binary that is stored in the dartium archive. 126 """Get the latest binary that is stored in the dartium archive.
124 127
125 Args: 128 Args:
126 name: the name of the desired download. 129 name: the name of the desired download.
127 directory: target directory (recreated) to install binary 130 directory: target directory (recreated) to install binary
128 version_file: name of file with the current version stamp 131 version_file: name of file with the current version stamp
129 latest_pattern: the google store url pattern pointing to the latest binary 132 latest_pattern: the google store url pattern pointing to the latest binary
130 permanent_prefix: stable google store folder used to download versions 133 permanent_prefix: stable google store folder used to download versions
134 revision_num: The desired revision number to retrieve. If revision_num is
135 None, we return the latest revision.
131 """ 136 """
132 osdict = {'Darwin':'mac', 'Linux':'lucid64', 'Windows':'win'} 137 osdict = {'Darwin':'mac', 'Linux':'lucid64', 'Windows':'win'}
133 def latest_func(out, osname): 138
139 def latest_func(out, osname, revision_num):
vsm 2012/08/04 15:27:15 Consider renaming from "latest" now that it gets a
Emily Fortuna 2012/08/04 20:36:51 Done.
134 output_lines = out.split() 140 output_lines = out.split()
135 latest = output_lines[-1] 141 latest = output_lines[-1]
136 latest = (permanent_prefix % { 'osname' : osname } 142 if not revision_num:
137 + latest[latest.rindex('/'):]) 143 revision_num = latest[latest.rindex('-') + 1 : latest.index('.')]
144 latest = (permanent_prefix % { 'osname' : osname, 'num' : revision_num })
138 return latest 145 return latest
139 146
140 get_from_gsutil(name, directory, version_file, latest_pattern, osdict, 147 get_from_gsutil(name, directory, version_file, latest_pattern, osdict,
141 latest_func) 148 latest_func, revision_num)
142 149
143 def get_sdk_revision(name, directory, version_file, latest_pattern, 150 def get_sdk_revision(name, directory, version_file, latest_pattern,
144 permanent_prefix, revision_num): 151 permanent_prefix, revision_num):
145 """Get a revision of the SDK from the editor build archive. 152 """Get a revision of the SDK from the editor build archive.
146 153
147 Args: 154 Args:
148 name: the name of the desired download 155 name: the name of the desired download
149 directory: target directory (recreated) to install binary 156 directory: target directory (recreated) to install binary
150 version_file: name of file with the current version stamp 157 version_file: name of file with the current version stamp
151 latest_pattern: the google store url pattern pointing to the latest binary 158 latest_pattern: the google store url pattern pointing to the latest binary
152 permanent_prefix: stable google store folder used to download versions 159 permanent_prefix: stable google store folder used to download versions
153 revision_num: the desired revision number, or None for the most recent 160 revision_num: the desired revision number, or None for the most recent
154 """ 161 """
155 osdict = {'Darwin':'macos', 'Linux':'linux', 'Windows':'win32'} 162 osdict = {'Darwin':'macos', 'Linux':'linux', 'Windows':'win32'}
156 def find_permanent_url(out, osname): 163 def find_permanent_url(out, osname, not_used):
157 rev_num = revision_num 164 rev_num = revision_num
158 if not rev_num: 165 if not rev_num:
159 temp_file = tempfile.NamedTemporaryFile() 166 temp_file = tempfile.NamedTemporaryFile()
160 temp_file_url = 'file://' + temp_file.name 167 temp_file_url = 'file://' + temp_file.name
161 gsutil('cp', latest_pattern % {'osname' : osname }, temp_file_url) 168 gsutil('cp', latest_pattern % {'osname' : osname }, temp_file_url)
162 temp_file.seek(0) 169 temp_file.seek(0)
163 version_info = temp_file.read() 170 version_info = temp_file.read()
164 temp_file.close() 171 temp_file.close()
165 if version_info != '': 172 if version_info != '':
166 rev_num = json.loads(version_info)['revision'] 173 rev_num = json.loads(version_info)['revision']
167 else: 174 else:
168 print 'Unable to get latest version information.' 175 print 'Unable to get latest version information.'
169 return '' 176 return ''
170 latest = (permanent_prefix % { 'osname' : osname, 'version_num': rev_num}) 177 latest = (permanent_prefix % { 'osname' : osname, 'version_num': rev_num})
171 return latest 178 return latest
172 179
173 get_from_gsutil(name, directory, version_file, latest_pattern, osdict, 180 get_from_gsutil(name, directory, version_file, latest_pattern, osdict,
174 find_permanent_url) 181 find_permanent_url, revision_num)
175 182
176 def get_from_gsutil(name, directory, version_file, latest_pattern, 183 def get_from_gsutil(name, directory, version_file, latest_pattern,
177 os_name_dict, get_permanent_url): 184 os_name_dict, get_permanent_url, revision_num = ''):
178 """Download and unzip the desired file from Google Storage. 185 """Download and unzip the desired file from Google Storage.
179 Args: 186 Args:
180 name: the name of the desired download 187 name: the name of the desired download
181 directory: target directory (recreated) to install binary 188 directory: target directory (recreated) to install binary
182 version_file: name of file with the current version stamp 189 version_file: name of file with the current version stamp
183 latest_pattern: the google store url pattern pointing to the latest binary 190 latest_pattern: the google store url pattern pointing to the latest binary
184 os_name_dict: a dictionary of operating system names and their corresponding 191 os_name_dict: a dictionary of operating system names and their corresponding
185 strings on the google storage site. 192 strings on the google storage site.
186 get_permanent_url: a function that accepts a listing of available files 193 get_permanent_url: a function that accepts a listing of available files
187 and the os name, and returns a permanent URL for downloading. 194 and the os name, and returns a permanent URL for downloading.
195 revision_num: the desired revision number to get (if not supplied, we get
196 the latest revision)
188 """ 197 """
189 system = platform.system() 198 system = platform.system()
190 try: 199 try:
191 osname = os_name_dict[system] 200 osname = os_name_dict[system]
192 except KeyError: 201 except KeyError:
193 print >>sys.stderr, ('WARNING: platform "%s" does not support' 202 print >>sys.stderr, ('WARNING: platform "%s" does not support'
194 '%s.') % (system, name) 203 '%s.') % (system, name)
195 return 0 204 return 0
196 205
197 ensure_config() 206 ensure_config()
198 207
199 # Query for the lastest version 208 # Query for the lastest version
200 pattern = latest_pattern % { 'osname' : osname } 209 pattern = latest_pattern % { 'osname' : osname }
201 result, out = gsutil('ls', pattern) 210 result, out = gsutil('ls', pattern)
202 if result == 0: 211 if result == 0:
203 # use permanent link instead, just in case the latest zip entry gets deleted 212 # use permanent link instead, just in case the latest zip entry gets deleted
204 # while we are downloading it. 213 # while we are downloading it.
205 latest = get_permanent_url(out, osname) 214 latest = get_permanent_url(out, osname, revision_num)
206 else: # e.g. no access 215 else: # e.g. no access
207 print "Couldn't download %s: %s\n%s" % (name, pattern, out) 216 print "Couldn't download %s: %s\n%s" % (name, pattern, out)
208 if not os.path.exists(version_file): 217 if not os.path.exists(version_file):
209 print "Using %s will not work. Please try again later." % name 218 print "Using %s will not work. Please try again later." % name
210 return 0 219 return 0
211 220
212 # Check if we need to update the file 221 # Check if we need to update the file
213 if os.path.exists(version_file): 222 if os.path.exists(version_file):
214 v = open(version_file, 'r').read() 223 v = open(version_file, 'r').read()
215 if v == latest: 224 if v == latest:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 269
261 270
262 def main(): 271 def main():
263 parser = optparse.OptionParser(usage='usage: %prog [options] download_name') 272 parser = optparse.OptionParser(usage='usage: %prog [options] download_name')
264 parser.add_option('-r', '--revision', dest='revision', 273 parser.add_option('-r', '--revision', dest='revision',
265 help='Desired revision number to retrieve for the SDK. If ' 274 help='Desired revision number to retrieve for the SDK. If '
266 'unspecified, retrieve the latest SDK build.', 275 'unspecified, retrieve the latest SDK build.',
267 action='store', default=None) 276 action='store', default=None)
268 args, positional = parser.parse_args() 277 args, positional = parser.parse_args()
269 278
270 if args.revision and positional[0] != 'sdk':
271 print ('Error: You can only specify the revision number for the SDK target.'
272 ' For all other targets we return the latest build.')
273 sys.exit(1)
274 if positional[0] == 'dartium': 279 if positional[0] == 'dartium':
275 get_dartium_latest('Dartium', DARTIUM_DIR, DARTIUM_VERSION, 280 get_dartium_revision('Dartium', DARTIUM_DIR, DARTIUM_VERSION,
276 DARTIUM_LATEST_PATTERN, DARTIUM_PERMANENT_PREFIX) 281 DARTIUM_LATEST_PATTERN, DARTIUM_PERMANENT_PATTERN,
282 args.revision)
277 elif positional[0] == 'chromedriver': 283 elif positional[0] == 'chromedriver':
278 get_dartium_latest('chromedriver', CHROMEDRIVER_DIR, CHROMEDRIVER_VERSION, 284 get_dartium_revision('chromedriver', CHROMEDRIVER_DIR, CHROMEDRIVER_VERSION,
279 CHROMEDRIVER_LATEST_PATTERN, 285 CHROMEDRIVER_LATEST_PATTERN,
280 CHROMEDRIVER_PERMANENT_PREFIX) 286 CHROMEDRIVER_PERMANENT_PATTERN, args.revision)
281 elif positional[0] == 'sdk': 287 elif positional[0] == 'sdk':
282 get_sdk_revision('sdk', SDK_DIR, SDK_VERSION, SDK_LATEST_PATTERN, 288 get_sdk_revision('sdk', SDK_DIR, SDK_VERSION, SDK_LATEST_PATTERN,
283 SDK_PERMANENT, args.revision) 289 SDK_PERMANENT, args.revision)
284 elif positional[0] == 'drt': 290 elif positional[0] == 'drt':
285 get_dartium_latest('DumpRenderTree', DRT_DIR, DRT_VERSION, 291 get_dartium_revision('DumpRenderTree', DRT_DIR, DRT_VERSION,
286 DRT_LATEST_PATTERN, DRT_PERMANENT_PREFIX) 292 DRT_LATEST_PATTERN, DRT_PERMANENT_PATTERN,
293 args.revision)
287 else: 294 else:
288 print ('Please specify the target you wish to download from Google Storage ' 295 print ('Please specify the target you wish to download from Google Storage '
289 '("drt", "dartium", "chromedriver", or "sdk")') 296 '("drt", "dartium", "chromedriver", or "sdk")')
290 297
291 if __name__ == '__main__': 298 if __name__ == '__main__':
292 sys.exit(main()) 299 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | tools/testing/perf_testing/run_perf_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698