From 78dec0421b6903c0d260d51aff69d6b7ebf09781 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Thu, 11 Jul 2019 05:09:12 +0000 Subject: [PATCH] Show nice error on failure to enumerage input files. Without this we get an ugly stack trace. This is way more friendly. Bug: 983006 Change-Id: I5ba871ad71ad43bb48d91697e96473afbfe399a0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1697221 Auto-Submit: Eli Ribble Commit-Queue: Robbie Iannucci Reviewed-by: Robbie Iannucci --- download_from_google_storage.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/download_from_google_storage.py b/download_from_google_storage.py index cfaac6ccb7..854caa614e 100755 --- a/download_from_google_storage.py +++ b/download_from_google_storage.py @@ -169,7 +169,9 @@ def enumerate_input(input_filename, directory, recursive, ignore_errors, output, if sha1_file: if not os.path.exists(input_filename): if not ignore_errors: - raise FileNotFoundError('%s not found.' % input_filename) + raise FileNotFoundError( + '{} not found when attempting enumerate files to download.'.format( + input_filename)) print('%s not found.' % input_filename, file=sys.stderr) with open(input_filename, 'rb') as f: sha1_match = re.match(b'^([A-Za-z0-9]{40})$', f.read(1024).rstrip()) @@ -603,11 +605,15 @@ def main(args): base_url = 'gs://%s' % options.bucket - return download_from_google_storage( + try: + 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.verbose, options.auto_platform, options.extract) + except FileNotFoundError as e: + print("Fatal error: {}".format(e)) + return 1 if __name__ == '__main__':