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

Side by Side Diff: download_from_google_storage.py

Issue 1252313005: Add verification to downloaded files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 5 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 | tests/download_from_google_storage_unittests.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 # 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 """Download files from Google Storage based on SHA1 sums.""" 6 """Download files from Google Storage based on SHA1 sums."""
7 7
8 8
9 import hashlib 9 import hashlib
10 import optparse 10 import optparse
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 out_q.put('%d> Downloading %s...' % (thread_num, output_filename)) 219 out_q.put('%d> Downloading %s...' % (thread_num, output_filename))
220 try: 220 try:
221 os.remove(output_filename) # Delete the file if it exists already. 221 os.remove(output_filename) # Delete the file if it exists already.
222 except OSError: 222 except OSError:
223 if os.path.exists(output_filename): 223 if os.path.exists(output_filename):
224 out_q.put('%d> Warning: deleting %s failed.' % ( 224 out_q.put('%d> Warning: deleting %s failed.' % (
225 thread_num, output_filename)) 225 thread_num, output_filename))
226 code, _, err = gsutil.check_call('cp', file_url, output_filename) 226 code, _, err = gsutil.check_call('cp', file_url, output_filename)
227 if code != 0: 227 if code != 0:
228 out_q.put('%d> %s' % (thread_num, err)) 228 out_q.put('%d> %s' % (thread_num, err))
229 ret_codes.put((code, err)) 229 ret_codes.put((code, err))
Vadim Sh. 2015/07/29 20:43:49 is it ok that there's no "continue" after this lin
Ryan Tseng 2015/07/29 20:51:24 Good catch there should be a continue here. I thi
230 remote_sha1 = get_sha1(output_filename)
231 if remote_sha1 != input_sha1_sum:
232 msg = ('%d> ERROR remote sha1 (%s) does not match expected sha1 (%s).' %
233 (thread_num, remote_sha1, input_sha1_sum))
234 out_q.put(msg)
235 ret_codes.put((20, msg))
236 continue
230 237
231 # Set executable bit. 238 # Set executable bit.
232 if sys.platform == 'cygwin': 239 if sys.platform == 'cygwin':
233 # Under cygwin, mark all files as executable. The executable flag in 240 # Under cygwin, mark all files as executable. The executable flag in
234 # Google Storage will not be set when uploading from Windows, so if 241 # Google Storage will not be set when uploading from Windows, so if
235 # this script is running under cygwin and we're downloading an 242 # this script is running under cygwin and we're downloading an
236 # executable, it will be unrunnable from inside cygwin without this. 243 # executable, it will be unrunnable from inside cygwin without this.
237 st = os.stat(output_filename) 244 st = os.stat(output_filename)
238 os.chmod(output_filename, st.st_mode | stat.S_IEXEC) 245 os.chmod(output_filename, st.st_mode | stat.S_IEXEC)
239 elif sys.platform != 'win32': 246 elif sys.platform != 'win32':
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 base_url = 'gs://%s' % options.bucket 456 base_url = 'gs://%s' % options.bucket
450 457
451 return download_from_google_storage( 458 return download_from_google_storage(
452 input_filename, base_url, gsutil, options.num_threads, options.directory, 459 input_filename, base_url, gsutil, options.num_threads, options.directory,
453 options.recursive, options.force, options.output, options.ignore_errors, 460 options.recursive, options.force, options.output, options.ignore_errors,
454 options.sha1_file, options.verbose, options.auto_platform) 461 options.sha1_file, options.verbose, options.auto_platform)
455 462
456 463
457 if __name__ == '__main__': 464 if __name__ == '__main__':
458 sys.exit(main(sys.argv)) 465 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | tests/download_from_google_storage_unittests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698