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

Side by Side Diff: scripts/slave/build_scan.py

Issue 2465493002: build_scan: Fix exception handling (Closed)
Patch Set: Created 4 years, 1 month 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
« 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 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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 """Scans a list of masters and saves information in a build_db.""" 6 """Scans a list of masters and saves information in a build_db."""
7 7
8 from contextlib import closing 8 from contextlib import closing
9 import json 9 import json
10 import logging 10 import logging
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 """Downloads the json of a specific build.""" 154 """Downloads the json of a specific build."""
155 url, master, builder, buildnum = url_tuple 155 url, master, builder, buildnum = url_tuple
156 156
157 # Assumes we have something like https://build.chromium.org/p/chromium.perf 157 # Assumes we have something like https://build.chromium.org/p/chromium.perf
158 name = master.rstrip('/').split('/')[-1] 158 name = master.rstrip('/').split('/')[-1]
159 if name in CBE_WHITELIST: 159 if name in CBE_WHITELIST:
160 url = '%s/p/%s/builders/%s/builds/%d?json=1' % ( 160 url = '%s/p/%s/builders/%s/builds/%d?json=1' % (
161 CBE_URL, name, urllib.quote(builder), buildnum) 161 CBE_URL, name, urllib.quote(builder), buildnum)
162 162
163 logging.debug('opening %s...' % url) 163 logging.debug('opening %s...' % url)
164 return _url_open_json(url), master, builder, buildnum 164 try:
ghost stip (do not use) 2016/10/28 20:34:01 put this in _url_open_json() instead
martiniss 2016/10/28 20:42:29 Done.
165 return _url_open_json(url), master, builder, buildnum
166 except (urllib2.URLError, IOError) as f:
167 # Catch this and raise a ValueError because this can be called from
168 # mulitprocessing, which can't pickle SSLContext objects, which apparently a re
169 # properties of urllib2.URLError (it seems).
170 msg = "Error encountered during URL Fetch: %s" % f
171 logging.error(msg)
172 raise ValueError(msg)
165 173
166 174
167 def get_build_jsons(master_builds, processes): 175 def get_build_jsons(master_builds, processes):
168 """Get all new builds on specified masters. 176 """Get all new builds on specified masters.
169 177
170 This takes a dict in the form of [master][builder][build], formats that URL 178 This takes a dict in the form of [master][builder][build], formats that URL
171 and appends that to url_list. Then, it forks out and queries each build_url 179 and appends that to url_list. Then, it forks out and queries each build_url
172 for build information. 180 for build information.
173 """ 181 """
174 url_list = [] 182 url_list = []
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 237
230 if not args: 238 if not args:
231 parser.error('you need to specify at least one master URL') 239 parser.error('you need to specify at least one master URL')
232 240
233 args = [url.rstrip('/') for url in args] 241 args = [url.rstrip('/') for url in args]
234 242
235 return options, args 243 return options, args
236 244
237 245
238 def get_updated_builds(masters, build_db, parallelism): 246 def get_updated_builds(masters, build_db, parallelism):
239 try: 247 new_builds, master_jsons = find_new_builds_per_master(masters, build_db)
240 new_builds, master_jsons = find_new_builds_per_master(masters, build_db) 248 build_jsons = get_build_jsons(new_builds, parallelism)
241 build_jsons = get_build_jsons(new_builds, parallelism) 249 propagate_build_json_to_db(build_db, build_jsons)
242 propagate_build_json_to_db(build_db, build_jsons) 250 return master_jsons, build_jsons
243 return master_jsons, build_jsons
244 251
245 # Catch this and raise a ValueError because this can be called from
246 # mulitprocessing, which can't pickle SSLContext objects, which apparently are
247 # properties of urllib2.URLError (it seems).
248 except (urllib2.URLError, IOError) as f:
249 msg = "Error encountered during URL Fetch: %s" % f
250 logging.error(msg)
251 raise ValueError(msg)
252 252
253 253
254 def main(): 254 def main():
255 options, args = get_options() 255 options, args = get_options()
256 256
257 logging.basicConfig(level=logging.DEBUG if options.verbose else logging.INFO) 257 logging.basicConfig(level=logging.DEBUG if options.verbose else logging.INFO)
258 258
259 masters = {} 259 masters = {}
260 for m in set(args): 260 for m in set(args):
261 masters[m] = BUILDER_WILDCARD 261 masters[m] = BUILDER_WILDCARD
(...skipping 11 matching lines...) Expand all
273 print '%s:%s:%s' % (master_url, builder, buildnum) 273 print '%s:%s:%s' % (master_url, builder, buildnum)
274 274
275 if not options.skip_build_db_update: 275 if not options.skip_build_db_update:
276 build_scan_db.save_build_db(build_db, {}, options.build_db) 276 build_scan_db.save_build_db(build_db, {}, options.build_db)
277 277
278 return 0 278 return 0
279 279
280 280
281 if __name__ == '__main__': 281 if __name__ == '__main__':
282 sys.exit(main()) 282 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