From f9cc91d9074aa49c3f47fd2220790821bc1e3395 Mon Sep 17 00:00:00 2001 From: "hinoka@google.com" Date: Tue, 4 Jun 2013 03:25:42 +0000 Subject: [PATCH] Change download_from_google_storage.py to not run gsutil config when receiving a 403 When a developer runs download_from_google_storage, and they don't have a .boto file, the tool automatically runs "gsutil config" to create one for them. Unfortunately, a side consequence is that if a bot runs the script, and it has a boto file that 403's, then it would run "gsutil config" which moves the .boto to .boto.bak, and creates an empty .boto file. This should not be the intended action. This CL changes so that "gsutil config" is not called, but instead just fails with a message telling the dev to run that command. TBR=maruel@chromium.org Review URL: https://codereview.chromium.org/16072023 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@203824 0039d316-1c4b-4281-b951-d872f2087c98 --- download_from_google_storage.py | 5 ++--- tests/download_from_google_storage_unittests.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/download_from_google_storage.py b/download_from_google_storage.py index b1891755d..45e299c0b 100755 --- a/download_from_google_storage.py +++ b/download_from_google_storage.py @@ -81,9 +81,8 @@ def check_bucket_permissions(bucket, gsutil): code, _, ls_err = gsutil.check_call('ls', base_url) if code == 403: - code, _, _ = gsutil.call('config') - if code != 0: - print >> sys.stderr, 'Error while authenticating to %s.' % base_url + print >> sys.stderr, 'Got error 403 while authenticating to %s.' % base_url + print >> sys.stderr, 'Try running "gsutil config".' elif code == 404: print >> sys.stderr, '%s not found.' % base_url elif code != 0: diff --git a/tests/download_from_google_storage_unittests.py b/tests/download_from_google_storage_unittests.py index abf12d991..5e5779374 100755 --- a/tests/download_from_google_storage_unittests.py +++ b/tests/download_from_google_storage_unittests.py @@ -82,7 +82,7 @@ class GstoolsUnitTests(unittest.TestCase): self.assertEqual(err_lines[0], 'gsutil version 3.25') self.assertEqual( err_lines[1], - 'checksum ce71ac982f1148315e7fa65cff2f83e8 (OK)') + 'checksum 010822c61d38d70ac23600bc955fccf5 (OK)') def test_get_sha1(self): lorem_ipsum = os.path.join(self.base_path, 'lorem_ipsum.txt')