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

Unified Diff: download_from_google_storage.py

Issue 58783002: Silence common noisiness in download_from_google_storage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/download_from_google_storage_unittests.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: download_from_google_storage.py
===================================================================
--- download_from_google_storage.py (revision 237112)
+++ download_from_google_storage.py (working copy)
@@ -163,16 +163,17 @@
def _downloader_worker_thread(thread_num, q, force, base_url,
- gsutil, out_q, ret_codes):
+ gsutil, out_q, ret_codes, verbose):
while True:
input_sha1_sum, output_filename = q.get()
if input_sha1_sum is None:
return
if os.path.exists(output_filename) and not force:
if get_sha1(output_filename) == input_sha1_sum:
- out_q.put(
- '%d> File %s exists and SHA1 matches. Skipping.' % (
- thread_num, output_filename))
+ if verbose:
+ out_q.put(
+ '%d> File %s exists and SHA1 matches. Skipping.' % (
+ thread_num, output_filename))
continue
# Check if file exists.
file_url = '%s/%s' % (base_url, input_sha1_sum)
@@ -216,7 +217,7 @@
def download_from_google_storage(
input_filename, base_url, gsutil, num_threads, directory, recursive,
- force, output, ignore_errors, sha1_file):
+ force, output, ignore_errors, sha1_file, verbose):
# Start up all the worker threads.
all_threads = []
download_start = time.time()
@@ -228,7 +229,7 @@
t = threading.Thread(
target=_downloader_worker_thread,
args=[thread_num, work_queue, force, base_url,
- gsutil, stdout_queue, ret_codes])
+ gsutil, stdout_queue, ret_codes, verbose])
t.daemon = True
t.start()
all_threads.append(t)
@@ -255,11 +256,12 @@
max_ret_code = max(ret_code, max_ret_code)
if message:
print >> sys.stderr, message
- if not max_ret_code:
+ if verbose and not max_ret_code:
print 'Success!'
- print 'Downloading %d files took %1f second(s)' % (
- work_queue_size, time.time() - download_start)
+ if verbose:
+ print 'Downloading %d files took %1f second(s)' % (
+ work_queue_size, time.time() - download_start)
return max_ret_code
@@ -308,14 +310,17 @@
help='A regular expression that is compared against '
'Python\'s sys.platform. If this option is specified, '
'the download will happen only if there is a match.')
+ parser.add_option('-v', '--verbose', action='store_true',
+ help='Output extra diagnostic and progress information.')
(options, args) = parser.parse_args()
# Make sure we should run at all based on platform matching.
if options.platform:
if not re.match(options.platform, sys.platform):
- print('The current platform doesn\'t match "%s", skipping.' %
- options.platform)
+ if options.verbose:
+ print('The current platform doesn\'t match "%s", skipping.' %
+ options.platform)
return 0
# Set the boto file to /dev/null if we don't need auth.
@@ -383,7 +388,7 @@
return download_from_google_storage(
input_filename, base_url, gsutil, options.num_threads, options.directory,
options.recursive, options.force, options.output, options.ignore_errors,
- options.sha1_file)
+ options.sha1_file, options.verbose)
if __name__ == '__main__':
« 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