Commit ff7ea00a authored by scottmg@chromium.org's avatar scottmg@chromium.org

Silence common noisiness in download_from_google_storage

Seems overly verbose when run in "gclient runhooks".

R=iannucci@chromium.org, brettw@chromium.org

Review URL: https://codereview.chromium.org/58783002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@237120 0039d316-1c4b-4281-b951-d872f2087c98
parent 78dc9841
...@@ -163,13 +163,14 @@ def enumerate_work_queue(input_filename, work_queue, directory, ...@@ -163,13 +163,14 @@ def enumerate_work_queue(input_filename, work_queue, directory,
def _downloader_worker_thread(thread_num, q, force, base_url, def _downloader_worker_thread(thread_num, q, force, base_url,
gsutil, out_q, ret_codes): gsutil, out_q, ret_codes, verbose):
while True: while True:
input_sha1_sum, output_filename = q.get() input_sha1_sum, output_filename = q.get()
if input_sha1_sum is None: if input_sha1_sum is None:
return return
if os.path.exists(output_filename) and not force: if os.path.exists(output_filename) and not force:
if get_sha1(output_filename) == input_sha1_sum: if get_sha1(output_filename) == input_sha1_sum:
if verbose:
out_q.put( out_q.put(
'%d> File %s exists and SHA1 matches. Skipping.' % ( '%d> File %s exists and SHA1 matches. Skipping.' % (
thread_num, output_filename)) thread_num, output_filename))
...@@ -216,7 +217,7 @@ def printer_worker(output_queue): ...@@ -216,7 +217,7 @@ def printer_worker(output_queue):
def download_from_google_storage( def download_from_google_storage(
input_filename, base_url, gsutil, num_threads, directory, recursive, 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. # Start up all the worker threads.
all_threads = [] all_threads = []
download_start = time.time() download_start = time.time()
...@@ -228,7 +229,7 @@ def download_from_google_storage( ...@@ -228,7 +229,7 @@ def download_from_google_storage(
t = threading.Thread( t = threading.Thread(
target=_downloader_worker_thread, target=_downloader_worker_thread,
args=[thread_num, work_queue, force, base_url, args=[thread_num, work_queue, force, base_url,
gsutil, stdout_queue, ret_codes]) gsutil, stdout_queue, ret_codes, verbose])
t.daemon = True t.daemon = True
t.start() t.start()
all_threads.append(t) all_threads.append(t)
...@@ -255,9 +256,10 @@ def download_from_google_storage( ...@@ -255,9 +256,10 @@ def download_from_google_storage(
max_ret_code = max(ret_code, max_ret_code) max_ret_code = max(ret_code, max_ret_code)
if message: if message:
print >> sys.stderr, message print >> sys.stderr, message
if not max_ret_code: if verbose and not max_ret_code:
print 'Success!' print 'Success!'
if verbose:
print 'Downloading %d files took %1f second(s)' % ( print 'Downloading %d files took %1f second(s)' % (
work_queue_size, time.time() - download_start) work_queue_size, time.time() - download_start)
return max_ret_code return max_ret_code
...@@ -308,12 +310,15 @@ def main(args): ...@@ -308,12 +310,15 @@ def main(args):
help='A regular expression that is compared against ' help='A regular expression that is compared against '
'Python\'s sys.platform. If this option is specified, ' 'Python\'s sys.platform. If this option is specified, '
'the download will happen only if there is a match.') '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() (options, args) = parser.parse_args()
# Make sure we should run at all based on platform matching. # Make sure we should run at all based on platform matching.
if options.platform: if options.platform:
if not re.match(options.platform, sys.platform): if not re.match(options.platform, sys.platform):
if options.verbose:
print('The current platform doesn\'t match "%s", skipping.' % print('The current platform doesn\'t match "%s", skipping.' %
options.platform) options.platform)
return 0 return 0
...@@ -383,7 +388,7 @@ def main(args): ...@@ -383,7 +388,7 @@ def main(args):
return download_from_google_storage( return download_from_google_storage(
input_filename, base_url, gsutil, options.num_threads, options.directory, input_filename, base_url, gsutil, options.num_threads, options.directory,
options.recursive, options.force, options.output, options.ignore_errors, options.recursive, options.force, options.output, options.ignore_errors,
options.sha1_file) options.sha1_file, options.verbose)
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -173,7 +173,7 @@ class DownloadTests(unittest.TestCase): ...@@ -173,7 +173,7 @@ class DownloadTests(unittest.TestCase):
stdout_queue = Queue.Queue() stdout_queue = Queue.Queue()
download_from_google_storage._downloader_worker_thread( download_from_google_storage._downloader_worker_thread(
0, self.queue, False, self.base_url, self.gsutil, 0, self.queue, False, self.base_url, self.gsutil,
stdout_queue, self.ret_codes) stdout_queue, self.ret_codes, True)
expected_calls = [ expected_calls = [
('check_call', ('check_call',
('ls', input_filename)), ('ls', input_filename)),
...@@ -200,7 +200,7 @@ class DownloadTests(unittest.TestCase): ...@@ -200,7 +200,7 @@ class DownloadTests(unittest.TestCase):
stdout_queue = Queue.Queue() stdout_queue = Queue.Queue()
download_from_google_storage._downloader_worker_thread( download_from_google_storage._downloader_worker_thread(
0, self.queue, False, self.base_url, self.gsutil, 0, self.queue, False, self.base_url, self.gsutil,
stdout_queue, self.ret_codes) stdout_queue, self.ret_codes, True)
expected_output = [ expected_output = [
'0> File %s exists and SHA1 matches. Skipping.' % output_filename '0> File %s exists and SHA1 matches. Skipping.' % output_filename
] ]
...@@ -217,7 +217,7 @@ class DownloadTests(unittest.TestCase): ...@@ -217,7 +217,7 @@ class DownloadTests(unittest.TestCase):
self.gsutil.add_expected(1, '', '') # Return error when 'ls' is called. self.gsutil.add_expected(1, '', '') # Return error when 'ls' is called.
download_from_google_storage._downloader_worker_thread( download_from_google_storage._downloader_worker_thread(
0, self.queue, False, self.base_url, self.gsutil, 0, self.queue, False, self.base_url, self.gsutil,
stdout_queue, self.ret_codes) stdout_queue, self.ret_codes, True)
expected_output = [ expected_output = [
'0> File %s for %s does not exist, skipping.' % ( '0> File %s for %s does not exist, skipping.' % (
input_filename, output_filename), input_filename, output_filename),
...@@ -250,7 +250,8 @@ class DownloadTests(unittest.TestCase): ...@@ -250,7 +250,8 @@ class DownloadTests(unittest.TestCase):
force=True, force=True,
output=output_filename, output=output_filename,
ignore_errors=False, ignore_errors=False,
sha1_file=False) sha1_file=False,
verbose=True)
expected_calls = [ expected_calls = [
('check_call', ('check_call',
('ls', input_filename)), ('ls', input_filename)),
...@@ -280,7 +281,8 @@ class DownloadTests(unittest.TestCase): ...@@ -280,7 +281,8 @@ class DownloadTests(unittest.TestCase):
force=False, force=False,
output=None, output=None,
ignore_errors=False, ignore_errors=False,
sha1_file=False) sha1_file=False,
verbose=True)
expected_calls = [ expected_calls = [
('check_call', ('check_call',
('ls', input_filename)), ('ls', input_filename)),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment