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

Side by Side Diff: tools/isolate/run_test_from_archive.py

Issue 10187007: Update run_test_from_archive.py to handle 404 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 8 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
« 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 (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 """Reads a manifest, creates a tree of hardlinks and runs the test. 6 """Reads a manifest, creates a tree of hardlinks and runs the test.
7 7
8 Keeps a local cache. 8 Keeps a local cache.
9 """ 9 """
10 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 def open_remote(file_or_url): 110 def open_remote(file_or_url):
111 """Reads a file or url.""" 111 """Reads a file or url."""
112 if re.match(r'^https?://.+$', file_or_url): 112 if re.match(r'^https?://.+$', file_or_url):
113 return urllib.urlopen(file_or_url) 113 return urllib.urlopen(file_or_url)
114 return open(file_or_url, 'rb') 114 return open(file_or_url, 'rb')
115 115
116 116
117 def download_or_copy(file_or_url, dest): 117 def download_or_copy(file_or_url, dest):
118 """Copies a file or download an url.""" 118 """Copies a file or download an url."""
119 if re.match(r'^https?://.+$', file_or_url): 119 if re.match(r'^https?://.+$', file_or_url):
120 urllib.urlretrieve(file_or_url, dest) 120 remote_file = urllib.urlopen(file_or_url)
Marc-Antoine Ruel (Google) 2012/04/23 23:50:14 I'd prefer to keep using urlretrieve(). Albeit it'
121 if remote_file.getcode() != 200:
122 logging.error('Failed to download ' + file_or_url)
123 return
124
125 f = open(dest, 'wb')
126 f.write(remote_file.read())
127 f.close()
121 else: 128 else:
122 shutil.copy(file_or_url, dest) 129 shutil.copy(file_or_url, dest)
123 130
124 131
125 def get_free_space(path): 132 def get_free_space(path):
126 """Returns the number of free bytes.""" 133 """Returns the number of free bytes."""
127 if sys.platform == 'win32': 134 if sys.platform == 'win32':
128 free_bytes = ctypes.c_ulonglong(0) 135 free_bytes = ctypes.c_ulonglong(0)
129 ctypes.windll.kernel32.GetDiskFreeSpaceExW( 136 ctypes.windll.kernel32.GetDiskFreeSpaceExW(
130 ctypes.c_wchar_p(path), None, None, ctypes.pointer(free_bytes)) 137 ctypes.c_wchar_p(path), None, None, ctypes.pointer(free_bytes))
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 parser.error('Unsupported args %s' % ' '.join(args)) 310 parser.error('Unsupported args %s' % ' '.join(args))
304 311
305 manifest = json.load(open_remote(options.manifest)) 312 manifest = json.load(open_remote(options.manifest))
306 return run_tha_test( 313 return run_tha_test(
307 manifest, os.path.abspath(options.cache), options.remote, 314 manifest, os.path.abspath(options.cache), options.remote,
308 options.max_cache_size, options.min_free_space) 315 options.max_cache_size, options.min_free_space)
309 316
310 317
311 if __name__ == '__main__': 318 if __name__ == '__main__':
312 sys.exit(main()) 319 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