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 <eliribble@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
changes/21/1697221/3
Eli Ribble 6 years ago committed by Commit Bot
parent 08a3d8e2a0
commit 78dec0421b

@ -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__':

Loading…
Cancel
Save